diff options
author | Mike Stump <mrs@apple.com> | 2009-02-07 23:02:10 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-02-07 23:02:10 +0000 |
commit | 3e9da66ac7e88d64d30ee777588677320660cf84 (patch) | |
tree | 3a6306abbd236f9ad372ed47347dba9ea19e358f /lib/CodeGen/CGStmt.cpp | |
parent | 043254a9d267d48f1289c3274fad0a17f97c435d (diff) |
Ensure we track all the stack depths for all break and continue points
correctly. This should lay the ground work to throw the big switch
and start code gening break and continue in the presense of vlas.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64046 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index c65b8114f3..ac97c6329d 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -466,6 +466,8 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) { EmitBlock(CondBlock); + llvm::Value *saveStackDepth = StackDepth; + // Evaluate the condition if present. If not, treat it as a // non-zero-constant according to 6.8.5.3p2, aka, true. if (S.getCond()) { @@ -491,8 +493,10 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) { ContinueBlock = CondBlock; // Store the blocks to use for break and continue. - BreakContinuePush(AfterFor, ContinueBlock); - + // Ensure any vlas created between there and here, are undone + BreakContinuePush(AfterFor, ContinueBlock, + saveStackDepth, saveStackDepth); + // If the condition is true, execute the body of the for stmt. EmitStmt(S.getBody()); @@ -708,6 +712,9 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) { llvm::SwitchInst *SavedSwitchInsn = SwitchInsn; llvm::BasicBlock *SavedCRBlock = CaseRangeBlock; + // Ensure any vlas created inside are destroyed on break. + llvm::Value *saveBreakStackDepth = StackDepth; + // Create basic block to hold stuff that comes after switch // statement. We also need to create a default block now so that // explicit case ranges tests can have a place to jump to on @@ -723,9 +730,14 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) { // All break statements jump to NextBlock. If BreakContinueStack is non empty // then reuse last ContinueBlock. llvm::BasicBlock *ContinueBlock = NULL; - if (!BreakContinueStack.empty()) + llvm::Value *saveContinueStackDepth = NULL; + if (!BreakContinueStack.empty()) { ContinueBlock = BreakContinueStack.back().ContinueBlock; - BreakContinuePush(NextBlock, ContinueBlock); + saveContinueStackDepth = BreakContinueStack.back().SaveContinueStackDepth; + } + // Ensure any vlas created between there and here, are undone + BreakContinuePush(NextBlock, ContinueBlock, + saveBreakStackDepth, saveContinueStackDepth); // Emit switch body. EmitStmt(S.getBody()); |