diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmt.cpp | 16 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.h | 4 |
3 files changed, 13 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 4bdd032a2b9..d3121774463 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2184,7 +2184,7 @@ void CodeGenFunction::EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, call->setCallingConv(getRuntimeCC()); Builder.CreateUnreachable(); } - PGO.setCurrentRegionCount(0); + PGO.setCurrentRegionUnreachable(); } /// Emits a call or invoke instruction to the given nullary runtime diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index ade6ac91852..a9c691ea0cd 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -404,14 +404,14 @@ void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) { EmitStopPoint(&S); EmitBranchThroughCleanup(getJumpDestForLabel(S.getLabel())); - PGO.setCurrentRegionCount(0); + PGO.setCurrentRegionUnreachable(); } void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) { if (const LabelDecl *Target = S.getConstantTarget()) { EmitBranchThroughCleanup(getJumpDestForLabel(Target)); - PGO.setCurrentRegionCount(0); + PGO.setCurrentRegionUnreachable(); return; } @@ -428,7 +428,7 @@ void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) { cast<llvm::PHINode>(IndGotoBB->begin())->addIncoming(V, CurBB); EmitBranch(IndGotoBB); - PGO.setCurrentRegionCount(0); + PGO.setCurrentRegionUnreachable(); } void CodeGenFunction::EmitIfStmt(const IfStmt &S) { @@ -847,7 +847,7 @@ void CodeGenFunction::EmitReturnOfRValue(RValue RV, QualType Ty) { /*init*/ true); } EmitBranchThroughCleanup(ReturnBlock); - PGO.setCurrentRegionCount(0); + PGO.setCurrentRegionUnreachable(); } /// EmitReturnStmt - Note that due to GCC extensions, this can have an operand @@ -920,7 +920,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) { cleanupScope.ForceCleanup(); EmitBranchThroughCleanup(ReturnBlock); - PGO.setCurrentRegionCount(0); + PGO.setCurrentRegionUnreachable(); } void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) { @@ -950,7 +950,7 @@ void CodeGenFunction::EmitBreakStmt(const BreakStmt &S) { if (BC.CountBreak) BC.LoopCnt->getBreakCounter().beginRegion(Builder); EmitBranchThroughCleanup(BC.BreakBlock); - PGO.setCurrentRegionCount(0); + PGO.setCurrentRegionUnreachable(); } void CodeGenFunction::EmitContinueStmt(const ContinueStmt &S) { @@ -967,7 +967,7 @@ void CodeGenFunction::EmitContinueStmt(const ContinueStmt &S) { // non-local exits in PGO instrumentation. BC.LoopCnt->getContinueCounter().beginRegion(Builder); EmitBranchThroughCleanup(BC.ContinueBlock); - PGO.setCurrentRegionCount(0); + PGO.setCurrentRegionUnreachable(); } /// EmitCaseStmtRange - If case statement range is not too big then @@ -1438,7 +1438,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) { // Clear the insertion point to indicate we are in unreachable code. Builder.ClearInsertionPoint(); - PGO.setCurrentRegionCount(0); + PGO.setCurrentRegionUnreachable(); // All break statements jump to NextBlock. If BreakContinueStack is non-empty // then reuse last ContinueBlock and that block's counter. diff --git a/clang/lib/CodeGen/CodeGenPGO.h b/clang/lib/CodeGen/CodeGenPGO.h index 0a0699067b1..a459e42d299 100644 --- a/clang/lib/CodeGen/CodeGenPGO.h +++ b/clang/lib/CodeGen/CodeGenPGO.h @@ -74,6 +74,10 @@ public: /// of changes to the most recent counter from control flow and non-local /// exits. void setCurrentRegionCount(uint64_t Count) { CurrentRegionCount = Count; } + /// Indicate that the current region is never reached, and thus should have a + /// counter value of zero. This is important so that subsequent regions can + /// correctly track their parent counts. + void setCurrentRegionUnreachable() { setCurrentRegionCount(0); } /// Calculate branch weights appropriate for PGO data llvm::MDNode *createBranchWeights(uint64_t TrueCount, uint64_t FalseCount); |