summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2013-11-22 10:20:43 +0000
committerJustin Bogner <mail@justinbogner.com>2013-11-22 10:20:43 +0000
commit7fa2eb9f49e6dbf8317405de06d418ae7e77f267 (patch)
tree1d30a14b7be2f99064689718a35feefb4e048d50 /clang/lib/CodeGen/CGStmt.cpp
parent0f06606b68fee7b41225d91d79cf2d27a151ff93 (diff)
downloadbcm5719-llvm-7fa2eb9f49e6dbf8317405de06d418ae7e77f267.tar.gz
bcm5719-llvm-7fa2eb9f49e6dbf8317405de06d418ae7e77f267.zip
Revert r193994 and part of r193995
Not long ago I made the CodeGen of for loops simplify the condition at -O0 in the same way we do for if and conditionals. Unfortunately this ties how loops and simple conditions work together too tightly, which makes features such as instrumentation based PGO awkward. Ultimately, we should find a more general way to simplify the logic in a given condition, but for now we'll just avoid using EmitBranchOnBool for loops, like we already do for while and do loops. llvm-svn: 195438
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 1d91e926865..8325dddbb8a 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -657,7 +657,8 @@ 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.
- EmitBranchOnBoolExpr(S.getCond(), ForBody, ExitBlock);
+ llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
+ Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock);
if (ExitBlock != LoopExit.getBlock()) {
EmitBlock(ExitBlock);
@@ -737,7 +738,8 @@ void CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S) {
// The body is executed if the expression, contextually converted
// to bool, is true.
- EmitBranchOnBoolExpr(S.getCond(), ForBody, ExitBlock);
+ llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
+ Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock);
if (ExitBlock != LoopExit.getBlock()) {
EmitBlock(ExitBlock);
OpenPOWER on IntegriCloud