aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorMark de Wever <koraq@xs4all.nl>2020-10-31 13:07:06 +0100
committerMark de Wever <koraq@xs4all.nl>2020-10-31 17:51:29 +0100
commitb46fddf75fc27ee1545f00ab853d50b10c1d7ee6 (patch)
treec2376509855c7b939060b18c6d2df99840453f6a /clang/lib/CodeGen/CodeGenFunction.h
parentef6f6d1c1a2819407c8c218119b97e1e656e5ef3 (diff)
downloadllvm-b46fddf75fc27ee1545f00ab853d50b10c1d7ee6.zip
llvm-b46fddf75fc27ee1545f00ab853d50b10c1d7ee6.tar.gz
llvm-b46fddf75fc27ee1545f00ab853d50b10c1d7ee6.tar.bz2
[CodeGen] Implement [[likely]] and [[unlikely]] for while and for loop.
The attribute has no effect on a do statement since the path of execution will always include its substatement. It adds a diagnostic when the attribute is used on an infinite while loop since the codegen omits the branch here. Since the likelihood attributes have no effect on a do statement no diagnostic will be issued for do [[unlikely]] {...} while(0); Differential Revision: https://reviews.llvm.org/D89899
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 2616226..4cf857a 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1407,6 +1407,13 @@ private:
llvm::MDNode *createProfileWeightsForLoop(const Stmt *Cond,
uint64_t LoopCount) const;
+ /// Calculate the branch weight for PGO data or the likelihood attribute.
+ /// The function tries to get the weight of \ref createProfileWeightsForLoop.
+ /// If that fails it gets the weight of \ref createBranchWeights.
+ llvm::MDNode *createProfileOrBranchWeightsForLoop(const Stmt *Cond,
+ uint64_t LoopCount,
+ const Stmt *Body) const;
+
public:
/// Increment the profiler's counter for the given statement by \p StepV.
/// If \p StepV is null, the default increment is 1.