1- //
2- // compile-flags: -C no-prepopulate-passes
3- // only-riscv64
4- // only-linux
1+ // compile-flags: --target riscv64gc-unknown-linux-gnu -C no-prepopulate-passes
2+ // needs-llvm-components: riscv
3+
54#![ crate_type = "lib" ]
5+ #![ no_core]
6+ #![ feature( no_core, lang_items) ]
67#![ allow( improper_ctypes) ]
78
9+ #[ lang = "sized" ]
10+ trait Sized { }
11+ #[ lang = "copy" ]
12+ trait Copy { }
13+
814// CHECK: define void @f_void()
915#[ no_mangle]
1016pub extern "C" fn f_void ( ) { }
@@ -70,8 +76,6 @@ pub struct Tiny {
7076// CHECK: define void @f_agg_tiny(i64 %0)
7177#[ no_mangle]
7278pub extern "C" fn f_agg_tiny ( mut e : Tiny ) {
73- e. a += e. b ;
74- e. c += e. d ;
7579}
7680
7781// CHECK: define i64 @f_agg_tiny_ret()
@@ -89,14 +93,12 @@ pub struct Small {
8993// CHECK: define void @f_agg_small([2 x i64] %0)
9094#[ no_mangle]
9195pub extern "C" fn f_agg_small ( mut x : Small ) {
92- x. a += unsafe { * x. b } ;
93- x. b = & mut x. a ;
9496}
9597
9698// CHECK: define [2 x i64] @f_agg_small_ret()
9799#[ no_mangle]
98100pub extern "C" fn f_agg_small_ret ( ) -> Small {
99- Small { a : 1 , b : core :: ptr :: null_mut ( ) }
101+ Small { a : 1 , b : 0 as * mut _ }
100102}
101103
102104#[ repr( C ) ]
@@ -107,7 +109,6 @@ pub struct SmallAligned {
107109// CHECK: define void @f_agg_small_aligned(i128 %0)
108110#[ no_mangle]
109111pub extern "C" fn f_agg_small_aligned ( mut x : SmallAligned ) {
110- x. a += x. a ;
111112}
112113
113114#[ repr( C ) ]
@@ -121,7 +122,6 @@ pub struct Large {
121122// CHECK: define void @f_agg_large(%Large* {{.*}}%x)
122123#[ no_mangle]
123124pub extern "C" fn f_agg_large ( mut x : Large ) {
124- x. a = x. b + x. c + x. d ;
125125}
126126
127127// CHECK: define void @f_agg_large_ret(%Large* {{.*}}sret{{.*}}, i32 signext %i, i8 signext %j)
@@ -172,7 +172,7 @@ pub unsafe extern "C" fn f_va_caller() {
172172 4.0f64 ,
173173 5.0f64 ,
174174 Tiny { a : 1 , b : 2 , c : 3 , d : 4 } ,
175- Small { a : 10 , b : core :: ptr :: null_mut ( ) } ,
175+ Small { a : 10 , b : 0 as * mut _ } ,
176176 SmallAligned { a : 11 } ,
177177 Large { a : 12 , b : 13 , c : 14 , d : 15 } ,
178178 ) ;
0 commit comments