Add support of __builtin_expect_with_probability
authorZhi Zhuang <Zhi.Zhuang@mediatek.com>
Mon, 22 Jun 2020 17:20:42 +0000 (10:20 -0700)
committerErich Keane <erich.keane@intel.com>
Mon, 22 Jun 2020 17:21:28 +0000 (10:21 -0700)
commit37fb860301272d8138d289da5b606115b3fe5a13
treef32b0b47de9a9e7ed9ce1ede6112d67fc8010b83
parent9e1decf7434641411b78a5c140ee1f2eff7f0d50
Add support of __builtin_expect_with_probability

Add a new builtin-function __builtin_expect_with_probability and
intrinsic llvm.expect.with.probability.
The interface is __builtin_expect_with_probability(long expr, long
expected, double probability).
It is mainly the same as __builtin_expect besides one more argument
indicating the probability of expression equal to expected value. The
probability should be a constant floating-point expression and be in
range [0.0, 1.0] inclusive.
It is similar to builtin-expect-with-probability function in GCC
built-in functions.

Differential Revision: https://reviews.llvm.org/D79830
12 files changed:
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtin-expect-with-probability.cpp [new file with mode: 0644]
clang/test/Sema/builtin-expect-with-probability-avr.cpp [new file with mode: 0644]
clang/test/Sema/builtin-expect-with-probability.cpp [new file with mode: 0644]
llvm/docs/BranchWeightMetadata.rst
llvm/docs/LangRef.rst
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll [new file with mode: 0644]