1 ; RUN: llc < %s -mtriple=armv7-none-linux-gnueabi | FileCheck %s 2 ; Test that we correctly use registers and align elements when using va_arg 3 4 %struct_t = type { double, double, double } 5 @static_val = constant %struct_t { double 1.0, double 2.0, double 3.0 } 6 7 declare void @llvm.va_start(i8*) nounwind 8 declare void @llvm.va_end(i8*) nounwind 9 10 ; CHECK: test_byval_8_bytes_alignment: 11 define void @test_byval_8_bytes_alignment(i32 %i, ...) { 12 entry: 13 ; CHECK: stm r0, {r1, r2, r3} 14 %g = alloca i8* 15 %g1 = bitcast i8** %g to i8* 16 call void @llvm.va_start(i8* %g1) 17 18 ; CHECK: add [[REG:(r[0-9]+)|(lr)]], {{(r[0-9]+)|(lr)}}, #7 19 ; CHECK: bfc [[REG]], #0, #3 20 %0 = va_arg i8** %g, double 21 call void @llvm.va_end(i8* %g1) 22 23 ret void 24 } 25 26 ; CHECK: main: 27 ; CHECK: ldm r0, {r2, r3} 28 define i32 @main() { 29 entry: 30 call void (i32, ...)* @test_byval_8_bytes_alignment(i32 555, %struct_t* byval @static_val) 31 ret i32 0 32 } 33 34 declare void @f(double); 35 36 ; CHECK: test_byval_8_bytes_alignment_fixed_arg: 37 ; CHECK-NOT: str r1 38 ; CHECK: str r3, [sp, #12] 39 ; CHECK: str r2, [sp, #8] 40 ; CHECK-NOT: str r1 41 define void @test_byval_8_bytes_alignment_fixed_arg(i32 %n1, %struct_t* byval %val) nounwind { 42 entry: 43 %a = getelementptr inbounds %struct_t* %val, i32 0, i32 0 44 %0 = load double* %a 45 call void (double)* @f(double %0) 46 ret void 47 } 48 49 ; CHECK: main_fixed_arg: 50 ; CHECK: ldm r0, {r2, r3} 51 define i32 @main_fixed_arg() { 52 entry: 53 call void (i32, %struct_t*)* @test_byval_8_bytes_alignment_fixed_arg(i32 555, %struct_t* byval @static_val) 54 ret i32 0 55 } 56 57