diff options
author | Mike Stump <mrs@apple.com> | 2009-02-07 18:08:12 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-02-07 18:08:12 +0000 |
commit | 72cac2ccce8058833f56358e3391e28a8ddeeaa4 (patch) | |
tree | 4b39ee1fe10e1956ca50f5725cf95265f19d946f /lib/CodeGen/CGStmt.cpp | |
parent | 16b16206741f5139c4ad870632db8f9ea4c6c943 (diff) |
Arrange to have the correct StackDepth for while statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64021 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 4e2bca59ea..dc7722c425 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/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()); |