Skip to content

Commit e6cf5a2

Browse files
committed
test u128 passing on linux and windows
1 parent 31ae3d2 commit e6cf5a2

4 files changed

Lines changed: 49 additions & 1 deletion

File tree

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,8 +1273,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12731273
op.val = Ref(arg.val);
12741274
}
12751275
LocalRef::Operand(arg) => {
1276+
let Ref(place_value) = arg.val else {
1277+
bug!("only `Ref` should use `PassMode::Indirect`");
1278+
};
12761279
bx.typed_place_copy(
1277-
arg.val.deref(fn_abi.args[i].layout.align.abi),
1280+
place_value,
12781281
tmp.val,
12791282
fn_abi.args[i].layout,
12801283
);

tests/assembly-llvm/tail-call-indirect.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ add-minicore
2+
//@ min-llvm-version: 22
23
//@ assembly-output: emit-asm
34
//@ needs-llvm-components: x86
45
//@ compile-flags: --target=x86_64-unknown-linux-gnu
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//@ add-minicore
2+
//@ revisions: win linux
3+
//@ min-llvm-version: 22
4+
//
5+
//@ compile-flags: -Copt-level=3
6+
//@[linux] compile-flags: --target x86_64-unknown-linux-gnu
7+
//@[linux] needs-llvm-components: x86
8+
//@[win] compile-flags: --target x86_64-pc-windows-msvc
9+
//@[win] needs-llvm-components: x86
10+
11+
#![crate_type = "lib"]
12+
#![feature(no_core, lang_items, explicit_tail_calls)]
13+
#![allow(incomplete_features)]
14+
#![no_core]
15+
16+
// Test passing of i128/u128, which is passed directly on x86, but indirectly on win64.
17+
18+
extern crate minicore;
19+
use minicore::*;
20+
21+
// linux: define noundef i128 @foo(i128 noundef %a, i128 noundef %b)
22+
// win: define <16 x i8> @foo(ptr {{.*}} %a, ptr {{.*}} %b)
23+
#[unsafe(no_mangle)]
24+
#[inline(never)]
25+
extern "C" fn foo(a: u128, b: u128) -> u128 {
26+
// linux: start:
27+
// linux-NEXT: musttail call noundef i128 @bar(i128 noundef %b, i128 noundef %a)
28+
//
29+
//
30+
// win: start:
31+
// win-NEXT: %0 = load i128, ptr %b
32+
// win-NEXT: %1 = load i128, ptr %a
33+
// win-NEXT: store i128 %0, ptr %a
34+
// win-NEXT: store i128 %1, ptr %b
35+
// win-NEXT: musttail call <16 x i8> @bar(ptr {{.*}} %a, ptr {{.*}} %b)
36+
become bar(b, a)
37+
}
38+
39+
unsafe extern "C" {
40+
safe fn bar(a: u128, b: u128) -> u128;
41+
}

tests/ui/explicit-tail-calls/indirect.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//@ run-pass
22
//@ ignore-backends: gcc
3+
//
4+
//@ ignore-wasm
5+
//@ ignore-riscv64
36
#![feature(explicit_tail_calls)]
47
#![expect(incomplete_features)]
58

0 commit comments

Comments
 (0)