From cea1fdd1748e06455940d3aa8a258ab65f232840 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 29 Apr 2008 04:58:38 +0000 Subject: [PATCH] don't delete the last store to an alloca if the store is volatile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50390 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 2 +- test/Transforms/InstCombine/2008-04-28-VolatileStore.ll | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/Transforms/InstCombine/2008-04-28-VolatileStore.ll diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 655ab102599..c707e6ee670 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -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(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 index 00000000000..9bfe7aa1414 --- /dev/null +++ b/test/Transforms/InstCombine/2008-04-28-VolatileStore.ll @@ -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 +} +