-
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.
f912c90
to
42c719e
Compare
…nd the LLVM codegen bckend.
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
The job Click to see the possible cause of the failure (guessed by this bot)
|
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 |
bx.tail_call(fn_ty, fn_attrs, fn_abi, fn_ptr, llargs, self.funclet(fx), instance); | ||
for &(tmp, size) in lifetime_ends_after_call { | ||
bx.lifetime_end(tmp, size); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lifetime_end
after a musttail call will create ill-formed LLVM IR: "the call must immediately precede a ret instruction, or a pointer bitcast followed by a ret instruction".
It also hints at more fundamental challenge. Arguments using PassMode::Indirect
are passed as pointers to stack allocations which will be deallocated by musttail
call.
Perhaps it would make more sense to bug!
in the situation, until PassMode::Indirect
arguments are actually supported.
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 quite a bit of bikeshedding on how we should go about implementing this for WASM, 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.