Skip to content
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

[IRGen] Don't call objc_retainAutoreleasedReturnValue() without interop. #72011

Merged
merged 2 commits into from Mar 2, 2024

Conversation

al45tair
Copy link
Contributor

@al45tair al45tair commented Mar 1, 2024

When ObjC interop is not enabled, we shouldn't be emitting calls to objc_retainAutoreleasedReturnValue() as that function might not exist.

Call swift_retain() instead, to balance the swift_release() of the returned value.

Fixes #47846, fixes #45359.

rdar://23335318

@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

@swift-ci Please smoke test

@kateinoigakukun
Copy link
Member

@swift-ci test WebAssembly

@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

@swift-ci test WebAssembly

@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

@swift-ci test WebAssembly

When ObjC interop is not enabled, we shouldn't be emitting calls to
`objc_retainAutoreleasedReturnValue()` as that function might not exist.

Call `swift_retain()` instead, to balance the `swift_release()` of the
returned value.

Fixes apple#47846, apple#45359.

rdar://23335318
@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

@swift-ci test WebAssembly

@compnerd
Copy link
Collaborator

compnerd commented Mar 1, 2024

I wonder if we can remove the workaround in libdispatch with this merged: https://github.com/apple/swift-corelibs-libdispatch/blob/main/src/swift/DispatchStubs.cc#L65-L95

Tweak the tests slightly for WASM, Windows and Darwin.

rdar://23335318
@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

I wonder if we can remove the workaround in libdispatch with this merged: https://github.com/apple/swift-corelibs-libdispatch/blob/main/src/swift/DispatchStubs.cc#L65-L95

That's the idea. And not add another one, which is what prompted me to try to fix this.

@al45tair al45tair requested a review from etcwilde March 1, 2024 21:29
@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

al45tair commented Mar 1, 2024

@swift-ci test WebAssembly

@al45tair
Copy link
Contributor Author

al45tair commented Mar 2, 2024

@swift-ci please smoke test macOS platform

@al45tair
Copy link
Contributor Author

al45tair commented Mar 2, 2024

@swift-ci Please test Linux platform

@al45tair al45tair merged commit 0860953 into apple:main Mar 2, 2024
5 checks passed
@kateinoigakukun
Copy link
Member

Linux + aarch64 CIs are failing

Command Output (stderr):
--
/home/build-user/swift/test/IRGen/cf_objc_retainAutoreleasedReturnValue.swift:20:11: error: CHECK: expected string not found in input
// CHECK: %1 = notail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %0)
          ^
<stdin>:19:40: note: scanning from here
 %0 = call ptr @returnsACFBridgedType()
                                       ^
<stdin>:21:2: note: possible intended match here
 %1 = call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %0)
 ^

Input file: <stdin>
Check file: /home/build-user/swift/test/IRGen/cf_objc_retainAutoreleasedReturnValue.swift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants