summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp4
-rw-r--r--clang/lib/CodeGen/CGExprAgg.cpp4
-rw-r--r--clang/lib/CodeGen/CGExprComplex.cpp4
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp8
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp12
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp4
-rw-r--r--clang/lib/CodeGen/CodeGenPGO.h12
7 files changed, 24 insertions, 24 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 940022bdddc..4f0c221450f 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2680,7 +2680,7 @@ EmitConditionalOperatorLValue(const AbstractConditionalOperator *expr) {
eval.begin(*this);
LValue lhs = EmitLValue(expr->getTrueExpr());
eval.end(*this);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
if (!lhs.isSimple())
return EmitUnsupportedLValue(expr, "conditional operator");
@@ -2694,7 +2694,7 @@ EmitConditionalOperatorLValue(const AbstractConditionalOperator *expr) {
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();
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 1a6274e8284..3395bd7d33b 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -903,7 +903,7 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
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!");
@@ -919,7 +919,7 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
CGF.EmitBlock(RHSBlock);
Cnt.beginElseRegion();
Visit(E->getFalseExpr());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
eval.end(CGF);
CGF.EmitBlock(ContBlock);
diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp
index 145d94620ee..938b0b331d7 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -760,7 +760,7 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
CGF.EmitBlock(LHSBlock);
Cnt.beginRegion(Builder);
ComplexPairTy LHS = Visit(E->getTrueExpr());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
LHSBlock = Builder.GetInsertBlock();
CGF.EmitBranch(ContBlock);
eval.end(CGF);
@@ -769,7 +769,7 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
CGF.EmitBlock(RHSBlock);
Cnt.beginElseRegion();
ComplexPairTy RHS = Visit(E->getFalseExpr());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(ContBlock);
eval.end(CGF);
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index a38c69494cc..a4e0eeb9f07 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2934,7 +2934,7 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
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.
@@ -3017,7 +3017,7 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
CGF.EmitBlock(RHSBlock);
Cnt.beginRegion(Builder);
Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
eval.end(CGF);
@@ -3171,7 +3171,7 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
eval.begin(CGF);
Value *LHS = Visit(lhsExpr);
eval.end(CGF);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
LHSBlock = Builder.GetInsertBlock();
Builder.CreateBr(ContBlock);
@@ -3181,7 +3181,7 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
eval.begin(CGF);
Value *RHS = Visit(rhsExpr);
eval.end(CGF);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(ContBlock);
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index a9c691ea0cd..79db4184868 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -480,7 +480,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
RunCleanupsScope ThenScope(*this);
EmitStmt(S.getThen());
}
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
EmitBranch(ContBlock);
// Emit the 'else' code if present.
@@ -494,7 +494,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
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());
@@ -569,7 +569,7 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) {
Cnt.beginRegion(Builder);
EmitStmt(S.getBody());
}
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
BreakContinueStack.pop_back();
@@ -612,7 +612,7 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S) {
RunCleanupsScope BodyScope(*this);
EmitStmt(S.getBody());
}
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
BreakContinueStack.pop_back();
@@ -732,7 +732,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
EmitBlock(Continue.getBlock());
EmitStmt(S.getInc());
}
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
BreakContinueStack.pop_back();
@@ -815,7 +815,7 @@ void CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S) {
// If there is an increment, emit it next.
EmitBlock(Continue.getBlock());
EmitStmt(S.getInc());
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
BreakContinueStack.pop_back();
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 564ea11a8f8..a6ed8cb47e3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -928,7 +928,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond,
eval.begin(*this);
EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock, TrueCount);
eval.end(*this);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
Cnt.applyAdjustmentsToRegion();
return;
@@ -974,7 +974,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond,
EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock, RHSCount);
eval.end(*this);
- Cnt.adjustFallThroughCount();
+ Cnt.adjustForControlFlow();
Cnt.applyAdjustmentsToRegion();
return;
diff --git a/clang/lib/CodeGen/CodeGenPGO.h b/clang/lib/CodeGen/CodeGenPGO.h
index a459e42d299..2d1193bab0b 100644
--- a/clang/lib/CodeGen/CodeGenPGO.h
+++ b/clang/lib/CodeGen/CodeGenPGO.h
@@ -200,15 +200,15 @@ public:
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);
}
OpenPOWER on IntegriCloud