1 ; RUN: opt < %s -deadargelim -S | FileCheck %s 2 3 declare void @llvm.va_start(i8*) 4 5 define internal i32 @va_func(i32 %a, i32 %b, ...) { 6 %valist = alloca i8 7 call void @llvm.va_start(i8* %valist) 8 9 ret i32 %b 10 } 11 12 ; Function derived from AArch64 ABI, where 8 integer arguments go in 13 ; registers but the 9th goes on the stack. We really don't want to put 14 ; just 7 args in registers and then start on the stack since any 15 ; va_arg implementation already present in va_func won't be expecting 16 ; it. 17 define i32 @call_va(i32 %in) { 18 %stacked = alloca i32 19 store i32 42, i32* %stacked 20 %res = call i32(i32, i32, ...) @va_func(i32 %in, i32 %in, [6 x i32] undef, i32* byval %stacked) 21 ret i32 %res 22 ; CHECK: call i32 (i32, i32, ...) @va_func(i32 undef, i32 %in, [6 x i32] undef, i32* byval %stacked) 23 } 24 25 define internal i32 @va_deadret_func(i32 %a, i32 %b, ...) { 26 %valist = alloca i8 27 call void @llvm.va_start(i8* %valist) 28 29 ret i32 %a 30 } 31 32 define void @call_deadret(i32 %in) { 33 %stacked = alloca i32 34 store i32 42, i32* %stacked 35 call i32 (i32, i32, ...) @va_deadret_func(i32 undef, i32 %in, [6 x i32] undef, i32* byval %stacked) 36 ret void 37 ; CHECK: call void (i32, i32, ...) @va_deadret_func(i32 undef, i32 undef, [6 x i32] undef, i32* byval %stacked) 38 } 39