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
4 %struct_t = type { double, double, double }
5 @static_val = constant %struct_t { double 1.0, double 2.0, double 3.0 }
7 declare void @llvm.va_start(i8*) nounwind
8 declare void @llvm.va_end(i8*) nounwind
10 ; CHECK: test_byval_8_bytes_alignment:
11 define void @test_byval_8_bytes_alignment(i32 %i, ...) {
13 ; CHECK: stm r0, {r1, r2, r3}
15 %g1 = bitcast i8** %g to i8*
16 call void @llvm.va_start(i8* %g1)
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)
27 ; CHECK: ldm r0, {r2, r3}
30 call void (i32, ...)* @test_byval_8_bytes_alignment(i32 555, %struct_t* byval @static_val)
34 declare void @f(double);
36 ; CHECK: test_byval_8_bytes_alignment_fixed_arg:
38 ; CHECK: str r3, [sp, #12]
39 ; CHECK: str r2, [sp, #8]
41 define void @test_byval_8_bytes_alignment_fixed_arg(i32 %n1, %struct_t* byval %val) nounwind {
43 %a = getelementptr inbounds %struct_t* %val, i32 0, i32 0
45 call void (double)* @f(double %0)
49 ; CHECK: main_fixed_arg:
50 ; CHECK: ldm r0, {r2, r3}
51 define i32 @main_fixed_arg() {
53 call void (i32, %struct_t*)* @test_byval_8_bytes_alignment_fixed_arg(i32 555, %struct_t* byval @static_val)