-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Typed throws] Implement reabstraction thunks that change the error #69700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Typed throws] Implement reabstraction thunks that change the error #69700
Conversation
@swift-ci please smoke test |
Introduce SILGen support for reabstractions thunks that change the error, between indirect and direct errors as well as conversions amongst error types (e.g., from concrete to `any Error`).
This needs to identify typed errors that aren't passed indirectly at the SIL level.
This peephole optimization in SILGen requires us to use the thrown error for the context of a closure type rather than the thrown error for the closure AST node itself.
cfed6e5
to
927e242
Compare
@swift-ci please smoke test |
@swift-ci please build toolchain |
@swift-ci please smoke test |
@swift-ci please build toolchain |
macOS toolchain failure is unrelated. I have more fixes coming, but this is a good step forward---one can write and use a basic |
@@ -30,8 +32,36 @@ func buildMetatype() -> Any.Type { | |||
} | |||
|
|||
// CHECK-NOMANGLE: define linkonce_odr hidden swiftcc %swift.metadata_response @"$sySi12typed_throws10MyBigErrorOYKcMa" | |||
// CHECK: call ptr @swift_getExtendedFunctionTypeMetadata({{i32|i64}} 2231369729, {{i32|i64}} 0, ptr [[PARAMS:%.*]], ptr null, ptr getelementptr inbounds (%swift.full_existential_type, ptr @"$sytN", i32 0, i32 1), ptr null, i32 1, ptr getelementptr inbounds (<{ ptr, ptr, i64, ptr }>, ptr {{.*}}@"$s12typed_throws10MyBigErrorOMf" | |||
// CHECK-NOMANGLE: call ptr @swift_getExtendedFunctionTypeMetadata({{i32|i64}} 2231369729, {{i32|i64}} 0, ptr [[PARAMS:%.*]], ptr null, ptr getelementptr inbounds (%swift.full_existential_type, ptr @"$sytN", i32 0, i32 1), ptr null, i32 1, ptr getelementptr inbounds (<{ ptr, ptr, i64, ptr }>, ptr {{.*}}@"$s12typed_throws10MyBigErrorOMf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DougGregor, this test change fails on the Android armv7 CI, probably on other 32-bit platforms like watchOS or embedded too:
/home/ubuntu/jenkins/workspace/oss-swift-RA-linux-ubuntu-16.04-android/swift/test/IRGen/typed_throws.swift:35:20: error: CHECK-NOMANGLE: expected string not found in input
// CHECK-NOMANGLE: call ptr @swift_getExtendedFunctionTypeMetadata({{i32|i64}} 2231369729, {{i32|i64}} 0, ptr [[PARAMS:%.*]], ptr null, ptr getelementptr inbounds (%swift.full_existential_type, ptr @"$sytN", i32 0, i32 1), ptr null, i32 1, ptr getelementptr inbounds (<{ ptr, ptr, i64, ptr }>, ptr {{.*}}@"$s12typed_throws10MyBigErrorOMf"
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thank you for pointing this out! I'll make the check more general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed by #69792
Introduce SILGen support for reabstractions thunks that change the error, between indirect and direct errors as well as conversions amongst error types (e.g., from concrete to
any Error
).