diff options
author | Mike Stump <mrs@apple.com> | 2009-02-07 12:52:26 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-02-07 12:52:26 +0000 |
commit | 36a2ada69fdb457b0e46d0ef452c150b360d8888 (patch) | |
tree | 8c26b9f5bf9120bb8ffd77871bc3a24c6554f7f1 /lib/CodeGen/CodeGenFunction.h | |
parent | 3268825a8e7f68520806e01bf306b21e747dd645 (diff) |
Fixup goto codegen in and around VLAs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64014 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index bf27d0acea..90b0bf45fe 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -144,21 +144,36 @@ private: /// until all AddrLabelExprs have been seen. std::vector<llvm::SwitchInst*> IndirectSwitches; - /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C - /// decls. + /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local + /// C decls. llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap; /// 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. + void BreakContinuePush(llvm::BasicBlock *bb, llvm::BasicBlock *cb) { + BreakContinueStack.push_back(BreakContinue(bb, cb, StackDepth, + ObjCEHStack.size())); + } + + /// BreakContinuePop - Note end of previous break and continue level. + void BreakContinuePop() { + BreakContinueStack.pop_back(); + } + // BreakContinueStack - This keeps track of where break and continue - // statements should jump to, as well as the size of the eh stack. + // statements should jump to, as well as the depth of the stack and the size + // of the eh stack. struct BreakContinue { - BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb, size_t ehss) - : BreakBlock(bb), ContinueBlock(cb), EHStackSize(ehss) {} + BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb, + llvm::Value *sd, size_t ehss) + : BreakBlock(bb), ContinueBlock(cb), SaveStackDepth(sd), + EHStackSize(ehss) {} llvm::BasicBlock *BreakBlock; llvm::BasicBlock *ContinueBlock; + llvm::Value *SaveStackDepth; size_t EHStackSize; }; llvm::SmallVector<BreakContinue, 8> BreakContinueStack; @@ -176,11 +191,23 @@ private: // we enter/leave scopes. llvm::DenseMap<const VariableArrayType*, llvm::Value*> VLASizeMap; + /// StackDepth - This keeps track of the stack depth. It is used to + /// notice when control flow results in a change in stack depth and + /// to arrange for the appropriate stack depth to be restored. + llvm::Value *StackDepth; + /// StackSaveValues - A stack(!) of stack save values. When a new scope is /// entered, a null is pushed on this stack. If a VLA is emitted, then /// the return value of llvm.stacksave() is stored at the top of this stack. llvm::SmallVector<llvm::Value*, 8> StackSaveValues; + llvm::DenseMap<const LabelStmt*, llvm::Value *> StackDepthMap; + + /// EmitStackUpdate - Routine to adjust the stack to the depth the + /// stack should be at by the time we transfer control flow to the + /// label. + void EmitStackUpdate(const LabelStmt &S); + public: CodeGenFunction(CodeGenModule &cgm); |