Fix PR5471 by removing an instcombine xform. Some pieces of the code
authorChris Lattner <sabre@nondot.org>
Thu, 26 Nov 2009 22:04:42 +0000 (22:04 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 26 Nov 2009 22:04:42 +0000 (22:04 +0000)
generates store to undef and some generates store to null as the idiom
for undefined behavior.  Since simplifycfg zaps both, don't remove the
undefined behavior in instcombine.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89971 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp
test/Transforms/InstCombine/crash.ll
test/Transforms/InstCombine/store.ll

index 670dd1162bd2c3e0c134243ee424eb2268e5fdf4..f997d60a85ee56d17408cc9b3fc2359872b69b31 100644 (file)
@@ -12096,12 +12096,6 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
   Value *Val = SI.getOperand(0);
   Value *Ptr = SI.getOperand(1);
 
-  if (isa<UndefValue>(Ptr)) {     // store X, undef -> noop (even if volatile)
-    EraseInstFromFunction(SI);
-    ++NumCombined;
-    return 0;
-  }
-  
   // If the RHS is an alloca with a single use, zapify the store, making the
   // alloca dead.
   // If the RHS is an alloca with a two uses, the other one being a 
index fbac472e19727865cae7016372b5dee31abdc172..1528f6ddf3c026275219eb23ae5dbf5966d90c7c 100644 (file)
@@ -125,3 +125,15 @@ l10:
   %v11 = select i1 %v5_, i64 0, i64 %v6
   ret i64 %v11
 }
+
+; PR5471
+define arm_apcscc i32 @test5a() {
+       ret i32 0
+}
+
+define arm_apcscc void @test5() {
+       store i1 true, i1* undef
+       %1 = invoke i32 @test5a() to label %exit unwind label %exit
+exit:
+       ret void
+}
index 314441eb86530bb862e6e8509e89ff31d3ac456d..64460d7a6d610e5c0ea5e2070890cea2f4c9a178 100644 (file)
@@ -6,6 +6,7 @@ define void @test1(i32* %P) {
         store i32 124, i32* null
         ret void
 ; CHECK: @test1(
+; CHECK-NEXT: store i32 123, i32* undef
 ; CHECK-NEXT: store i32 undef, i32* null
 ; CHECK-NEXT: ret void
 }