Skip to content

Conversation

@DougGregor
Copy link
Member

This change moves us toward the official feature, and eliminates the extra level of "thunk" that was implied by @_cdecl. Amusingly, this trips up the LLVM-level ARC optimizations, because we are trying to perform ARC optimizations within the retain/release runtime functions. Teach those optimization passes to leave swift_retainN et al alone.

Note that this also required a bug fix in our handling of @c functions, where we would always serialize the SIL for them because they were being lumped in with foreign thunks.

This eliminates a SIL verification error with `@c` functions, which
provide definitions for foreign entrypoints. We were serializing @c
definitions when we shouldn't be, which would cause problems down the
line if those @c definitions referenced something internal that they
shouldn't.
This change moves us toward the official feature, and eliminates the
extra level of "thunk" that was implied by `@_cdecl`. Amusingly, this
trips up the LLVM-level ARC optimizations, because we are trying to
perform ARC optimizations within the retain/release runtime functions.
Teach those optimization passes to leave swift_retainN et al alone.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor enabled auto-merge November 14, 2025 02:40
@DougGregor DougGregor merged commit 8e37909 into swiftlang:main Nov 14, 2025
3 checks passed
@DougGregor DougGregor deleted the c-funcs-for-embedded-runtime branch November 14, 2025 15:25
@rauhul rauhul added the embedded Embedded Swift label Nov 14, 2025
@gottesmm
Copy link
Contributor

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

embedded Embedded Swift

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants