1
Fork 0
rust/compiler/rustc_codegen_cranelift/src
bors 9af6fee87d Auto merge of #113128 - WaffleLapkin:become_trully_unuwuable, r=oli-obk,RalfJung
Support tail calls in mir via `TerminatorKind::TailCall`

This is one of the interesting bits in tail call implementation — MIR support.

This adds a new `TerminatorKind` which represents a tail call:
```rust
    TailCall {
        func: Operand<'tcx>,
        args: Vec<Operand<'tcx>>,
        fn_span: Span,
    },
```

*Structurally* this is very similar to a normal `Call` but is missing a few fields:
- `destination` — tail calls don't write to destination, instead they pass caller's destination to the callee (such that eventual `return` will write to the caller of the function that used tail call)
- `target` — similarly to `destination` tail calls pass the caller's return address to the callee, so there is nothing to do
- `unwind` — I _think_ this is applicable too, although it's a bit confusing
- `call_source` — `become` forbids operators and is not created as a lowering of something else; tail calls always come from HIR (at least for now)

It might be helpful to read the interpreter implementation to understand what `TailCall` means exactly, although I've tried documenting it too.

-----

There are a few `FIXME`-questions still left, ideally we'd be able to answer them during review ':)

-----

r? `@oli-obk`
cc `@scottmcm` `@DrMeepster` `@JakobDegen`
2024-07-08 04:35:04 +00:00
..
abi Fix spans 2024-07-02 15:48:48 -04:00
debuginfo debuginfo: Stabilize -Z debug-macros, -Z collapse-macro-debuginfo and #[collapse_debuginfo] 2024-04-25 22:14:47 +03:00
driver Merge commit '49cd5dd454' into sync_cg_clif-2024-06-30 2024-06-30 11:28:14 +00:00
intrinsics Merge commit '49cd5dd454' into sync_cg_clif-2024-06-30 2024-06-30 11:28:14 +00:00
optimize Merge commit '598f090956' into sync_cg_clif-2023-01-24 2023-01-24 18:56:42 +01:00
allocator.rs Merge commit '49cd5dd454' into sync_cg_clif-2024-06-30 2024-06-30 11:28:14 +00:00
analyze.rs remove redundant imports 2023-12-10 10:56:22 +08:00
archive.rs remove useless lifetime of ArchiveBuilder 2024-02-26 22:37:04 +08:00
base.rs Support tail calls in mir via TerminatorKind::TailCall 2024-07-07 17:11:04 +02:00
cast.rs Merge commit '93a5433f17' into sync_cg_clif-2023-10-24 2023-10-24 12:22:23 +00:00
codegen_i128.rs Remove Rvalue::CheckedBinaryOp 2024-05-17 20:33:02 -07:00
common.rs Merge commit '49cd5dd454' into sync_cg_clif-2024-06-30 2024-06-30 11:28:14 +00:00
compiler_builtins.rs Merge commit 'dec0daa8f6' into sync_cg_clif-2023-03-15 2023-03-15 14:41:48 +00:00
concurrency_limiter.rs Use a dedicated type instead of a reference for the diagnostic context 2024-06-18 15:42:11 +00:00
config.rs Merge commit '3270432f4b' into sync_cg_clif-2024-05-13 2024-05-13 13:26:33 +00:00
constant.rs Auto merge of #113128 - WaffleLapkin:become_trully_unuwuable, r=oli-obk,RalfJung 2024-07-08 04:35:04 +00:00
discriminant.rs Merge commit '3270432f4b' into sync_cg_clif-2024-05-13 2024-05-13 13:26:33 +00:00
global_asm.rs Merge commit '3270432f4b' into sync_cg_clif-2024-05-13 2024-05-13 13:26:33 +00:00
inline_asm.rs Merge commit '49cd5dd454' into sync_cg_clif-2024-06-30 2024-06-30 11:28:14 +00:00
lib.rs Merge commit '49cd5dd454' into sync_cg_clif-2024-06-30 2024-06-30 11:28:14 +00:00
linkage.rs
main_shim.rs Fix spans 2024-07-02 15:48:48 -04:00
num.rs Remove Rvalue::CheckedBinaryOp 2024-05-17 20:33:02 -07:00
pointer.rs Merge commit '81dc066758' into sync_cg_clif-2023-10-09 2023-10-09 08:52:46 +00:00
pretty_clif.rs Rename EarlyErrorHandler as EarlyDiagCtxt. 2023-12-18 16:06:21 +11:00
toolchain.rs Merge commit 'e9d1a0a7b0' into sync_cg_clif-2022-08-24 2022-08-24 18:40:58 +02:00
trap.rs Merge commit '8830dccd1d' into sync_cg_clif-2023-06-15 2023-06-15 17:56:01 +00:00
unsize.rs Only compute vtable information during codegen 2024-06-14 20:35:45 -04:00
unwind_module.rs Merge commit '49cd5dd454' into sync_cg_clif-2024-06-30 2024-06-30 11:28:14 +00:00
value_and_place.rs ScalarInt: size mismatches are a bug, do not delay the panic 2024-06-10 13:43:16 +02:00
vtable.rs Make builtin_deref just return a Ty 2024-05-09 22:55:00 -04:00