r199139 - CodeGen: Rename adjustFallThroughCount -> adjustForControlFlow

Justin Bogner mail at justinbogner.com
Mon Jan 13 13:24:23 PST 2014


Author: bogner
Date: Mon Jan 13 15:24:22 2014
New Revision: 199139

URL: http://llvm.org/viewvc/llvm-project?rev=199139&view=rev
Log:
CodeGen: Rename adjustFallThroughCount -> adjustForControlFlow

adjustFallThroughCount isn't a good name, and the documentation was
even worse. This commit attempts to clarify what it's for and when to
use it.

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/CodeGen/CGExprAgg.cpp
    cfe/trunk/lib/CodeGen/CGExprComplex.cpp
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/CodeGen/CodeGenPGO.h

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=199139&r1=199138&r2=199139&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Jan 13 15:24:22 2014
@@ -2680,7 +2680,7 @@ EmitConditionalOperatorLValue(const Abst
   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 Abst
   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();

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=199139&r1=199138&r2=199139&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Mon Jan 13 15:24:22 2014
@@ -903,7 +903,7 @@ VisitAbstractConditionalOperator(const A
   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 A
   CGF.EmitBlock(RHSBlock);
   Cnt.beginElseRegion();
   Visit(E->getFalseExpr());
-  Cnt.adjustFallThroughCount();
+  Cnt.adjustForControlFlow();
   eval.end(CGF);
 
   CGF.EmitBlock(ContBlock);

Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=199139&r1=199138&r2=199139&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Mon Jan 13 15:24:22 2014
@@ -760,7 +760,7 @@ VisitAbstractConditionalOperator(const A
   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 A
   CGF.EmitBlock(RHSBlock);
   Cnt.beginElseRegion();
   ComplexPairTy RHS = Visit(E->getFalseExpr());
-  Cnt.adjustFallThroughCount();
+  Cnt.adjustForControlFlow();
   RHSBlock = Builder.GetInsertBlock();
   CGF.EmitBlock(ContBlock);
   eval.end(CGF);

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=199139&r1=199138&r2=199139&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Jan 13 15:24:22 2014
@@ -2934,7 +2934,7 @@ Value *ScalarExprEmitter::VisitBinLAnd(c
   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(co
   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 A
   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 A
   eval.begin(CGF);
   Value *RHS = Visit(rhsExpr);
   eval.end(CGF);
-  Cnt.adjustFallThroughCount();
+  Cnt.adjustForControlFlow();
 
   RHSBlock = Builder.GetInsertBlock();
   CGF.EmitBlock(ContBlock);

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=199139&r1=199138&r2=199139&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Mon Jan 13 15:24:22 2014
@@ -480,7 +480,7 @@ void CodeGenFunction::EmitIfStmt(const I
     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 I
       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(cons
     Cnt.beginRegion(Builder);
     EmitStmt(S.getBody());
   }
-  Cnt.adjustFallThroughCount();
+  Cnt.adjustForControlFlow();
 
   BreakContinueStack.pop_back();
 
@@ -612,7 +612,7 @@ void CodeGenFunction::EmitDoStmt(const D
     RunCleanupsScope BodyScope(*this);
     EmitStmt(S.getBody());
   }
-  Cnt.adjustFallThroughCount();
+  Cnt.adjustForControlFlow();
 
   BreakContinueStack.pop_back();
 
@@ -732,7 +732,7 @@ void CodeGenFunction::EmitForStmt(const
     EmitBlock(Continue.getBlock());
     EmitStmt(S.getInc());
   }
-  Cnt.adjustFallThroughCount();
+  Cnt.adjustForControlFlow();
 
   BreakContinueStack.pop_back();
 
@@ -815,7 +815,7 @@ void CodeGenFunction::EmitCXXForRangeStm
   // If there is an increment, emit it next.
   EmitBlock(Continue.getBlock());
   EmitStmt(S.getInc());
-  Cnt.adjustFallThroughCount();
+  Cnt.adjustForControlFlow();
 
   BreakContinueStack.pop_back();
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=199139&r1=199138&r2=199139&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Jan 13 15:24:22 2014
@@ -928,7 +928,7 @@ void CodeGenFunction::EmitBranchOnBoolEx
       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::EmitBranchOnBoolEx
       EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock, RHSCount);
 
       eval.end(*this);
-      Cnt.adjustFallThroughCount();
+      Cnt.adjustForControlFlow();
       Cnt.applyAdjustmentsToRegion();
 
       return;

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.h?rev=199139&r1=199138&r2=199139&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.h Mon Jan 13 15:24:22 2014
@@ -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);
   }





More information about the cfe-commits mailing list