eval.begin(*this);
LValue lhs = EmitLValue(expr->getTrueExpr());
eval.end(*this);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
if (!lhs.isSimple())
return EmitUnsupportedLValue(expr, "conditional operator");
eval.begin(*this);
LValue rhs = EmitLValue(expr->getFalseExpr());
eval.end(*this);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
if (!rhs.isSimple())
return EmitUnsupportedLValue(expr, "conditional operator");
rhsBlock = Builder.GetInsertBlock();
CGF.EmitBlock(LHSBlock);
Cnt.beginRegion(Builder);
Visit(E->getTrueExpr());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
eval.end(CGF);
assert(CGF.HaveInsertPoint() && "expression evaluation ended with no IP!");
CGF.EmitBlock(RHSBlock);
Cnt.beginElseRegion();
Visit(E->getFalseExpr());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
eval.end(CGF);
CGF.EmitBlock(ContBlock);
CGF.EmitBlock(LHSBlock);
Cnt.beginRegion(Builder);
ComplexPairTy LHS = Visit(E->getTrueExpr());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
LHSBlock = Builder.GetInsertBlock();
CGF.EmitBranch(ContBlock);
eval.end(CGF);
CGF.EmitBlock(RHSBlock);
Cnt.beginElseRegion();
ComplexPairTy RHS = Visit(E->getFalseExpr());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(ContBlock);
eval.end(CGF);
CGF.EmitBlock(RHSBlock);
Cnt.beginRegion(Builder);
Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
eval.end(CGF);
// Reaquire the RHS block, as there may be subblocks inserted.
CGF.EmitBlock(RHSBlock);
Cnt.beginRegion(Builder);
Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
eval.end(CGF);
eval.begin(CGF);
Value *LHS = Visit(lhsExpr);
eval.end(CGF);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
LHSBlock = Builder.GetInsertBlock();
Builder.CreateBr(ContBlock);
eval.begin(CGF);
Value *RHS = Visit(rhsExpr);
eval.end(CGF);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(ContBlock);
RunCleanupsScope ThenScope(*this);
EmitStmt(S.getThen());
}
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
EmitBranch(ContBlock);
// Emit the 'else' code if present.
RunCleanupsScope ElseScope(*this);
EmitStmt(Else);
}
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
// There is no need to emit line number for unconditional branch.
if (getDebugInfo())
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
Cnt.beginRegion(Builder);
EmitStmt(S.getBody());
}
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
BreakContinueStack.pop_back();
RunCleanupsScope BodyScope(*this);
EmitStmt(S.getBody());
}
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
BreakContinueStack.pop_back();
EmitBlock(Continue.getBlock());
EmitStmt(S.getInc());
}
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
BreakContinueStack.pop_back();
// If there is an increment, emit it next.
EmitBlock(Continue.getBlock());
EmitStmt(S.getInc());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
BreakContinueStack.pop_back();
eval.begin(*this);
EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock, TrueCount);
eval.end(*this);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
Cnt.applyAdjustmentsToRegion();
return;
EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock, RHSCount);
eval.end(*this);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
Cnt.applyAdjustmentsToRegion();
return;
PGO->setCurrentRegionCount(RegionCount);
}
- /// Control may either enter or leave the region, so the count at the end may
- /// be different from the start. Call this to track that adjustment without
- /// modifying the current count. Must not be called before one of beginRegion
- /// or beginElseRegion.
- void adjustFallThroughCount() {
+ /// Adjust for non-local control flow after emitting a subexpression or
+ /// substatement. This must be called to account for constructs such as gotos,
+ /// labels, and returns, so that we can ensure that our region's count is
+ /// correct in the code that follows.
+ void adjustForControlFlow() {
Adjust += PGO->getCurrentRegionCount() - RegionCount;
}
/// Commit all adjustments to the current region. This should be called after
- /// all blocks that adjust the fallthrough count have been emitted.
+ /// all blocks that adjust for control flow count have been emitted.
void applyAdjustmentsToRegion() {
PGO->setCurrentRegionCount(ParentCount + Adjust);
}