File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ //@ run-pass
2
+ //@ only-x86_64
3
+ //@ only-linux
4
+ #![ feature( c_variadic) ]
5
+
6
+ #[ repr( C ) ]
7
+ #[ derive( Debug , PartialEq ) ]
8
+ struct Data ( i32 , f64 ) ;
9
+
10
+ #[ unsafe( naked) ]
11
+ unsafe extern "C" fn c_variadic ( _: ...) -> Data {
12
+ // This assembly was generated with GCC, because clang/LLVM is unable to
13
+ // optimize out the spilling of all registers to the stack.
14
+ core:: arch:: naked_asm!(
15
+ " sub rsp, 96" ,
16
+ " mov QWORD PTR [rsp-88], rdi" ,
17
+ " test al, al" ,
18
+ " je .L7" ,
19
+ " movaps XMMWORD PTR [rsp-40], xmm0" ,
20
+ ".L7:" ,
21
+ " lea rax, [rsp+104]" ,
22
+ " mov rcx, QWORD PTR [rsp-40]" ,
23
+ " mov DWORD PTR [rsp-112], 0" ,
24
+ " mov QWORD PTR [rsp-104], rax" ,
25
+ " lea rax, [rsp-88]" ,
26
+ " mov QWORD PTR [rsp-96], rax" ,
27
+ " movq xmm0, rcx" ,
28
+ " mov eax, DWORD PTR [rsp-88]" ,
29
+ " mov DWORD PTR [rsp-108], 48" ,
30
+ " add rsp, 96" ,
31
+ " ret" ,
32
+ )
33
+ }
34
+
35
+ fn main ( ) {
36
+ unsafe {
37
+ assert_eq ! ( c_variadic( 1 , 2.0 ) , Data ( 1 , 2.0 ) ) ;
38
+ assert_eq ! ( c_variadic( 123 , 4.56 ) , Data ( 123 , 4.56 ) ) ;
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments