[cfe-commits] r64043 - in /cfe/trunk/lib/CodeGen: CodeGenFunction.cpp CodeGenFunction.h
Anders Carlsson
andersca at mac.com
Sat Feb 7 14:53:43 PST 2009
Author: andersca
Date: Sat Feb 7 16:53:43 2009
New Revision: 64043
URL: http://llvm.org/viewvc/llvm-project?rev=64043&view=rev
Log:
Add plumbing for the cleanup stack.
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=64043&r1=64042&r2=64043&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sat Feb 7 16:53:43 2009
@@ -512,3 +512,12 @@
}
return EmitLValue(E).getAddress();
}
+
+llvm::BasicBlock *CodeGenFunction::CreateCleanupBlock()
+{
+ llvm::BasicBlock *CleanupBlock = createBasicBlock("cleanup");
+
+ CleanupEntries.push_back(CleanupEntry(CleanupBlock));
+
+ return CleanupBlock;
+}
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=64043&r1=64042&r2=64043&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Feb 7 16:53:43 2009
@@ -128,6 +128,10 @@
void EmitJumpThroughFinally(ObjCEHEntry *Entry, llvm::BasicBlock *Dest,
bool ExecuteTryExit=true);
+ /// CreateCleanupBlock - Will push a new cleanup entry on the stack
+ /// and return a BasicBlock where cleanup instructions can be added
+ llvm::BasicBlock *CreateCleanupBlock();
+
private:
/// LabelIDs - Track arbitrary ids assigned to labels for use in
/// implementing the GCC address-of-label extension and indirect
@@ -206,6 +210,24 @@
/// label.
void EmitStackUpdate(const LabelStmt &S);
+ struct CleanupEntry {
+ /// CleanupBlock - The block of code that does the actual cleanup.
+ llvm::BasicBlock *CleanupBlock;
+
+ /// Blocks - Basic blocks that were emitted in the current cleanup scope.
+ std::vector<llvm::BasicBlock *> Blocks;
+
+ /// BranchFixups - Branch instructions to basic blocks that haven't been
+ /// inserted into the current function yet.
+ std::vector<llvm::BranchInst*> BranchFixups;
+
+ explicit CleanupEntry(llvm::BasicBlock *cb)
+ : CleanupBlock(cb) {}
+ };
+
+ /// CleanupEntries - Stack of cleanup entries.
+ llvm::SmallVector<CleanupEntry, 8> CleanupEntries;
+
public:
CodeGenFunction(CodeGenModule &cgm);
More information about the cfe-commits
mailing list