Skip to content

Commit ec6d207

Browse files
Merge pull request #72538 from nate-chandler/opaque-values/20240322/1
[OpaqueValues] Pass direct to willThrowTyped.
2 parents 7f74e7a + 7887912 commit ec6d207

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/SILGen/SILGenStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ void SILGenFunction::emitThrow(SILLocation loc, ManagedValue exnMV,
15951595
}, LookUpConformanceInModule(getModule().getSwiftModule()));
15961596

15971597
// Generic errors are passed indirectly.
1598-
if (!exnMV.getType().isAddress()) {
1598+
if (!exnMV.getType().isAddress() && useLoweredAddresses()) {
15991599
// Materialize the error so we can pass the address down to the
16001600
// swift_willThrowTyped.
16011601
exnMV = exnMV.materialize(*this, loc);

test/SILGen/opaque_values_silgen.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,3 +874,14 @@ struct Twople<T> {
874874
self.storage = (t1, t2)
875875
}
876876
}
877+
878+
// CHECK-LABEL: sil{{.*}} [ossa] @throwTypedValue : {{.*}} {
879+
// CHECK: bb0([[E:%[^,]+]] :
880+
// CHECK: [[SWIFT_WILL_THROW_TYPED:%[^,]+]] = function_ref @swift_willThrowTyped
881+
// CHECK: apply [[SWIFT_WILL_THROW_TYPED]]<Err>([[E]])
882+
// CHECK: throw [[E]]
883+
// CHECK-LABEL: } // end sil function 'throwTypedValue'
884+
@_silgen_name("throwTypedValue")
885+
func throwTypedValue(_ e: Err) throws(Err) { throw e }
886+
887+
struct Err : Error {}

0 commit comments

Comments
 (0)