r199138 - CodeGen: Introduce CodeGenPGO::setCurrentRegionUnreachable
Justin Bogner
mail at justinbogner.com
Mon Jan 13 13:24:18 PST 2014
Author: bogner
Date: Mon Jan 13 15:24:18 2014
New Revision: 199138
URL: http://llvm.org/viewvc/llvm-project?rev=199138&view=rev
Log:
CodeGen: Introduce CodeGenPGO::setCurrentRegionUnreachable
There are a number of places where we do PGO.setCurrentRegionCount(0)
directly after an unconditional branch. Give this operation a name so
that it's clearer why we're doing this.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.h
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=199138&r1=199137&r2=199138&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Jan 13 15:24:18 2014
@@ -2184,7 +2184,7 @@ void CodeGenFunction::EmitNoreturnRuntim
call->setCallingConv(getRuntimeCC());
Builder.CreateUnreachable();
}
- PGO.setCurrentRegionCount(0);
+ PGO.setCurrentRegionUnreachable();
}
/// Emits a call or invoke instruction to the given nullary runtime
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=199138&r1=199137&r2=199138&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Mon Jan 13 15:24:18 2014
@@ -404,14 +404,14 @@ void CodeGenFunction::EmitGotoStmt(const
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::EmitIndirectGotoSt
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
/*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(con
cleanupScope.ForceCleanup();
EmitBranchThroughCleanup(ReturnBlock);
- PGO.setCurrentRegionCount(0);
+ PGO.setCurrentRegionUnreachable();
}
void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
@@ -950,7 +950,7 @@ void CodeGenFunction::EmitBreakStmt(cons
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(c
// 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(con
// 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.
Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.h?rev=199138&r1=199137&r2=199138&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.h Mon Jan 13 15:24:18 2014
@@ -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);
More information about the cfe-commits
mailing list