Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
26 changes: 24 additions & 2 deletions tests/ui/explicit-tail-calls/tailcc-no-signature-restriction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
Loading