aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorMark de Wever <koraq@xs4all.nl>2020-10-18 13:34:41 +0200
committerMark de Wever <koraq@xs4all.nl>2020-10-18 13:48:42 +0200
commit2bcda6bb2896f0f8daf67343edfc64fb226f3e3f (patch)
treef606041cb0f082b30bd0cfd2bf4a2c3b6cb04234 /clang/lib/CodeGen/CodeGenFunction.h
parent7081db99eee0123f955ab01e550bdfdfce606dd2 (diff)
downloadllvm-2bcda6bb2896f0f8daf67343edfc64fb226f3e3f.zip
llvm-2bcda6bb2896f0f8daf67343edfc64fb226f3e3f.tar.gz
llvm-2bcda6bb2896f0f8daf67343edfc64fb226f3e3f.tar.bz2
[Sema, CodeGen] Implement [[likely]] and [[unlikely]] in SwitchStmt
This implements the likelihood attribute for the switch statement. Based on the discussion in D85091 and D86559 it only handles the attribute when placed on the case labels or the default labels. It also marks the likelihood attribute as feature complete. There are more QoI patches in the pipeline. Differential Revision: https://reviews.llvm.org/D89210
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index a9fb478..0a199e9 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1395,6 +1395,9 @@ private:
};
OpenMPCancelExitStack OMPCancelStack;
+ /// Calculate branch weights for the likelihood attribute
+ llvm::MDNode *createBranchWeights(Stmt::Likelihood LH) const;
+
CodeGenPGO PGO;
/// Calculate branch weights appropriate for PGO data
@@ -1439,6 +1442,9 @@ private:
/// The branch weights of SwitchInsn when doing instrumentation based PGO.
SmallVector<uint64_t, 16> *SwitchWeights = nullptr;
+ /// The likelihood attributes of the SwitchCase.
+ SmallVector<Stmt::Likelihood, 16> *SwitchLikelihood = nullptr;
+
/// CaseRangeBlock - This block holds if condition check for last case
/// statement range in current switch instruction.
llvm::BasicBlock *CaseRangeBlock = nullptr;
@@ -3075,7 +3081,7 @@ public:
/// statements.
///
/// \return True if the statement was handled.
- bool EmitSimpleStmt(const Stmt *S);
+ bool EmitSimpleStmt(const Stmt *S, ArrayRef<const Attr *> Attrs);
Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false,
AggValueSlot AVS = AggValueSlot::ignored());
@@ -3104,9 +3110,9 @@ public:
void EmitBreakStmt(const BreakStmt &S);
void EmitContinueStmt(const ContinueStmt &S);
void EmitSwitchStmt(const SwitchStmt &S);
- void EmitDefaultStmt(const DefaultStmt &S);
- void EmitCaseStmt(const CaseStmt &S);
- void EmitCaseStmtRange(const CaseStmt &S);
+ void EmitDefaultStmt(const DefaultStmt &S, ArrayRef<const Attr *> Attrs);
+ void EmitCaseStmt(const CaseStmt &S, ArrayRef<const Attr *> Attrs);
+ void EmitCaseStmtRange(const CaseStmt &S, ArrayRef<const Attr *> Attrs);
void EmitAsmStmt(const AsmStmt &S);
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S);