From a05c4c2bcae124d12f4e0ddaa6dce240e552463b Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Sun, 18 Oct 2015 19:34:10 +0000 Subject: [PATCH] Preserve CFG in MergedLoadStoreMotion. This fixes PR24426. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250660 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Scalar/MergedLoadStoreMotion.cpp | 1 + test/Transforms/GVN/pr24426.ll | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/Transforms/GVN/pr24426.ll diff --git a/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp b/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp index 4161d6f7dd7..744ab4b9100 100644 --- a/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp +++ b/lib/Transforms/Scalar/MergedLoadStoreMotion.cpp @@ -118,6 +118,7 @@ public: private: // This transformation requires dominator postdominator info void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.setPreservesCFG(); AU.addRequired(); AU.addRequired(); AU.addPreserved(); diff --git a/test/Transforms/GVN/pr24426.ll b/test/Transforms/GVN/pr24426.ll new file mode 100644 index 00000000000..76b190f8fc2 --- /dev/null +++ b/test/Transforms/GVN/pr24426.ll @@ -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 +} + -- 2.34.1