[llvm] r292249 - [EarlyCSE] Don't DSE across readnone functions that may throw
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 17 12:15:47 PST 2017
Author: sanjoy
Date: Tue Jan 17 14:15:47 2017
New Revision: 292249
URL: http://llvm.org/viewvc/llvm-project?rev=292249&view=rev
Log:
[EarlyCSE] Don't DSE across readnone functions that may throw
Summary: Depends on D28740
Reviewers: dberlin, chandlerc, hfinkel, majnemer
Subscribers: mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D28741
Added:
llvm/trunk/test/Transforms/EarlyCSE/readnone-mayunwind.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp?rev=292249&r1=292248&r2=292249&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp Tue Jan 17 14:15:47 2017
@@ -761,12 +761,13 @@ bool EarlyCSE::processNode(DomTreeNode *
continue;
}
- // If this instruction may read from memory, forget LastStore.
- // Load/store intrinsics will indicate both a read and a write to
- // memory. The target may override this (e.g. so that a store intrinsic
- // does not read from memory, and thus will be treated the same as a
- // regular store for commoning purposes).
- if (Inst->mayReadFromMemory() &&
+ // If this instruction may read from memory or throw (and potentially read
+ // from memory in the exception handler), forget LastStore. Load/store
+ // intrinsics will indicate both a read and a write to memory. The target
+ // may override this (e.g. so that a store intrinsic does not read from
+ // memory, and thus will be treated the same as a regular store for
+ // commoning purposes).
+ if ((Inst->mayReadFromMemory() || Inst->mayThrow()) &&
!(MemInst.isValid() && !MemInst.mayReadFromMemory()))
LastStore = nullptr;
Added: llvm/trunk/test/Transforms/EarlyCSE/readnone-mayunwind.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/EarlyCSE/readnone-mayunwind.ll?rev=292249&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/EarlyCSE/readnone-mayunwind.ll (added)
+++ llvm/trunk/test/Transforms/EarlyCSE/readnone-mayunwind.ll Tue Jan 17 14:15:47 2017
@@ -0,0 +1,15 @@
+; RUN: opt -S -early-cse < %s | FileCheck %s
+
+declare void @readnone_may_unwind() readnone
+
+define void @f(i32* %ptr) {
+; CHECK-LABEL: @f(
+; CHECK: store i32 100, i32* %ptr
+; CHECK: call void @readnone_may_unwind()
+; CHECK: store i32 200, i32* %ptr
+
+ store i32 100, i32* %ptr
+ call void @readnone_may_unwind()
+ store i32 200, i32* %ptr
+ ret void
+}
More information about the llvm-commits
mailing list