Commit 9af6fee
committed
Auto merge of rust-lang#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`File tree
75 files changed
+2386
-174
lines changed- compiler
- rustc_borrowck/src
- polonius
- type_check
- rustc_codegen_cranelift/src
- rustc_codegen_ssa/src/mir
- rustc_const_eval/src
- check_consts
- interpret
- rustc_middle/src/mir
- rustc_mir_build/src
- build
- expr
- rustc_mir_dataflow/src
- impls
- move_paths
- rustc_mir_transform/src
- coverage
- spans
- rustc_monomorphize/src
- rustc_smir/src/rustc_smir/convert
- src/tools
- clippy/clippy_utils/src
- miri
- src
- shims
- tests
- fail/tail_calls
- pass
- tests
- mir-opt
- ui
- explicit-tail-calls
- lint
- parser
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
75 files changed
+2386
-174
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
727 | 727 | | |
728 | 728 | | |
729 | 729 | | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
730 | 736 | | |
731 | 737 | | |
732 | 738 | | |
| |||
813 | 819 | | |
814 | 820 | | |
815 | 821 | | |
| 822 | + | |
816 | 823 | | |
817 | | - | |
818 | | - | |
819 | 824 | | |
820 | 825 | | |
821 | 826 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
128 | 134 | | |
129 | 135 | | |
130 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1352 | 1352 | | |
1353 | 1353 | | |
1354 | 1354 | | |
1355 | | - | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
1356 | 1363 | | |
1357 | 1364 | | |
1358 | 1365 | | |
| |||
1425 | 1432 | | |
1426 | 1433 | | |
1427 | 1434 | | |
1428 | | - | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
1429 | 1438 | | |
1430 | 1439 | | |
1431 | 1440 | | |
| |||
1443 | 1452 | | |
1444 | 1453 | | |
1445 | 1454 | | |
1446 | | - | |
| 1455 | + | |
1447 | 1456 | | |
1448 | 1457 | | |
1449 | 1458 | | |
| |||
1675 | 1684 | | |
1676 | 1685 | | |
1677 | 1686 | | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
1678 | 1692 | | |
1679 | 1693 | | |
1680 | 1694 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
494 | 499 | | |
495 | 500 | | |
496 | 501 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| 570 | + | |
570 | 571 | | |
571 | 572 | | |
572 | 573 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| 284 | + | |
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1389 | 1389 | | |
1390 | 1390 | | |
1391 | 1391 | | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
1392 | 1399 | | |
1393 | 1400 | | |
1394 | 1401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
| |||
711 | 713 | | |
712 | 714 | | |
713 | 715 | | |
714 | | - | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
715 | 724 | | |
716 | 725 | | |
717 | 726 | | |
| |||
783 | 792 | | |
784 | 793 | | |
785 | 794 | | |
786 | | - | |
| 795 | + | |
787 | 796 | | |
788 | 797 | | |
789 | 798 | | |
| |||
830 | 839 | | |
831 | 840 | | |
832 | 841 | | |
833 | | - | |
| 842 | + | |
834 | 843 | | |
835 | 844 | | |
836 | 845 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
0 commit comments