From 19cd1d84adae29e5c40c9ff2b63bae1e68977733 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Thu, 15 Apr 2010 19:53:35 +0000 Subject: Make sure the initialization of a GC root is after its definition. llvm-svn: 101388 --- llvm/lib/CodeGen/GCStrategy.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/GCStrategy.cpp') diff --git a/llvm/lib/CodeGen/GCStrategy.cpp b/llvm/lib/CodeGen/GCStrategy.cpp index 6d7cc51547d..790cb216489 100644 --- a/llvm/lib/CodeGen/GCStrategy.cpp +++ b/llvm/lib/CodeGen/GCStrategy.cpp @@ -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( - cast((*I)->getType())->getElementType())), - *I, IP); + StoreInst* SI = new StoreInst(ConstantPointerNull::get(cast( + cast((*I)->getType())->getElementType())), + *I); + SI->insertAfter(*I); MadeChange = true; } -- cgit v1.2.3