From: Hans Wennborg Date: Wed, 1 Feb 2017 16:56:48 +0000 (+0000) Subject: Merging r293658: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ed06de3e1aeb9b8e7bf0eb8d48bedc24ff7b948;p=llvm Merging r293658: ------------------------------------------------------------------------ r293658 | arnolds | 2017-01-31 09:53:49 -0800 (Tue, 31 Jan 2017) | 1 line Don't combine stores to a swifterror pointer operand to a different type ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@293781 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 388c5e4e7fa..49e516e9c17 100644 --- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -502,7 +502,8 @@ static Instruction *combineLoadToOperationType(InstCombiner &IC, LoadInst &LI) { !DL.isNonIntegralPointerType(Ty)) { if (all_of(LI.users(), [&LI](User *U) { auto *SI = dyn_cast(U); - return SI && SI->getPointerOperand() != &LI; + return SI && SI->getPointerOperand() != &LI && + !SI->getPointerOperand()->isSwiftError(); })) { LoadInst *NewLoad = combineLoadToNewType( IC, LI, diff --git a/test/Transforms/InstCombine/load.ll b/test/Transforms/InstCombine/load.ll index cad2899ea35..49ed897fd2e 100644 --- a/test/Transforms/InstCombine/load.ll +++ b/test/Transforms/InstCombine/load.ll @@ -219,3 +219,22 @@ entry: store %swift.error* %err.res, %swift.error** %err, align 8 ret void } + +; Make sure we preseve the type of the store to a swifterror pointer. +; CHECK-LABEL: @test19( +; CHECK: [[A:%.*]] = alloca +; CHECK: call +; CHECK: [[BC:%.*]] = bitcast i8** [[A]] to +; CHECK: [[ERRVAL:%.*]] = load {{.*}}[[BC]] +; CHECK: store {{.*}}[[ERRVAL]] +; CHECK: ret +declare void @initi8(i8**) +define void @test19(%swift.error** swifterror %err) { +entry: + %tmp = alloca i8*, align 8 + call void @initi8(i8** %tmp) + %swifterror = bitcast i8** %tmp to %swift.error** + %err.res = load %swift.error*, %swift.error** %swifterror, align 8 + store %swift.error* %err.res, %swift.error** %err, align 8 + ret void +}