Skip to content

[IRGen] Emit keypath thunk helpers with swiftcc to match with the caller cc #39546

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Oct 1, 2021

KeyPath thunk helpers are called from stdlib indirectly through
descriptor and its calling-convention in the caller side are SwiftCC.
However, the definition side expects C calling-convention, so they
can be broken on some architectures, that SwiftCC is not compatible
with C-CC on it.

This patch changes to use SwiftCC consistently on caller side and
definition side.
This doesn't have any effect on the ABI stable platforms because
SwiftCC is compatible with C-CC on them.

The caller-side signatures are defined here without @convention(c)
https://github.com/apple/swift/blob/ef4a2eeb6b8347752897f43351da946cbf1323d7/stdlib/public/core/KeyPath.swift#L481-L486
https://github.com/apple/swift/blob/ef4a2eeb6b8347752897f43351da946cbf1323d7/stdlib/public/core/KeyPath.swift#L568-L581

This fixes case 2 of https://bugs.swift.org/browse/SR-15188

CC: @MaxDesiatov

KeyPath thunk helpers are called from stdlib indirectly through
descriptor and its calling-convention in the caller side is SwiftCC.
However, the definition side expects C calling-convention, so they
can be broken on some architectures, that SwiftCC is not compatible
with C-CC on it.

This patch changes to use SwiftCC consistently on caller side and
definition side.
This doesn't have any effect on the ABI stable platforms because
SwiftCC is compatible with C-CC on them.
@MaxDesiatov MaxDesiatov requested a review from rjmccall October 1, 2021 17:15
@MaxDesiatov
Copy link
Contributor

@swift-ci please smoke test

@kateinoigakukun kateinoigakukun changed the title [IRGen] Emit keypath thunk helpers with swiftcc to match the caller cc [IRGen] Emit keypath thunk helpers with swiftcc to match with the caller cc Oct 1, 2021
@kateinoigakukun
Copy link
Member Author

@swift-ci please test Windows platform

1 similar comment
@MaxDesiatov
Copy link
Contributor

@swift-ci please test Windows platform

Copy link
Contributor

@aschwaighofer aschwaighofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me

@kateinoigakukun kateinoigakukun merged commit b341624 into swiftlang:main Oct 5, 2021
@kateinoigakukun kateinoigakukun deleted the katei/fix-keypath-cc-mismatch branch October 5, 2021 00:50
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants