diff options
author | Sanjay Patel <spatel@rotateright.com> | 2021-03-20 14:45:56 -0400 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2021-03-20 14:46:46 -0400 |
commit | ee8b53815ddf6f6f94ade0068903cd5ae843fafa (patch) | |
tree | b7d292fd5477f09dba0c9c4f61fa1a0ad0071562 /llvm/lib/Support/BranchProbability.cpp | |
parent | 47fdaa32f97d29ade52232ad8cb16227d195de6a (diff) | |
download | llvm-ee8b53815ddf6f6f94ade0068903cd5ae843fafa.zip llvm-ee8b53815ddf6f6f94ade0068903cd5ae843fafa.tar.gz llvm-ee8b53815ddf6f6f94ade0068903cd5ae843fafa.tar.bz2 |
[BranchProbability] move options for 'likely' and 'unlikely'
This makes the settings available for use in other passes by housing
them within the Support lib, but NFC otherwise.
See D98898 for the proposed usage in SimplifyCFG
(where this change was originally included).
Differential Revision: https://reviews.llvm.org/D98945
Diffstat (limited to 'llvm/lib/Support/BranchProbability.cpp')
-rw-r--r-- | llvm/lib/Support/BranchProbability.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Support/BranchProbability.cpp b/llvm/lib/Support/BranchProbability.cpp index 60d5478..d93d9cf 100644 --- a/llvm/lib/Support/BranchProbability.cpp +++ b/llvm/lib/Support/BranchProbability.cpp @@ -19,6 +19,20 @@ using namespace llvm; +// These default values are chosen to represent an extremely skewed outcome for +// a condition, but they leave some room for interpretation by later passes. +// +// If the documentation for __builtin_expect() was made explicit that it should +// only be used in extreme cases, we could make this ratio higher. As it stands, +// programmers may be using __builtin_expect() / llvm.expect to annotate that a +// branch is only mildly likely or unlikely to be taken. +cl::opt<uint32_t> llvm::LikelyBranchWeight( + "likely-branch-weight", cl::Hidden, cl::init(2000), + cl::desc("Weight of the branch likely to be taken (default = 2000)")); +cl::opt<uint32_t> llvm::UnlikelyBranchWeight( + "unlikely-branch-weight", cl::Hidden, cl::init(1), + cl::desc("Weight of the branch unlikely to be taken (default = 1)")); + constexpr uint32_t BranchProbability::D; raw_ostream &BranchProbability::print(raw_ostream &OS) const { |