aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-09-01 02:00:51 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-09-01 02:00:51 +0000
commit5c11e498f848b29be149df74bcfff6ce6bbdfb17 (patch)
tree6dee4698affb94b4ac5b849f0723c80fd0c8aeea /lib/Transforms
parent3ba8d7b20ba265b7bf7e4e214d9aaac5b34b29c0 (diff)
downloadexternal_llvm-5c11e498f848b29be149df74bcfff6ce6bbdfb17.zip
external_llvm-5c11e498f848b29be149df74bcfff6ce6bbdfb17.tar.gz
external_llvm-5c11e498f848b29be149df74bcfff6ce6bbdfb17.tar.bz2
Fix a gcroot lowering bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41668 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/LowerGC.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp
index e157684..0da1d91 100644
--- a/lib/Transforms/Scalar/LowerGC.cpp
+++ b/lib/Transforms/Scalar/LowerGC.cpp
@@ -262,7 +262,7 @@ bool LowerGC::runOnFunction(Function &F) {
cast<PointerType>(GCRootInt->getFunctionType()->getParamType(0));
Constant *Null = ConstantPointerNull::get(PtrLocTy);
- // Initialize all of the gcroot records now, and eliminate them as we go.
+ // Initialize all of the gcroot records now.
for (unsigned i = 0, e = GCRoots.size(); i != e; ++i) {
// Initialize the meta-data pointer.
Par[2] = ConstantInt::get(Type::Int32Ty, i);
@@ -282,7 +282,6 @@ bool LowerGC::runOnFunction(Function &F) {
new StoreInst(Constant::getNullValue(PtrLocTy->getElementType()),
GCRoots[i]->getOperand(1), GCRoots[i]);
new StoreInst(GCRoots[i]->getOperand(1), RootPtrPtr, GCRoots[i]);
- GCRoots[i]->getParent()->getInstList().erase(GCRoots[i]);
}
// Now that the record is all initialized, store the pointer into the global
@@ -290,6 +289,10 @@ bool LowerGC::runOnFunction(Function &F) {
Value *C = new BitCastInst(AI, PointerType::get(MainRootRecordType), "", IP);
new StoreInst(C, RootChain, IP);
+ // Eliminate all the gcroot records now.
+ for (unsigned i = 0, e = GCRoots.size(); i != e; ++i)
+ GCRoots[i]->getParent()->getInstList().erase(GCRoots[i]);
+
// On exit from the function we have to remove the entry from the GC root
// chain. Doing this is straight-forward for return and unwind instructions:
// just insert the appropriate copy.