From e6cf5a22e7d52050055385f42aabe0980273be29 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sat, 17 Jan 2026 14:30:01 +0100 Subject: [PATCH] test u128 passing on linux and windows --- compiler/rustc_codegen_ssa/src/mir/block.rs | 5 ++- tests/assembly-llvm/tail-call-indirect.rs | 1 + tests/codegen-llvm/tail-call-u128.rs | 41 +++++++++++++++++++++ tests/ui/explicit-tail-calls/indirect.rs | 3 ++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/codegen-llvm/tail-call-u128.rs diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 4420e95017dc..0d42ccc1a73c 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -1273,8 +1273,11 @@ fn codegen_call_terminator( op.val = Ref(arg.val); } LocalRef::Operand(arg) => { + let Ref(place_value) = arg.val else { + bug!("only `Ref` should use `PassMode::Indirect`"); + }; bx.typed_place_copy( - arg.val.deref(fn_abi.args[i].layout.align.abi), + place_value, tmp.val, fn_abi.args[i].layout, ); diff --git a/tests/assembly-llvm/tail-call-indirect.rs b/tests/assembly-llvm/tail-call-indirect.rs index 106132c974d2..2bc1743a9baf 100644 --- a/tests/assembly-llvm/tail-call-indirect.rs +++ b/tests/assembly-llvm/tail-call-indirect.rs @@ -1,4 +1,5 @@ //@ add-minicore +//@ min-llvm-version: 22 //@ assembly-output: emit-asm //@ needs-llvm-components: x86 //@ compile-flags: --target=x86_64-unknown-linux-gnu diff --git a/tests/codegen-llvm/tail-call-u128.rs b/tests/codegen-llvm/tail-call-u128.rs new file mode 100644 index 000000000000..25dfc47a2bfe --- /dev/null +++ b/tests/codegen-llvm/tail-call-u128.rs @@ -0,0 +1,41 @@ +//@ add-minicore +//@ revisions: win linux +//@ min-llvm-version: 22 +// +//@ compile-flags: -Copt-level=3 +//@[linux] compile-flags: --target x86_64-unknown-linux-gnu +//@[linux] needs-llvm-components: x86 +//@[win] compile-flags: --target x86_64-pc-windows-msvc +//@[win] needs-llvm-components: x86 + +#![crate_type = "lib"] +#![feature(no_core, lang_items, explicit_tail_calls)] +#![allow(incomplete_features)] +#![no_core] + +// Test passing of i128/u128, which is passed directly on x86, but indirectly on win64. + +extern crate minicore; +use minicore::*; + +// linux: define noundef i128 @foo(i128 noundef %a, i128 noundef %b) +// win: define <16 x i8> @foo(ptr {{.*}} %a, ptr {{.*}} %b) +#[unsafe(no_mangle)] +#[inline(never)] +extern "C" fn foo(a: u128, b: u128) -> u128 { + // linux: start: + // linux-NEXT: musttail call noundef i128 @bar(i128 noundef %b, i128 noundef %a) + // + // + // win: start: + // win-NEXT: %0 = load i128, ptr %b + // win-NEXT: %1 = load i128, ptr %a + // win-NEXT: store i128 %0, ptr %a + // win-NEXT: store i128 %1, ptr %b + // win-NEXT: musttail call <16 x i8> @bar(ptr {{.*}} %a, ptr {{.*}} %b) + become bar(b, a) +} + +unsafe extern "C" { + safe fn bar(a: u128, b: u128) -> u128; +} diff --git a/tests/ui/explicit-tail-calls/indirect.rs b/tests/ui/explicit-tail-calls/indirect.rs index a3d38001e9f4..537976b7f6f4 100644 --- a/tests/ui/explicit-tail-calls/indirect.rs +++ b/tests/ui/explicit-tail-calls/indirect.rs @@ -1,5 +1,8 @@ //@ run-pass //@ ignore-backends: gcc +// +//@ ignore-wasm +//@ ignore-riscv64 #![feature(explicit_tail_calls)] #![expect(incomplete_features)]