Fix a bug in my patch last night that broke InstCombine/2007-10-12-Crash.ll



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42920 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 2c88279..3096cab 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -8643,8 +8643,14 @@
       // converted to match the type of the cast, don't touch this.
       if (isa<AllocationInst>(BCI->getOperand(0))) {
         // See if the bitcast simplifies, if so, don't nuke this GEP yet.
-        if (visitBitCast(*BCI))
+        if (Instruction *I = visitBitCast(*BCI)) {
+          if (I != BCI) {
+            I->takeName(BCI);
+            BCI->getParent()->getInstList().insert(BCI, I);
+            ReplaceInstUsesWith(*BCI, I);
+          }
           return &GEP;
+        }
       }
       return new BitCastInst(BCI->getOperand(0), GEP.getType());
     }