Skip to content

SIL: Distinguish "compatible convention" and "compatible representation" function conversions. #28541

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
merged 1 commit into from
Dec 4, 2019

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Dec 3, 2019

We want to be able to use different representations for function types with otherwise compatible
calling conventions. Distinguish these concepts in the checkForABIDifferences SIL APIs, so that
we correctly handle representation-only conversions, which can be handled by convert_function,
from full reabstractions, making sure to note that the representation-only case is not transitive
for function arguments, since a function that takes a function with a representation change needs
a thunk to change the argument's representation.

…on" function conversions.

We want to be able to use different representations for function types with otherwise compatible
calling conventions. Distinguish these concepts in the `checkForABIDifferences` SIL APIs, so that
we correctly handle representation-only conversions, which can be handled by `convert_function`,
from full reabstractions, making sure to note that the representation-only case is not transitive
for function arguments, since a function that takes a function with a representation change needs
a thunk to change the argument's representation.
@jckarter
Copy link
Contributor Author

jckarter commented Dec 3, 2019

@swift-ci Please test

@jckarter
Copy link
Contributor Author

jckarter commented Dec 3, 2019

@swift-ci Please test source compatibility

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

Substantively approved.

// `SameCallingConvention`, then the outer function types may not themselves
// have the `SameCallingConvention` because they need a thunk to convert
// the inner function value representation.
CompatibleCallingConvention,
Copy link
Contributor

Choose a reason for hiding this comment

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

The contrast between this and the cases below isn't clear. Maybe something like:

The types have a representation difference that can be resolved with convert_function, such as a possible difference in ptrauth discriminators.

We don't need to be coy about using ptrauth as an example.

The comment about nested positions applies to all these cases except CompatibleRepresentation, so maybe it should just go there.

Also you keep using SameCallingConvention in these comments, but it looks like you renamed that to CompatibleCallingConvention.

Longer-term question: should we just roll thin_to_thick_function into convert_function, so that we have one instruction for doing superficial conversions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll clean up the comment in a follow up commit.

@jckarter jckarter merged commit 41a116b into master Dec 4, 2019
@compnerd compnerd deleted the subst-function-type-conversion branch June 10, 2025 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants