From: Chris Lattner Date: Tue, 30 Nov 2010 00:12:39 +0000 (+0000) Subject: my previous patch would cause us to start deleting some volatile X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=184d1ba73866b688cef5f78a214e3fb964b6d833;p=oota-llvm.git my previous patch would cause us to start deleting some volatile stores, fix and add a testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120363 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index e1d89cb9109..dd66416e7fe 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -222,7 +222,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) { if (StoreInst *SI = dyn_cast(Inst)) { if (LoadInst *DepLoad = dyn_cast(InstDep.getInst())) { if (SI->getPointerOperand() == DepLoad->getPointerOperand() && - SI->getOperand(0) == DepLoad) { + SI->getOperand(0) == DepLoad && !SI->isVolatile()) { // DeleteDeadInstruction can delete the current instruction. Save BBI // in case we need it. WeakVH NextInst(BBI); diff --git a/test/Transforms/DeadStoreElimination/simple.ll b/test/Transforms/DeadStoreElimination/simple.ll index 6aba1d2125e..05e0d351dee 100644 --- a/test/Transforms/DeadStoreElimination/simple.ll +++ b/test/Transforms/DeadStoreElimination/simple.ll @@ -34,3 +34,23 @@ define i32 @test3(i32* %g_addr) nounwind { %tmp3 = load i32* @g, align 4 ret i32 %tmp3 } + + +define void @test4(i32* %Q) { + %a = load i32* %Q + volatile store i32 %a, i32* %Q + ret void +; CHECK: @test4 +; CHECK-NEXT: load i32 +; CHECK-NEXT: volatile store +; CHECK-NEXT: ret void +} + +define void @test5(i32* %Q) { + %a = volatile load i32* %Q + store i32 %a, i32* %Q + ret void +; CHECK: @test5 +; CHECK-NEXT: volatile load +; CHECK-NEXT: ret void +}