Lift the same-signature restriction for extern "tail"#157983
Conversation
|
|
|
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.
| .emit(); | ||
|
|
||
| self.found_errors = Err(err); | ||
| } |
There was a problem hiding this comment.
Maybe also disallow it for extern "tail"?
There was a problem hiding this comment.
This disallows any tail call with unsized arguments (currently that ICEs for e.g. extern "Rust" https://godbolt.org/z/xe888qThd).
Interestingly the test passes locally, and it already has LLVM 22 as the minimum version, so I'm not sure what the problem is here.
There was a problem hiding this comment.
This disallows it on the tail call itself, but my suggestion is to also disallow it for extern "tail" even if no actual tail calls are involved so we don't need to compute any ABI adjustments for at all for extern "tail" with unsized arguments.
|
|
||
| // Check that argument is Sized. | ||
| if !params_can_be_unsized { | ||
| if !params_can_be_unsized || fn_sig.abi() == rustc_abi::ExternAbi::RustTail { |
There was a problem hiding this comment.
@bjorn3 this line here should disallow unsized arguments in extern "tail" signatures. I forgot to push a test file for this, I'll do so shortly.
0a30594 to
ce0a4ed
Compare
ce0a4ed to
73d1dea
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot)For more information how to resolve CI failures of this job, visit this link. |
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