Uh oh!
There was an error while loading. Please reload this page.
rustc_codegen: fix musttail returns for cast/indirect ABIs - #148240
Conversation
rustbot
commented
Oct 29, 2025
Some changes occurred in compiler/rustc_codegen_ssa |
WaffleLapkin
commented
Oct 29, 2025
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 :) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
c58787e to
b677a52Compare
This comment has been minimized.
This comment has been minimized.
b677a52 to
6024333CompareMade changes to address existing comments, the generated IR for Lines 110-125 |
This comment has been minimized.
This comment has been minimized.
InvalidPathException
commented
Oct 29, 2025
How can we properly test this if |
bjorn3
commented
Oct 29, 2025
You can add an |
6024333 to
52959a8CompareInvalidPathException
commented
Oct 30, 2025
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. |
WaffleLapkin
commented
Nov 1, 2025
@bors r+ |
bors
commented
Nov 1, 2025
…fleLapkin rustc_codegen: fix musttail returns for cast/indirect ABIs Fixesrust-lang#148239rust-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
matthiaskrgr
commented
Nov 2, 2025
InvalidPathException
commented
Nov 2, 2025
@rustbot ready |
@InvalidPathException I think you forgot to push the changes addressing CI failure. |
rustbot
commented
Nov 2, 2025
Reminder, once the PR becomes ready for a review, use |
InvalidPathException
commented
Nov 2, 2025
72c9762f500ec24b017506d01427594f34bce250 This should fix it, no? |
InvalidPathException
commented
Nov 2, 2025
Might be because the comment was timestamped weirdly so the timeline became unclear. Not sure why it's dated "in the future". |
WaffleLapkin
commented
Nov 2, 2025
my bad, didn't notice the commit in all the backlinks 🤦🏻 |
bors
commented
Nov 2, 2025
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
Uh oh!
There was an error while loading. Please reload this page.
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
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
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