1 ; RUN: llc -mtriple=thumb-eabi %s -o /dev/null
2 ; RUN: llc -mtriple=thumb-linux %s -o - | FileCheck %s
3 ; RUN: llc -mtriple=thumb-darwin %s -o - | FileCheck %s
5 @str = internal constant [4 x i8] c"%d\0A\00" ; <ptr> [#uses=1]
7 define void @f(i32 %a, ...) {
9 ; Check that space is reserved above the pushed lr for variadic argument
10 ; registers to be stored in.
11 ; CHECK: sub sp, #[[IMM:[0-9]+]]
13 %va = alloca ptr, align 4 ; <ptr> [#uses=4]
14 call void @llvm.va_start( ptr %va )
17 bb: ; preds = %bb, %entry
18 %a_addr.0 = phi i32 [ %a, %entry ], [ %tmp5, %bb ] ; <i32> [#uses=2]
19 %tmp = load volatile ptr, ptr %va ; <ptr> [#uses=2]
20 %tmp2 = getelementptr i8, ptr %tmp, i32 4 ; <ptr> [#uses=1]
21 store volatile ptr %tmp2, ptr %va
22 %tmp5 = add i32 %a_addr.0, -1 ; <i32> [#uses=1]
23 %tmp.upgrd.2 = icmp eq i32 %a_addr.0, 1 ; <i1> [#uses=1]
24 br i1 %tmp.upgrd.2, label %bb7, label %bb
27 %tmp.upgrd.3 = load i32, ptr %tmp ; <i32> [#uses=1]
28 %tmp10 = call i32 (ptr, ...) @printf( ptr @str, i32 %tmp.upgrd.3 ) ; <i32> [#uses=0]
29 call void @llvm.va_end( ptr %va )
32 ; The return sequence should pop the lr to r0-3, recover the stack space used to
33 ; store variadic argument registers, then return via r3. Possibly there is a pop
34 ; before this, but only if the function happened to use callee-saved registers.
35 ; CHECK: pop {[[POP_REG:r[0-3]]]}
36 ; CHECK: add sp, #[[IMM]]
37 ; CHECK: bx [[POP_REG]]
40 declare void @llvm.va_start(ptr)
42 declare i32 @printf(ptr, ...)
44 declare void @llvm.va_end(ptr)