Preserve CFG in MergedLoadStoreMotion. This fixes PR24426.
authorJakub Staszak <kubastaszak@gmail.com>
Sun, 18 Oct 2015 19:34:10 +0000 (19:34 +0000)
committerJakub Staszak <kubastaszak@gmail.com>
Sun, 18 Oct 2015 19:34:10 +0000 (19:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250660 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/MergedLoadStoreMotion.cpp
test/Transforms/GVN/pr24426.ll [new file with mode: 0644]

index 4161d6f7dd75ce0d9f32573c878f2ec3fce743ed..744ab4b91008b650adc5c0f39c16d71714751311 100644 (file)
@@ -118,6 +118,7 @@ public:
 private:
   // This transformation requires dominator postdominator info
   void getAnalysisUsage(AnalysisUsage &AU) const override {
+    AU.setPreservesCFG();
     AU.addRequired<TargetLibraryInfoWrapperPass>();
     AU.addRequired<AAResultsWrapperPass>();
     AU.addPreserved<GlobalsAAWrapperPass>();
diff --git a/test/Transforms/GVN/pr24426.ll b/test/Transforms/GVN/pr24426.ll
new file mode 100644 (file)
index 0000000..76b190f
--- /dev/null
@@ -0,0 +1,18 @@
+; RUN: opt < %s -memcpyopt -mldst-motion -gvn -S | FileCheck %s
+
+declare void @check(i8)
+
+declare void @write(i8* %res)
+
+define void @test1() {
+  %1 = alloca [10 x i8]
+  %2 = bitcast [10 x i8]* %1 to i8*
+  call void @write(i8* %2)
+  %3 = load i8, i8* %2
+
+; CHECK-NOT: undef
+  call void @check(i8 %3)
+
+  ret void
+}
+