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 7declare void @llvm.va_start(i8*) nounwind 8declare void @llvm.va_end(i8*) nounwind 9 10; CHECK-LABEL: test_byval_8_bytes_alignment: 11define void @test_byval_8_bytes_alignment(i32 %i, ...) { 12entry: 13; CHECK: sub sp, sp, #12 14; CHECK: sub sp, sp, #4 15; CHECK: stmib sp, {r1, r2, r3} 16 %g = alloca i8* 17 %g1 = bitcast i8** %g to i8* 18 call void @llvm.va_start(i8* %g1) 19 20; CHECK: add [[REG:(r[0-9]+)|(lr)]], {{(r[0-9]+)|(lr)}}, #7 21; CHECK: bfc [[REG]], #0, #3 22 %0 = va_arg i8** %g, double 23 call void @llvm.va_end(i8* %g1) 24 25 ret void 26} 27 28; CHECK-LABEL: main: 29; CHECK: movw [[BASE:r[0-9]+]], :lower16:static_val 30; CHECK: movt [[BASE]], :upper16:static_val 31; ldm is not formed when the coalescer failed to coalesce everything. 32; CHECK: ldrd r2, [[TMP:r[0-9]+]], {{\[}}[[BASE]]{{\]}} 33; CHECK: movw r0, #555 34define i32 @main() { 35entry: 36 call void (i32, ...) @test_byval_8_bytes_alignment(i32 555, %struct_t* byval @static_val) 37 ret i32 0 38} 39 40declare void @f(double); 41 42; CHECK-LABEL: test_byval_8_bytes_alignment_fixed_arg: 43; CHECK-NOT: str r1 44; CHECK: str r3, [sp, #12] 45; CHECK: str r2, [sp, #8] 46; CHECK-NOT: str r1 47define void @test_byval_8_bytes_alignment_fixed_arg(i32 %n1, %struct_t* byval %val) nounwind { 48entry: 49 %a = getelementptr inbounds %struct_t, %struct_t* %val, i32 0, i32 0 50 %0 = load double, double* %a 51 call void (double) @f(double %0) 52 ret void 53} 54 55; CHECK-LABEL: main_fixed_arg: 56; CHECK: movw [[BASE:r[0-9]+]], :lower16:static_val 57; CHECK: movt [[BASE]], :upper16:static_val 58; ldm is not formed when the coalescer failed to coalesce everything. 59; CHECK: ldrd r2, [[TMP:r[0-9]+]], {{\[}}[[BASE]]{{\]}} 60; CHECK: movw r0, #555 61define i32 @main_fixed_arg() { 62entry: 63 call void (i32, %struct_t*) @test_byval_8_bytes_alignment_fixed_arg(i32 555, %struct_t* byval @static_val) 64 ret i32 0 65} 66