Skip to content

Commit 2a5a001

Browse files
committed
Fix tests/uninhabited-transparent-return-abi.rs test failure on riscv64
1 parent 7de63ec commit 2a5a001

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/codegen/uninhabited-transparent-return-abi.rs renamed to tests/codegen/uninhabited-transparent-return-abi-generic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags: -Copt-level=3
2+
//@ ignore-riscv64
23

34
// See https://github.com/rust-lang/rust/issues/135802
45

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//@ compile-flags: -Copt-level=3
2+
//@ only-riscv64
3+
4+
// See https://github.com/rust-lang/rust/issues/135802
5+
6+
#![crate_type = "lib"]
7+
8+
enum Void {}
9+
10+
// Should be ABI-compatible with T, but wasn't prior to the PR adding this test.
11+
#[repr(transparent)]
12+
struct NoReturn<T>(T, Void);
13+
14+
// Returned by invisible reference (in most ABIs)
15+
#[allow(dead_code)]
16+
struct Large(u64, u64, u64);
17+
18+
extern "Rust" {
19+
fn opaque() -> NoReturn<Large>;
20+
fn opaque_with_arg(rsi: u32) -> NoReturn<Large>;
21+
}
22+
23+
// CHECK-LABEL: @test_uninhabited_ret_by_ref
24+
#[no_mangle]
25+
pub fn test_uninhabited_ret_by_ref() {
26+
// CHECK: %_1 = alloca [24 x i8], align {{8|4}}
27+
// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_1)
28+
// CHECK-NEXT: call void @opaque({{.*}} sret([24 x i8]) {{.*}} %_1) #2
29+
// CHECK-NEXT: unreachable
30+
unsafe {
31+
opaque();
32+
}
33+
}
34+
35+
// CHECK-LABEL: @test_uninhabited_ret_by_ref_with_arg
36+
#[no_mangle]
37+
pub fn test_uninhabited_ret_by_ref_with_arg(rsi: u32) {
38+
// CHECK: %_2 = alloca [24 x i8], align {{8|4}}
39+
// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_2)
40+
// CHECK-NEXT: call void @opaque_with_arg({{.*}} sret([24 x i8]) {{.*}} %_2, i32 noundef signext %rsi) #2
41+
// CHECK-NEXT: unreachable
42+
unsafe {
43+
opaque_with_arg(rsi);
44+
}
45+
}

0 commit comments

Comments
 (0)