-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
enable PassMode::Indirect { on_stack: true, .. } tail call arguments
#153361
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
Merged
rust-bors
merged 1 commit into
rust-lang:main
from
folkertdev:tail-call-indirect-on-stack-true
Mar 5, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| //@ build-pass | ||
| //@ ignore-backends: gcc | ||
| //@ add-minicore | ||
| //@ min-llvm-version: 22 | ||
| // | ||
| //@ revisions: i686 | ||
| //@[i686] compile-flags: --target i686-unknown-linux-gnu | ||
| //@[i686] needs-llvm-components: x86 | ||
| //@ revisions: x86-64 | ||
| //@[x86-64] compile-flags: --target x86_64-unknown-linux-gnu | ||
| //@[x86-64] needs-llvm-components: x86 | ||
| //@ revisions: x86-64-win | ||
| //@[x86-64-win] compile-flags: --target x86_64-pc-windows-msvc | ||
| //@[x86-64-win] needs-llvm-components: x86 | ||
| //@ revisions: arm | ||
| //@[arm] compile-flags: --target arm-unknown-linux-gnueabi | ||
| //@[arm] needs-llvm-components: arm | ||
| //@ revisions: thumb | ||
| //@[thumb] compile-flags: --target thumbv8m.main-none-eabi | ||
| //@[thumb] needs-llvm-components: arm | ||
| //@ revisions: aarch64 | ||
| //@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu | ||
| //@[aarch64] needs-llvm-components: aarch64 | ||
| //@ revisions: s390x | ||
| //@[s390x] compile-flags: --target s390x-unknown-linux-gnu | ||
| //@[s390x] needs-llvm-components: systemz | ||
| //@ revisions: sparc | ||
| //@[sparc] compile-flags: --target sparc-unknown-linux-gnu | ||
| //@[sparc] needs-llvm-components: sparc | ||
| //@ revisions: sparc64 | ||
| //@[sparc64] compile-flags: --target sparc64-unknown-linux-gnu | ||
| //@[sparc64] needs-llvm-components: sparc | ||
| //@ revisions: powerpc64 | ||
| //@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu | ||
| //@[powerpc64] needs-llvm-components: powerpc | ||
| //@ revisions: riscv | ||
| //@[riscv] compile-flags: --target riscv64gc-unknown-linux-gnu | ||
| //@[riscv] needs-llvm-components: riscv | ||
| //@ revisions: loongarch32 | ||
| //@[loongarch32] compile-flags: --target loongarch32-unknown-none | ||
| //@[loongarch32] needs-llvm-components: loongarch | ||
| //@ revisions: loongarch64 | ||
| //@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu | ||
| //@[loongarch64] needs-llvm-components: loongarch | ||
| //@ revisions: bpf | ||
| //@[bpf] compile-flags: --target bpfeb-unknown-none | ||
| //@[bpf] needs-llvm-components: bpf | ||
| //@ revisions: m68k | ||
| //@[m68k] compile-flags: --target m68k-unknown-linux-gnu | ||
| //@[m68k] needs-llvm-components: m68k | ||
| //@ revisions: nvptx64 | ||
| //@[nvptx64] compile-flags: --target nvptx64-nvidia-cuda | ||
| //@[nvptx64] needs-llvm-components: nvptx | ||
| // | ||
| // Wasm needs a special target feature. | ||
| // | ||
| //@ revisions: wasm | ||
| //@[wasm] compile-flags: --target wasm32-unknown-unknown -Ctarget-feature=+tail-call | ||
| //@[wasm] needs-llvm-components: webassembly | ||
| //@ revisions: wasip1 | ||
| //@[wasip1] compile-flags: --target wasm32-wasip1 -Ctarget-feature=+tail-call | ||
| //@[wasip1] needs-llvm-components: webassembly | ||
| // | ||
| // Failing cases (just zero support) | ||
| // | ||
| // //@ revisions: powerpc | ||
| // //@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu | ||
| // //@[powerpc] needs-llvm-components: powerpc | ||
| // //@ revisions: aix | ||
| // //@[aix] compile-flags: --target powerpc64-ibm-aix | ||
| // //@[aix] needs-llvm-components: powerpc | ||
| // //@ revisions: csky | ||
| // //@[csky] compile-flags: --target csky-unknown-linux-gnuabiv2 | ||
| // //@[csky] needs-llvm-components: csky | ||
| // //@ revisions: mips | ||
| // //@[mips] compile-flags: --target mips-unknown-linux-gnu | ||
| // //@[mips] needs-llvm-components: mips | ||
| // //@ revisions: mips64 | ||
| // //@[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 | ||
| // //@[mips64] needs-llvm-components: mips | ||
| #![feature(no_core, explicit_tail_calls)] | ||
| #![expect(incomplete_features)] | ||
| #![no_core] | ||
| #![crate_type = "lib"] | ||
|
|
||
| extern crate minicore; | ||
| use minicore::*; | ||
|
|
||
| #[inline(never)] | ||
| fn simple1(x: u64) -> u64 { | ||
| x | ||
| } | ||
|
|
||
| #[unsafe(no_mangle)] | ||
| fn simple2(x: u64) -> u64 { | ||
| become simple1(x); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| //@ build-pass | ||
| //@ ignore-backends: gcc | ||
| //@ add-minicore | ||
| //@ min-llvm-version: 22 | ||
| // | ||
| //@ revisions: i686 | ||
| //@[i686] compile-flags: --target i686-unknown-linux-gnu | ||
| //@[i686] needs-llvm-components: x86 | ||
| //@ revisions: x86-64 | ||
| //@[x86-64] compile-flags: --target x86_64-unknown-linux-gnu | ||
| //@[x86-64] needs-llvm-components: x86 | ||
| //@ revisions: x86-64-win | ||
| //@[x86-64-win] compile-flags: --target x86_64-pc-windows-msvc | ||
| //@[x86-64-win] needs-llvm-components: x86 | ||
| //@ revisions: arm | ||
| //@[arm] compile-flags: --target arm-unknown-linux-gnueabi | ||
| //@[arm] needs-llvm-components: arm | ||
| //@ revisions: thumb | ||
| //@[thumb] compile-flags: --target thumbv8m.main-none-eabi | ||
| //@[thumb] needs-llvm-components: arm | ||
| //@ revisions: aarch64 | ||
| //@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu | ||
| //@[aarch64] needs-llvm-components: aarch64 | ||
| //@ revisions: s390x | ||
| //@[s390x] compile-flags: --target s390x-unknown-linux-gnu | ||
| //@[s390x] needs-llvm-components: systemz | ||
| //@ revisions: sparc | ||
| //@[sparc] compile-flags: --target sparc-unknown-linux-gnu | ||
| //@[sparc] needs-llvm-components: sparc | ||
| //@ revisions: sparc64 | ||
| //@[sparc64] compile-flags: --target sparc64-unknown-linux-gnu | ||
| //@[sparc64] needs-llvm-components: sparc | ||
| //@ revisions: powerpc64 | ||
| //@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu | ||
| //@[powerpc64] needs-llvm-components: powerpc | ||
| //@ revisions: loongarch32 | ||
| //@[loongarch32] compile-flags: --target loongarch32-unknown-none | ||
| //@[loongarch32] needs-llvm-components: loongarch | ||
| //@ revisions: loongarch64 | ||
| //@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu | ||
| //@[loongarch64] needs-llvm-components: loongarch | ||
| //@ revisions: bpf | ||
| //@[bpf] compile-flags: --target bpfeb-unknown-none | ||
| //@[bpf] needs-llvm-components: bpf | ||
| //@ revisions: m68k | ||
| //@[m68k] compile-flags: --target m68k-unknown-linux-gnu | ||
| //@[m68k] needs-llvm-components: m68k | ||
| //@ revisions: nvptx64 | ||
| //@[nvptx64] compile-flags: --target nvptx64-nvidia-cuda | ||
| //@[nvptx64] needs-llvm-components: nvptx | ||
| // | ||
| // Riscv does not support byval in LLVM 22 (but wil in LLVM 23) | ||
| // | ||
| // //@ revisions: riscv | ||
| // //@[riscv] compile-flags: --target riscv64gc-unknown-linux-gnu | ||
| // //@[riscv] needs-llvm-components: riscv | ||
| // | ||
| // Wasm needs a special target feature. | ||
| // | ||
| //@ revisions: wasm | ||
| //@[wasm] compile-flags: --target wasm32-unknown-unknown -Ctarget-feature=+tail-call | ||
| //@[wasm] needs-llvm-components: webassembly | ||
| //@ revisions: wasip1 | ||
| //@[wasip1] compile-flags: --target wasm32-wasip1 -Ctarget-feature=+tail-call | ||
| //@[wasip1] needs-llvm-components: webassembly | ||
| // | ||
| // Failing cases (just zero support) | ||
| // | ||
| // //@ revisions: powerpc | ||
| // //@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu | ||
| // //@[powerpc] needs-llvm-components: powerpc | ||
| // //@ revisions: aix | ||
| // //@[aix] compile-flags: --target powerpc64-ibm-aix | ||
| // //@[aix] needs-llvm-components: powerpc | ||
| // //@ revisions: csky | ||
| // //@[csky] compile-flags: --target csky-unknown-linux-gnuabiv2 | ||
| // //@[csky] needs-llvm-components: csky | ||
| // //@ revisions: mips | ||
| // //@[mips] compile-flags: --target mips-unknown-linux-gnu | ||
| // //@[mips] needs-llvm-components: mips | ||
| // //@ revisions: mips64 | ||
| // //@[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 | ||
| // //@[mips64] needs-llvm-components: mips | ||
| #![feature(no_core, explicit_tail_calls)] | ||
| #![expect(incomplete_features)] | ||
| #![no_core] | ||
| #![crate_type = "lib"] | ||
|
|
||
| extern crate minicore; | ||
| use minicore::*; | ||
|
|
||
| #[repr(C)] | ||
| struct PassedByVal { | ||
| a: u64, | ||
| b: u64, | ||
| c: u64, | ||
| d: u64, | ||
| } | ||
|
|
||
| #[inline(never)] | ||
| extern "C" fn callee(x: PassedByVal) -> PassedByVal { | ||
| x | ||
| } | ||
|
|
||
| #[unsafe(no_mangle)] | ||
| extern "C" fn byval(x: PassedByVal) -> PassedByVal { | ||
| become callee(x); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| //@ build-pass | ||
| //@ ignore-backends: gcc | ||
| //@ add-minicore | ||
| //@ min-llvm-version: 22 | ||
| // | ||
| //@ revisions: i686 | ||
| //@[i686] compile-flags: --target i686-unknown-linux-gnu | ||
| //@[i686] needs-llvm-components: x86 | ||
| //@ revisions: x86-64 | ||
| //@[x86-64] compile-flags: --target x86_64-unknown-linux-gnu | ||
| //@[x86-64] needs-llvm-components: x86 | ||
| //@ revisions: x86-64-win | ||
| //@[x86-64-win] compile-flags: --target x86_64-pc-windows-msvc | ||
| //@[x86-64-win] needs-llvm-components: x86 | ||
| //@ revisions: arm | ||
| //@[arm] compile-flags: --target arm-unknown-linux-gnueabi | ||
| //@[arm] needs-llvm-components: arm | ||
| //@ revisions: thumb | ||
| //@[thumb] compile-flags: --target thumbv8m.main-none-eabi | ||
| //@[thumb] needs-llvm-components: arm | ||
| //@ revisions: aarch64 | ||
| //@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu | ||
| //@[aarch64] needs-llvm-components: aarch64 | ||
| //@ revisions: s390x | ||
| //@[s390x] compile-flags: --target s390x-unknown-linux-gnu | ||
| //@[s390x] needs-llvm-components: systemz | ||
| //@ revisions: sparc | ||
| //@[sparc] compile-flags: --target sparc-unknown-linux-gnu | ||
| //@[sparc] needs-llvm-components: sparc | ||
| //@ revisions: sparc64 | ||
| //@[sparc64] compile-flags: --target sparc64-unknown-linux-gnu | ||
| //@[sparc64] needs-llvm-components: sparc | ||
| //@ revisions: powerpc64 | ||
| //@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu | ||
| //@[powerpc64] needs-llvm-components: powerpc | ||
| //@ revisions: loongarch32 | ||
| //@[loongarch32] compile-flags: --target loongarch32-unknown-none | ||
| //@[loongarch32] needs-llvm-components: loongarch | ||
| //@ revisions: loongarch64 | ||
| //@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu | ||
| //@[loongarch64] needs-llvm-components: loongarch | ||
| //@ revisions: bpf | ||
| //@[bpf] compile-flags: --target bpfeb-unknown-none | ||
| //@[bpf] needs-llvm-components: bpf | ||
| //@ revisions: m68k | ||
| //@[m68k] compile-flags: --target m68k-unknown-linux-gnu | ||
| //@[m68k] needs-llvm-components: m68k | ||
| //@ revisions: nvptx64 | ||
| //@[nvptx64] compile-flags: --target nvptx64-nvidia-cuda | ||
| //@[nvptx64] needs-llvm-components: nvptx | ||
| // | ||
| // Riscv does not support byval in LLVM 22 (but wil in LLVM 23) | ||
| // | ||
| // //@ revisions: riscv | ||
| // //@[riscv] compile-flags: --target riscv64gc-unknown-linux-gnu | ||
| // //@[riscv] needs-llvm-components: riscv | ||
| // | ||
| // Wasm needs a special target feature. | ||
| // | ||
| //@ revisions: wasm | ||
| //@[wasm] compile-flags: --target wasm32-unknown-unknown -Ctarget-feature=+tail-call | ||
| //@[wasm] needs-llvm-components: webassembly | ||
| //@ revisions: wasip1 | ||
| //@[wasip1] compile-flags: --target wasm32-wasip1 -Ctarget-feature=+tail-call | ||
| //@[wasip1] needs-llvm-components: webassembly | ||
| // | ||
| // Failing cases (just zero support) | ||
| // | ||
| // //@ revisions: powerpc | ||
| // //@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu | ||
| // //@[powerpc] needs-llvm-components: powerpc | ||
| // //@ revisions: aix | ||
| // //@[aix] compile-flags: --target powerpc64-ibm-aix | ||
| // //@[aix] needs-llvm-components: powerpc | ||
| // //@ revisions: csky | ||
| // //@[csky] compile-flags: --target csky-unknown-linux-gnuabiv2 | ||
| // //@[csky] needs-llvm-components: csky | ||
| // //@ revisions: mips | ||
| // //@[mips] compile-flags: --target mips-unknown-linux-gnu | ||
| // //@[mips] needs-llvm-components: mips | ||
| // //@ revisions: mips64 | ||
| // //@[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 | ||
| // //@[mips64] needs-llvm-components: mips | ||
| #![feature(no_core, explicit_tail_calls)] | ||
| #![expect(incomplete_features)] | ||
| #![no_core] | ||
| #![crate_type = "lib"] | ||
|
|
||
| extern crate minicore; | ||
| use minicore::*; | ||
|
|
||
| // The rust calling convention will pass this by-value. | ||
| struct PassedByVal { | ||
| a: u64, | ||
| b: u64, | ||
| c: u64, | ||
| d: u64, | ||
| } | ||
|
|
||
| #[inline(never)] | ||
| fn callee(x: PassedByVal) -> PassedByVal { | ||
| x | ||
| } | ||
|
|
||
| #[unsafe(no_mangle)] | ||
| fn byval(x: PassedByVal) -> PassedByVal { | ||
| become callee(x); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this comment not accurate anymore, shouldn't we wait until we don't support llvm 21 anymore?
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.
you can only use tail calls with nightly, which builds with the latest LLVM? We'll need to wait until we don't support LLVM 21 (or higher, given that e.g. riscv will only add support in LLVM 23) for stabilization, but not for experimentation.