Don't insert and erase load instruction. Simply create (new) and delete it.
authorJakub Staszak <kubastaszak@gmail.com>
Thu, 1 Nov 2012 01:10:43 +0000 (01:10 +0000)
committerJakub Staszak <kubastaszak@gmail.com>
Thu, 1 Nov 2012 01:10:43 +0000 (01:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167196 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SROA.cpp

index 1d0ba1c2c161e007e7be83f2705436ea557a5fe1..428aa8a472daa3cb32cfa4a7e19a8a8524062ef8 100644 (file)
@@ -2521,12 +2521,12 @@ private:
       // the computed value, and then replace the placeholder with LI, leaving
       // LI only used for this computation.
       Value *Placeholder
-        = IRB.CreateLoad(UndefValue::get(LI.getType()->getPointerTo()));
+        = new LoadInst(UndefValue::get(LI.getType()->getPointerTo()));
       V = insertInteger(TD, IRB, Placeholder, V, BeginOffset,
                         getName(".insert"));
       LI.replaceAllUsesWith(V);
       Placeholder->replaceAllUsesWith(&LI);
-      cast<Instruction>(Placeholder)->eraseFromParent();
+      delete Placeholder;
       if (Pass.DeadSplitInsts.insert(&LI))
         Pass.DeadInsts.push_back(&LI);
       DEBUG(dbgs() << "          to: " << *V << "\n");