From 3590abfda093eb5b5e4536727d2e4195400b7716 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 11 Jun 2009 17:54:56 +0000 Subject: [PATCH] Fix 4366: store to null in non-default addr space should not be turned into unreachable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73195 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 3 ++- test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 6d2ff0e3e53..03a7317138a 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -11824,7 +11824,8 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) { if (SI.isVolatile()) return 0; // Don't hack volatile stores. // store X, null -> turns into 'unreachable' in SimplifyCFG - if (isa(Ptr)) { + if (isa(Ptr) && + cast(Ptr->getType())->getAddressSpace() == 0) { if (!isa(Val)) { SI.setOperand(0, UndefValue::get(Val->getType())); if (Instruction *U = dyn_cast(Val)) diff --git a/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll b/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll new file mode 100644 index 00000000000..e86fed3c364 --- /dev/null +++ b/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll @@ -0,0 +1,7 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep store +; PR4366 + +define void @a() { + store i32 0, i32 addrspace(1)* null + ret void +} -- 2.11.0