File tree Expand file tree Collapse file tree 2 files changed +90
-0
lines changed Expand file tree Collapse file tree 2 files changed +90
-0
lines changed Original file line number Diff line number Diff line change
1
+ //@ compile-flags: -Copt-level=3
2
+ //@ ignore-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 %rsi) #2
41
+ // CHECK-NEXT: unreachable
42
+ unsafe {
43
+ opaque_with_arg ( rsi) ;
44
+ }
45
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments