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;
}
cast<llvm::PHINode>(IndGotoBB->begin())->addIncoming(V, CurBB);
EmitBranch(IndGotoBB);
- PGO.setCurrentRegionCount(0);
+ PGO.setCurrentRegionUnreachable();
}
void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
/*init*/ true);
}
EmitBranchThroughCleanup(ReturnBlock);
- PGO.setCurrentRegionCount(0);
+ PGO.setCurrentRegionUnreachable();
}
/// EmitReturnStmt - Note that due to GCC extensions, this can have an operand
cleanupScope.ForceCleanup();
EmitBranchThroughCleanup(ReturnBlock);
- PGO.setCurrentRegionCount(0);
+ PGO.setCurrentRegionUnreachable();
}
void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
if (BC.CountBreak)
BC.LoopCnt->getBreakCounter().beginRegion(Builder);
EmitBranchThroughCleanup(BC.BreakBlock);
- PGO.setCurrentRegionCount(0);
+ PGO.setCurrentRegionUnreachable();
}
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
// 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.
/// 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);