summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-01-30 13:53:59 +0000
committerSanjay Patel <spatel@rotateright.com>2018-01-30 13:53:59 +0000
commit1aef27f5cdb0f10cff58b4a09c2574bd67dae58c (patch)
tree6542d2abc688ca4e46aa74f3d0e6fb376c4d2df0
parent79d729eef511f4db3c858765be39c38879074de9 (diff)
downloadbcm5719-llvm-1aef27f5cdb0f10cff58b4a09c2574bd67dae58c.tar.gz
bcm5719-llvm-1aef27f5cdb0f10cff58b4a09c2574bd67dae58c.zip
[DSE] make sure memory is not modified before partial store merging (PR36129)
We missed a critical check in D30703. We must make sure that no intermediate store is sitting between the stores that we want to merge. This should fix: https://bugs.llvm.org/show_bug.cgi?id=36129 Differential Revision: https://reviews.llvm.org/D42663 llvm-svn: 323759
-rw-r--r--llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp3
-rw-r--r--llvm/test/Transforms/DeadStoreElimination/merge-stores.ll6
2 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 18cf3592556..6c7d311112a 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1172,7 +1172,8 @@ static bool eliminateDeadStores(BasicBlock &BB, AliasAnalysis *AA,
auto *Earlier = dyn_cast<StoreInst>(DepWrite);
auto *Later = dyn_cast<StoreInst>(Inst);
if (Earlier && isa<ConstantInt>(Earlier->getValueOperand()) &&
- Later && isa<ConstantInt>(Later->getValueOperand())) {
+ Later && isa<ConstantInt>(Later->getValueOperand()) &&
+ memoryIsNotModifiedBetween(Earlier, Later, AA)) {
// If the store we find is:
// a) partially overwritten by the store to 'Loc'
// b) the later store is fully contained in the earlier one and
diff --git a/llvm/test/Transforms/DeadStoreElimination/merge-stores.ll b/llvm/test/Transforms/DeadStoreElimination/merge-stores.ll
index 6bac3b741be..ff1bfaa4d3c 100644
--- a/llvm/test/Transforms/DeadStoreElimination/merge-stores.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/merge-stores.ll
@@ -186,12 +186,14 @@ define void @PR34074(i32* %x, i64* %y) {
ret void
}
-; FIXME: We can't eliminate the last store because P and Q may alias.
+; We can't eliminate the last store because P and Q may alias.
define void @PR36129(i32* %P, i32* %Q) {
; CHECK-LABEL: @PR36129(
-; CHECK-NEXT: store i32 3, i32* [[P:%.*]]
+; CHECK-NEXT: store i32 1, i32* [[P:%.*]]
+; CHECK-NEXT: [[P2:%.*]] = bitcast i32* [[P]] to i8*
; CHECK-NEXT: store i32 2, i32* [[Q:%.*]]
+; CHECK-NEXT: store i8 3, i8* [[P2]]
; CHECK-NEXT: ret void
;
store i32 1, i32* %P
OpenPOWER on IntegriCloud