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-LABEL: test_byval_8_bytes_alignment:
11 define void @test_byval_8_bytes_alignment(i32 %i, ...) {
13 ; CHECK: sub sp, sp, #12
14 ; CHECK: sub sp, sp, #4
15 ; CHECK: add r0, sp, #4
16 ; CHECK: stmib sp, {r1, r2, r3}
18 %g1 = bitcast i8** %g to i8*
19 call void @llvm.va_start(i8* %g1)
21 ; CHECK: add [[REG:(r[0-9]+)|(lr)]], {{(r[0-9]+)|(lr)}}, #7
22 ; CHECK: bic [[REG]], [[REG]], #7
23 %0 = va_arg i8** %g, double
24 call void @llvm.va_end(i8* %g1)
30 ; CHECK: movw [[BASE:r[0-9]+]], :lower16:static_val
31 ; CHECK: movt [[BASE]], :upper16:static_val
32 ; ldm is not formed when the coalescer failed to coalesce everything.
33 ; CHECK: ldrd r2, [[TMP:r[0-9]+]], {{\[}}[[BASE]]{{\]}}
34 ; CHECK: movw r0, #555
37 call void (i32, ...) @test_byval_8_bytes_alignment(i32 555, %struct_t* byval @static_val)
41 declare void @f(double);
43 ; CHECK-LABEL: test_byval_8_bytes_alignment_fixed_arg:
45 ; CHECK-DAG: str r3, [sp, #12]
46 ; CHECK-DAG: str r2, [sp, #8]
48 define void @test_byval_8_bytes_alignment_fixed_arg(i32 %n1, %struct_t* byval %val) nounwind {
50 %a = getelementptr inbounds %struct_t, %struct_t* %val, i32 0, i32 0
51 %0 = load double, double* %a
52 call void (double) @f(double %0)
56 ; CHECK-LABEL: main_fixed_arg:
57 ; CHECK: movw [[BASE:r[0-9]+]], :lower16:static_val
58 ; CHECK: movt [[BASE]], :upper16:static_val
59 ; ldm is not formed when the coalescer failed to coalesce everything.
60 ; CHECK: ldrd r2, [[TMP:r[0-9]+]], {{\[}}[[BASE]]{{\]}}
61 ; CHECK: movw r0, #555
62 define i32 @main_fixed_arg() {
64 call void (i32, %struct_t*) @test_byval_8_bytes_alignment_fixed_arg(i32 555, %struct_t* byval @static_val)