-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Implement support for become
and explicit tail call codegen for the LLVM backend
#144232
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
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in compiler/rustc_codegen_gcc Some changes occurred in compiler/rustc_codegen_ssa |
6a6d3c2
to
f912c90
Compare
This comment has been minimized.
This comment has been minimized.
b36cf15
to
ac87434
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
138b2a7
to
3fac279
Compare
This comment has been minimized.
This comment has been minimized.
I thought LLVM already supported the Wasm tail-call instructions — what's the missing piece that needs bikeshedding? |
@rustbot author it seems a tailcall test is still hitting a stack overflow, do you know why? |
Reminder, once the PR becomes ready for a review, use |
This was me mistakenly marking the rest |
Ah, my knowledge is outdated then. I've edited my comment, though point still stands for backends that aren't llvm/gcc. |
@rustbot ready |
@WaffleLapkin I'm going to go ahead and guess this is something you want to have a look at. |
@bors r+ Thanks! Glad we finally support it! |
This comment has been minimized.
This comment has been minimized.
ecf34e1
to
4028c67
Compare
@rustbot ready |
@bors r=oli-obk |
…-obk Implement support for `become` and explicit tail call codegen for the LLVM backend This PR implements codegen of explicit tail calls via `become` in `rustc_codegen_ssa` and support within the LLVM backend. Completes a task on (rust-lang#112788). This PR implements all the necessary bits to make explicit tail calls usable, other backends have received stubs for now and will ICE if you use `become` on them. I suspect there is some bikeshedding to be done on how we should go about implementing this for other backends, but it should be relatively straightforward for GCC after this is merged. During development I also put together a POC bytecode VM based on tail call dispatch to test these changes out and analyze the codegen to make sure it generates expected assembly. That is available [here](https://github.com/xacrimon/tcvm).
Rollup of 16 pull requests Successful merges: - #143374 (Unquerify extern_mod_stmt_cnum.) - #143838 (std: net: uefi: Add support to query connection data) - #144014 (don't link to the nightly version of the Edition Guide in stable lints) - #144094 (Ensure we codegen the main fn) - #144218 (Use serde for target spec json deserialize) - #144221 (generate elf symbol version in raw-dylib) - #144232 (Implement support for `become` and explicit tail call codegen for the LLVM backend) - #144240 (Add more test case to check if the false note related to sealed trait suppressed) - #144247 (coretests/num: use ldexp instead of hard-coding a power of 2) - #144276 (Use less HIR in check_private_in_public.) - #144278 (add Rev::into_inner) - #144317 (pass build.npm from bootstrap to tidy and use it for npm install) - #144320 (rustdoc: avoid allocating a temp String for aliases in search index) - #144334 (rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion) - #144335 (Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding) - #144358 (Stop using the old `validate_attr` logic for stability attributes) r? `@ghost` `@rustbot` modify labels: rollup
Failed in rollup: #144387 (comment) ---- [ui] tests/ui/explicit-tail-calls/recursion-no-tce.rs stdout ----
error: test did not crash! code=Some(0) so test would pass with `run-pass`
status: exit status: 0
command: cd "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/explicit-tail-calls/recursion-no-tce" && RUSTC="/checkout/obj/build/unpacked-dist/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/rustc" RUST_TEST_THREADS="36" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/explicit-tail-calls/recursion-no-tce/a"
--- stdout -------------------------------
1000000
------------------------------------------
stderr: none @bors r- |
Yea... I think you can just remove that test, it depends too much on optimizations and stack size and other things outside of our control. |
…nd the LLVM codegen bckend.
4028c67
to
58c6633
Compare
@rustbot ready Alright, that makes sense. It's been removed. |
This PR implements codegen of explicit tail calls via
become
inrustc_codegen_ssa
and support within the LLVM backend. Completes a task on (#112788). This PR implements all the necessary bits to make explicit tail calls usable, other backends have received stubs for now and will ICE if you usebecome
on them. I suspect there is some bikeshedding to be done on how we should go about implementing this for other backends, but it should be relatively straightforward for GCC after this is merged.During development I also put together a POC bytecode VM based on tail call dispatch to test these changes out and analyze the codegen to make sure it generates expected assembly. That is available here.