Lift the same-signature restriction for extern "tail"#157983
Open
folkertdev wants to merge 1 commit into
Open
Conversation
Collaborator
|
|
Member
|
I don't think it is possible supporting unsized arguments with tail calls except for the narrow case where every tail call passes the unsized argument it received from its own caller, in which case |
This comment has been minimized.
This comment has been minimized.
9ff5f86 to
0a30594
Compare
This comment has been minimized.
This comment has been minimized.
bjorn3
reviewed
Jun 16, 2026
folkertdev
commented
Jun 16, 2026
ce0a4ed to
73d1dea
Compare
This comment has been minimized.
This comment has been minimized.
73d1dea to
2a61ca9
Compare
This comment has been minimized.
This comment has been minimized.
2a61ca9 to
0aa786a
Compare
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
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.
tracking issue: #157427
The
extern "tail"calling convention uses callee cleanup (i.e. the callee restores the stack, not the caller). Hence, the same-signature restriction that is normally required to codegen tail calls does not apply.We need the ABI to deviate from
extern "Rust"to make sure indirect arguments are passed by stack offset, not via a pointer into the caller's stack frame (the value would potentially be overwritten). For standard tail calls we work around this problem by storing the value in the caller's caller, but forextern "tail"that doesn't work reliably because the signatures can be different.I'm not sure about unsized arguments. That feature seems really broken, so I'm not sure how much work we should put into trying to do something reasonable there. Fundamentally I don't think we can support unsized arguments in
extern "tail"calls.Also we can't really promote using this yet due to
tailccbeing a bit broken on LLVM 22 on x86_64.r? WaffleLapkin
cc @bjorn3