Make sure the initialization of a GC root is after its definition.
authorNicolas Geoffray <nicolas.geoffray@lip6.fr>
Thu, 15 Apr 2010 19:53:35 +0000 (19:53 +0000)
committerNicolas Geoffray <nicolas.geoffray@lip6.fr>
Thu, 15 Apr 2010 19:53:35 +0000 (19:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101388 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/GCStrategy.cpp

index 6d7cc51547d2f8cfdb70a860fd73a4515b85a14c..790cb21648979beb8f2865daa683354dddbdb158 100644 (file)
@@ -181,9 +181,10 @@ bool LowerIntrinsics::InsertRootInitializers(Function &F, AllocaInst **Roots,
   
   for (AllocaInst **I = Roots, **E = Roots + Count; I != E; ++I)
     if (!InitedRoots.count(*I)) {
-      new StoreInst(ConstantPointerNull::get(cast<PointerType>(
-                      cast<PointerType>((*I)->getType())->getElementType())),
-                    *I, IP);
+      StoreInst* SI = new StoreInst(ConstantPointerNull::get(cast<PointerType>(
+                        cast<PointerType>((*I)->getType())->getElementType())),
+                        *I);
+      SI->insertAfter(*I);
       MadeChange = true;
     }