blob: 4879d73894d6abdd480f9ce6e4faedd4395ebad6 [file] [log] [blame]
Mark Seabornbe266aa2014-02-16 18:59:48 +00001; RUN: llc < %s -mtriple=arm-nacl-gnueabi | FileCheck %s
2
3declare void @llvm.va_start(i8*)
4declare void @external_func(i8*)
5
6@va_list = external global i8*
7
8; On ARM, varargs arguments are passed in r0-r3 with the rest on the
9; stack. A varargs function must therefore spill rN-r3 just below the
10; function's initial stack pointer.
11;
12; This test checks for a bug in which a gap was left between the spill
13; area and varargs arguments on the stack when using 16 byte stack
14; alignment.
15
16define void @varargs_func(i32 %arg1, ...) {
17 call void @llvm.va_start(i8* bitcast (i8** @va_list to i8*))
18 call void @external_func(i8* bitcast (i8** @va_list to i8*))
19 ret void
20}
21; CHECK-LABEL: varargs_func:
22; Reserve space for the varargs save area. This currently reserves
23; more than enough (16 bytes rather than the 12 bytes needed).
Tim Northover8cda34f2015-03-11 18:54:22 +000024; CHECK: sub sp, sp, #12
Tim Northoverdc0d9e42014-11-05 00:27:20 +000025; CHECK: push {r11, lr}
Mark Seabornbe266aa2014-02-16 18:59:48 +000026; Align the stack pointer to a multiple of 16.
Tim Northover8cda34f2015-03-11 18:54:22 +000027; CHECK: sub sp, sp, #12
Mark Seabornbe266aa2014-02-16 18:59:48 +000028; Calculate the address of the varargs save area and save varargs
29; arguments into it.
30; CHECK-NEXT: add r0, sp, #20
31; CHECK-NEXT: stm r0, {r1, r2, r3}