-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SILGen] avoid hop before autoreleased foreign error is retained #68415
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
Merged
kavon
merged 1 commit into
swiftlang:main
from
kavon:autoreleasing-isolated-foreign-errors
Dec 20, 2023
Merged
[SILGen] avoid hop before autoreleased foreign error is retained #68415
kavon
merged 1 commit into
swiftlang:main
from
kavon:autoreleasing-isolated-foreign-errors
Dec 20, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci please smoke test |
40a184e
to
fd0a16c
Compare
@swift-ci please smoke test |
@swift-ci please smoke test |
fd0a16c
to
b0a6f67
Compare
@swift-ci please test |
@swift-ci please test |
b0a6f67
to
1f099f5
Compare
@swift-ci smoke test |
@swift-ci Please Build Toolchain macOS Platform |
1f099f5
to
bd11b28
Compare
@swift-ci please smoke test |
For an isolated ObjC function that is not async, we emit a hops around the call. But if that function returns an autoreleased pointer, we need to ensure we're retaining that pointer before hopping back after the call. We weren't doing that in the case of an autoreleased NSError: ``` %10 = alloc_stack $@sil_unmanaged Optional<NSError> %19 = ... a bunch of steps to wrap up %10 ... %20 = enum $Optional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>, #Optional.some!enumelt, %19 : $AutoreleasingUnsafeMutablePointer<Optional<NSError>> hop_to_executor $MainActor %26 = apply X(Y, %20) : $@convention(objc_method) (NSObject, Optional<AutoreleasingUnsafeMutablePointer<Optional<NSError>>>) -> @autoreleased Optional<NSString> hop_to_executor $Optional<Builtin.Executor> // retain the autoreleased pointer written-out. %28 = load [trivial] %10 : $*@sil_unmanaged Optional<NSError> %29 = unmanaged_to_ref %28 : $@sil_unmanaged Optional<NSError> to $Optional<NSError> %30 = copy_value %29 : $Optional<NSError> assign %31 to %7 : $*Optional<NSError> ``` This patch sinks the hop emission after the call so it happens after doing that copy. rdar://114049646
bd11b28
to
06ac850
Compare
@swift-ci smoke test |
kavon
commented
Dec 19, 2023
linux failure unrelated |
@swift-ci please smoke test linux platform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For an isolated ObjC function that is not async, we emit a hops around the call. But if that function
returns an autoreleased pointer, we need to ensure we're retaining that pointer before hopping back
after the call, because switching actors will trigger the autorelease. We weren't doing that retain beforehand in the case of an autoreleased NSError:
This patch sinks the hop emission after the call
so it happens after doing that copy.
rdar://114049646