-
Notifications
You must be signed in to change notification settings - Fork 13.9k
rustc_codegen: fix musttail returns for cast/indirect ABIs #148240
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
Conversation
|
Some changes occurred in compiler/rustc_codegen_ssa |
|
The best practice I'm usually trying to follow is: add tests in a separate commit (and make them "pass" there, possibly with known bug annotations, etc). That way the second commit with the impl clearly shows how the behavior changed, in the tests' diff. If you have time I'd recommend you do the same here (tip: jj makes splitting/modifying commits easy). And congrats on your first contribution! I'll try to review your PR shortly :) |
c58787e to
b677a52
Compare
This comment has been minimized.
This comment has been minimized.
b677a52 to
6024333
Compare
|
Made changes to address existing comments, the generated IR for Lines 110-125 |
This comment has been minimized.
This comment has been minimized.
How can we properly test this if |
|
You can add an |
6024333 to
52959a8
Compare
|
Tested with a real use case here and it compiles and runs fine. Did not notice any issue + verified it is not lowered to unoptimized recursive calls in IR. |
|
@bors r+ |
…fleLapkin rustc_codegen: fix musttail returns for cast/indirect ABIs Fixes rust-lang#148239 rust-lang#144986 Explicit tail calls trigger `bug!` for any callee whose ABI returns via `PassMode::Cast`, and we forgot to to forward the hidden `sret` out-pointer when the ABI requested an indirect return. The former causes ICE, the latter produced malformed IR (wrong codegen) if the return value is large enough to need `sret`. Updated the musttail helper to accept cast-mode returns, made it so that we pass the return pointer through the tail-call path. Added two UI tests to demonstrate each case. This is my first time contributing, please do check if I did it right. r? theemathas
Rollup of 8 pull requests Successful merges: - #147137 (Mention crate being analyzed in query description) - #148099 (Prepare to move debugger discovery from compiletest to bootstrap) - #148194 (compiletest: Remove `cleanup_debug_info_options`) - #148199 (compiletest: Don't modify `testpaths` when creating aux contexts) - #148240 (rustc_codegen: fix musttail returns for cast/indirect ABIs) - #148247 (Remove two special cases from reachable_non_generics) - #148290 (Do not emit solver errors that contain error types) - #148362 (docs: makes a note about possible building `rustc 1.91.0 + host tools` for win7) r? `@ghost` `@rustbot` modify labels: rollup
…fleLapkin rustc_codegen: fix musttail returns for cast/indirect ABIs Fixes rust-lang#148239 rust-lang#144986 Explicit tail calls trigger `bug!` for any callee whose ABI returns via `PassMode::Cast`, and we forgot to to forward the hidden `sret` out-pointer when the ABI requested an indirect return. The former causes ICE, the latter produced malformed IR (wrong codegen) if the return value is large enough to need `sret`. Updated the musttail helper to accept cast-mode returns, made it so that we pass the return pointer through the tail-call path. Added two UI tests to demonstrate each case. This is my first time contributing, please do check if I did it right. r? theemathas
Rollup of 9 pull requests Successful merges: - #147947 (Implement `strip_circumfix` lib feature) - #148170 (split definition and use site hidden tys) - #148194 (compiletest: Remove `cleanup_debug_info_options`) - #148199 (compiletest: Don't modify `testpaths` when creating aux contexts) - #148240 (rustc_codegen: fix musttail returns for cast/indirect ABIs) - #148290 (Do not emit solver errors that contain error types) - #148357 (temporary-lifetime-extension.rs test works in all editions) - #148362 (docs: makes a note about possible building `rustc 1.91.0 + host tools` for win7) - #148367 (Use --print host-tuple to get the host) r? `@ghost` `@rustbot` modify labels: rollup
|
@rustbot ready |
|
@InvalidPathException I think you forgot to push the changes addressing CI failure. |
|
Reminder, once the PR becomes ready for a review, use |
72c9762f500ec24b017506d01427594f34bce250 This should fix it, no? |
|
Might be because the comment was timestamped weirdly so the timeline became unclear. Not sure why it's dated "in the future". |
|
my bad, didn't notice the commit in all the backlinks 🤦🏻 |
Rollup of 5 pull requests Successful merges: - #144194 (Provide additional context to errors involving const traits) - #148232 (ci: add runners for vanilla LLVM 21) - #148240 (rustc_codegen: fix musttail returns for cast/indirect ABIs) - #148247 (Remove a special case and move another one out of reachable_non_generics) - #148370 (Point at inner item when it uses generic type param from outer item or `Self`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #148240 - InvalidPathException:master, r=WaffleLapkin rustc_codegen: fix musttail returns for cast/indirect ABIs Fixes #148239 #144986 Explicit tail calls trigger `bug!` for any callee whose ABI returns via `PassMode::Cast`, and we forgot to to forward the hidden `sret` out-pointer when the ABI requested an indirect return. The former causes ICE, the latter produced malformed IR (wrong codegen) if the return value is large enough to need `sret`. Updated the musttail helper to accept cast-mode returns, made it so that we pass the return pointer through the tail-call path. Added two UI tests to demonstrate each case. This is my first time contributing, please do check if I did it right. r? theemathas
Rollup of 5 pull requests Successful merges: - rust-lang/rust#144194 (Provide additional context to errors involving const traits) - rust-lang/rust#148232 (ci: add runners for vanilla LLVM 21) - rust-lang/rust#148240 (rustc_codegen: fix musttail returns for cast/indirect ABIs) - rust-lang/rust#148247 (Remove a special case and move another one out of reachable_non_generics) - rust-lang/rust#148370 (Point at inner item when it uses generic type param from outer item or `Self`) r? `@ghost` `@rustbot` modify labels: rollup
Fixes #148239 #144986
Explicit tail calls trigger
bug!for any callee whose ABI returns viaPassMode::Cast, and we forgot to to forward the hiddensretout-pointer when the ABI requested an indirect return. The former causes ICE, the latter produced malformed IR (wrong codegen) if the return value is large enough to needsret.Updated the musttail helper to accept cast-mode returns, made it so that we pass the return pointer through the tail-call path.
Added two UI tests to demonstrate each case.
This is my first time contributing, please do check if I did it right.
r? theemathas