[llvm-branch-commits] [llvm-branch] r324086 - Merging r323759:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Feb 2 05:44:37 PST 2018


Author: hans
Date: Fri Feb  2 05:44:37 2018
New Revision: 324086

URL: http://llvm.org/viewvc/llvm-project?rev=324086&view=rev
Log:
Merging r323759:
------------------------------------------------------------------------
r323759 | spatel | 2018-01-30 14:53:59 +0100 (Tue, 30 Jan 2018) | 10 lines

[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

------------------------------------------------------------------------

Modified:
    llvm/branches/release_60/   (props changed)
    llvm/branches/release_60/lib/Transforms/Scalar/DeadStoreElimination.cpp
    llvm/branches/release_60/test/Transforms/DeadStoreElimination/merge-stores.ll

Propchange: llvm/branches/release_60/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb  2 05:44:37 2018
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,321751,321789,321791,321806,321862,321870,321872,321878,321980,321991,321993-321994,322003,322016,322053,322056,322103,322106,322108,322123,322131,322223,322272,322313,322372,322473,322623,322644,322724,322767,322875,322878-322879,322900,322904-322905,322973,322993,323034,323155,323190,323307,323331,323355,323369,323371,323384,323469,323515,323582,323671-323672,323706,323710,323781,323810-323811,323813,323857,323915
+/llvm/trunk:155241,321751,321789,321791,321806,321862,321870,321872,321878,321980,321991,321993-321994,322003,322016,322053,322056,322103,322106,322108,322123,322131,322223,322272,322313,322372,322473,322623,322644,322724,322767,322875,322878-322879,322900,322904-322905,322973,322993,323034,323155,323190,323307,323331,323355,323369,323371,323384,323469,323515,323582,323671-323672,323706,323710,323759,323781,323810-323811,323813,323857,323915

Modified: llvm/branches/release_60/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=324086&r1=324085&r2=324086&view=diff
==============================================================================
--- llvm/branches/release_60/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/branches/release_60/lib/Transforms/Scalar/DeadStoreElimination.cpp Fri Feb  2 05:44:37 2018
@@ -1176,7 +1176,8 @@ static bool eliminateDeadStores(BasicBlo
           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

Modified: llvm/branches/release_60/test/Transforms/DeadStoreElimination/merge-stores.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/test/Transforms/DeadStoreElimination/merge-stores.ll?rev=324086&r1=324085&r2=324086&view=diff
==============================================================================
--- llvm/branches/release_60/test/Transforms/DeadStoreElimination/merge-stores.ll (original)
+++ llvm/branches/release_60/test/Transforms/DeadStoreElimination/merge-stores.ll Fri Feb  2 05:44:37 2018
@@ -186,6 +186,23 @@ define void @PR34074(i32* %x, i64* %y) {
   ret void
 }
 
+; 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 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
+  %P2 = bitcast i32* %P to i8*
+  store i32 2, i32* %Q
+  store i8 3, i8* %P2
+  ret void
+}
+
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 306512)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
 !1 = !DIFile(filename: "me.cpp", directory: "/compiler-explorer")
 !2 = !{}




More information about the llvm-branch-commits mailing list