Skip to content

Commit b1551d4

Browse files
committed
[6.0] [loadable by address reg2mem] Implement missing throw instruction
Description: Fixes a missing case to large types reg2mem. Without adding this case asserts compiler will complain and cause the compiler to crash. Risk: Low. This is the same code that we would have generated with an no-asserts compiler where we fallback to a solution that loads and stores back to memory. Scope: Fixes a compiler crasher in asserts toolchains. Testing: Regression test added. rdar://134914984 (cherry picked from commit eeaf962)
1 parent 94322e1 commit b1551d4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3861,6 +3861,10 @@ class RewriteUser : SILInstructionVisitor<RewriteUser> {
38613861
userInstructionFallback(kp);
38623862
}
38633863

3864+
void visitYieldInst(YieldInst *yield) { userInstructionFallback(yield); }
3865+
3866+
void visitThrowInst(ThrowInst *t) { userInstructionFallback(t); }
3867+
38643868
void visitFixLifetimeInst(FixLifetimeInst *f) {
38653869
auto addr = assignment.getAddressForValue(f->getOperand());
38663870
auto builder = assignment.getBuilder(f->getIterator());

test/IRGen/loadable_by_address_reg2mem.sil

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,16 @@ bb0(%0 : $*X):
306306
dealloc_stack %1 : $*Y
307307
return %13 : $()
308308
}
309+
310+
// CHECK: sil @test14
311+
// CHECK: [[VAL:%.*]] = load {{.*}} : $*X
312+
// CHECK: throw [[VAL]]
313+
// CHECK: } // end sil function 'test14'
314+
sil @test14 : $@convention(thin) (@in X) -> @error X {
315+
bb0(%0 : $*X):
316+
%1 = alloc_stack $X
317+
copy_addr [take] %0 to [init] %1 : $*X
318+
%3 = load %1 : $*X
319+
dealloc_stack %1 : $*X
320+
throw %3 : $X
321+
}

0 commit comments

Comments
 (0)