diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index 26fedbd8a54..9fe22a3a174 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -845,7 +845,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { // an LLVM aggregate type for this leads to bad optimizations, // so we pick an appropriately sized integer type instead. arg.cast_to_maybe_noundef(Reg { kind: RegKind::Integer, size }, cx); - } else if self.conv == CanonAbi::RustTail { + } else if self.conv == CanonAbi::RustTail && arg_idx.is_some() { assert!(arg.layout.is_sized(), "extern \"tail\" arguments must be sized"); arg.pass_by_stack_offset(None); } diff --git a/tests/ui/explicit-tail-calls/tailcc-no-signature-restriction.rs b/tests/ui/explicit-tail-calls/tailcc-no-signature-restriction.rs index 64cea66c1d5..e32aaa6b696 100644 --- a/tests/ui/explicit-tail-calls/tailcc-no-signature-restriction.rs +++ b/tests/ui/explicit-tail-calls/tailcc-no-signature-restriction.rs @@ -40,10 +40,32 @@ pub extern "tail" fn pass_struct(a: u64, d: u64) -> u64 { become add(large); } +#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), not(windows)))] +#[inline(never)] +pub extern "tail" fn pass_vector(x: [f32; 4]) -> [f32; 4] { + #[derive(Clone, Copy)] + pub struct F32x4([f32; 4]); + + #[inline(never)] + extern "tail" fn identity(x: F32x4) -> F32x4 { + x + } + + #[inline(never)] + extern "tail" fn forward(x: F32x4) -> F32x4 { + become identity(x); + } + + forward(F32x4(x)).0 +} + fn main() { assert_eq!(add(), 3); - // Windows and Aarch64 in LLVM 23 does not support byval arguments. + // Windows and Aarch64 in LLVM 23 do not support byval arguments. #[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), not(windows)))] - assert_eq!(pass_struct(5, 6), 5 + 6); + { + assert_eq!(pass_struct(5, 6), 5 + 6); + assert_eq!(pass_vector([1.0, 2.0, 3.0, 4.0]), [1.0, 2.0, 3.0, 4.0]); + } }