Skip to content

Commit

Permalink
Merging r293658:
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
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
------------------------------------------------------------------------

llvm-svn: 293781
  • Loading branch information
zmodem committed Feb 1, 2017
1 parent e986c14 commit 1494845
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Expand Up @@ -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<StoreInst>(U);
return SI && SI->getPointerOperand() != &LI;
return SI && SI->getPointerOperand() != &LI &&
!SI->getPointerOperand()->isSwiftError();
})) {
LoadInst *NewLoad = combineLoadToNewType(
IC, LI,
Expand Down
19 changes: 19 additions & 0 deletions llvm/test/Transforms/InstCombine/load.ll
Expand Up @@ -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
}

0 comments on commit 1494845

Please sign in to comment.