Skip to content

Commit 85ab5c6

Browse files
authored
Merge pull request #2631 from TNorthover/swifterror-noload
FastISel: do not fold a swifterror load into anything.
2 parents e9d29d0 + 90c8bc5 commit 85ab5c6

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,6 +2413,12 @@ bool FastISel::tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst) {
24132413
if (LI->isVolatile())
24142414
return false;
24152415

2416+
// Swifterror loads are not actually loads.
2417+
if (auto AI = dyn_cast<AllocaInst>(LI->getPointerOperand())) {
2418+
if (AI->isSwiftError())
2419+
return false;
2420+
}
2421+
24162422
// Figure out which vreg this is going into. If there is no assigned vreg yet
24172423
// then there actually was no reference to it. Perhaps the load is referenced
24182424
// by a dead instruction.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: llc -mtriple=x86_64-apple-darwin -O0 %s -o - | FileCheck %s
2+
3+
define i32 @foo() {
4+
; CHECK-LABEL: foo:
5+
; CHECK: cmpq $0, %r12
6+
7+
%swifterror = alloca swifterror i8*
8+
call void @callee(i8** swifterror %swifterror)
9+
%err = load i8*, i8** %swifterror
10+
%tst = icmp ne i8* %err, null
11+
br i1 %tst, label %true, label %false
12+
13+
true:
14+
ret i32 0
15+
16+
false:
17+
ret i32 1
18+
}
19+
20+
declare void @callee(i8** swifterror)

0 commit comments

Comments
 (0)