summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-02-07 18:08:12 +0000
committerMike Stump <mrs@apple.com>2009-02-07 18:08:12 +0000
commitdc0d6be7b90a6ad23eda2e121789794cacf4b508 (patch)
tree6f880d11faf2a78155405945caaa6c9cd295a715
parent1f8be1b9ac26459cdafd0725bd28f13a3778361f (diff)
downloadbcm5719-llvm-dc0d6be7b90a6ad23eda2e121789794cacf4b508.tar.gz
bcm5719-llvm-dc0d6be7b90a6ad23eda2e121789794cacf4b508.zip
Arrange to have the correct StackDepth for while statements.
llvm-svn: 64021
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp16
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h5
2 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 4e2bca59ea6..dc7722c4258 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -357,6 +357,14 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) {
// it.
llvm::BasicBlock *LoopHeader = createBasicBlock("while.cond");
EmitBlock(LoopHeader);
+
+ // Create an exit block for when the condition fails, create a block for the
+ // body of the loop.
+ llvm::BasicBlock *ExitBlock = createBasicBlock("while.end");
+ llvm::BasicBlock *LoopBody = createBasicBlock("while.body");
+
+ // Store the blocks to use for break and continue.
+ BreakContinuePush(ExitBlock, LoopHeader);
// Evaluate the conditional in the while header. C99 6.8.5.1: The
// evaluation of the controlling expression takes place before each
@@ -370,18 +378,10 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) {
if (C->isOne())
EmitBoolCondBranch = false;
- // Create an exit block for when the condition fails, create a block for the
- // body of the loop.
- llvm::BasicBlock *ExitBlock = createBasicBlock("while.end");
- llvm::BasicBlock *LoopBody = createBasicBlock("while.body");
-
// As long as the condition is true, go to the loop body.
if (EmitBoolCondBranch)
Builder.CreateCondBr(BoolCondVal, LoopBody, ExitBlock);
- // Store the blocks to use for break and continue.
- BreakContinuePush(ExitBlock, LoopHeader);
-
// Emit the loop body.
EmitBlock(LoopBody);
EmitStmt(S.getBody());
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 90b0bf45fe0..1a251d13632 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -151,7 +151,10 @@ private:
/// LabelMap - This keeps track of the LLVM basic block for each C label.
llvm::DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap;
- /// BreakContinuePush - Note a new break and continue level.
+ /// BreakContinuePush - Note a new break and continue level. This
+ /// must be called at the stack depth of the continue block. In
+ /// particular, this must not be called after the controlling
+ /// condition has possibly started a vla.
void BreakContinuePush(llvm::BasicBlock *bb, llvm::BasicBlock *cb) {
BreakContinueStack.push_back(BreakContinue(bb, cb, StackDepth,
ObjCEHStack.size()));
OpenPOWER on IntegriCloud