forked from OSchip/llvm-project
CodeGen: Use EmitBranchOnBool when generating For and CXXForRange
A while ago EmitForStmt was changed to explicitly evaluate the condition expression and create a branch instead of using EmitBranchOnBool, so that the condition expression could be used for some cleanup logic. The cleanup stuff has since been reorganized, and this is no longer necessary. In EmitCXXForRange, the evaluated condition was never used for anything else. The logic was presumably modeled on EmitForStmt. llvm-svn: 193994
This commit is contained in:
parent
085e28e4a6
commit
b23224eede
|
@ -639,7 +639,6 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
|
|||
// Create a cleanup scope for the condition variable cleanups.
|
||||
RunCleanupsScope ConditionScope(*this);
|
||||
|
||||
llvm::Value *BoolCondVal = 0;
|
||||
if (S.getCond()) {
|
||||
// If the for statement has a condition scope, emit the local variable
|
||||
// declaration.
|
||||
|
@ -658,8 +657,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
|
|||
|
||||
// C99 6.8.5p2/p4: The first substatement is executed if the expression
|
||||
// compares unequal to 0. The condition must be a scalar type.
|
||||
BoolCondVal = EvaluateExprAsBool(S.getCond());
|
||||
Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock);
|
||||
EmitBranchOnBoolExpr(S.getCond(), ForBody, ExitBlock);
|
||||
|
||||
if (ExitBlock != LoopExit.getBlock()) {
|
||||
EmitBlock(ExitBlock);
|
||||
|
@ -739,8 +737,7 @@ void CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S) {
|
|||
|
||||
// The body is executed if the expression, contextually converted
|
||||
// to bool, is true.
|
||||
llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
|
||||
Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock);
|
||||
EmitBranchOnBoolExpr(S.getCond(), ForBody, ExitBlock);
|
||||
|
||||
if (ExitBlock != LoopExit.getBlock()) {
|
||||
EmitBlock(ExitBlock);
|
||||
|
|
Loading…
Reference in New Issue