don't delete the last store to an alloca if the store is volatile.
authorChris Lattner <sabre@nondot.org>
Tue, 29 Apr 2008 04:58:38 +0000 (04:58 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 29 Apr 2008 04:58:38 +0000 (04:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50390 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp
test/Transforms/InstCombine/2008-04-28-VolatileStore.ll [new file with mode: 0644]

index 655ab102599f9adae29108c28cd3f44851f10a56..c707e6ee6705b725adbb58bf634c25a0dd6f9f83 100644 (file)
@@ -10311,7 +10311,7 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
   
   // If the RHS is an alloca with a single use, zapify the store, making the
   // alloca dead.
-  if (Ptr->hasOneUse()) {
+  if (Ptr->hasOneUse() && !SI.isVolatile()) {
     if (isa<AllocaInst>(Ptr)) {
       EraseInstFromFunction(SI);
       ++NumCombined;
diff --git a/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll b/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll
new file mode 100644 (file)
index 0000000..9bfe7aa
--- /dev/null
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {volatile store}
+
+define void @test() {
+       %votf = alloca <4 x float>              ; <<4 x float>*> [#uses=1]
+       volatile store <4 x float> zeroinitializer, <4 x float>* %votf, align 16
+       ret void
+}
+