Home | History | Annotate | Download | only in Thumb
      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
      4 
      5 @str = internal constant [4 x i8] c"%d\0A\00"           ; <[4 x i8]*> [#uses=1]
      6 
      7 define void @f(i32 %a, ...) {
      8 entry:
      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]+]]
     12 ; CHECK: push
     13         %va = alloca i8*, align 4               ; <i8**> [#uses=4]
     14         %va.upgrd.1 = bitcast i8** %va to i8*           ; <i8*> [#uses=1]
     15         call void @llvm.va_start( i8* %va.upgrd.1 )
     16         br label %bb
     17 
     18 bb:             ; preds = %bb, %entry
     19         %a_addr.0 = phi i32 [ %a, %entry ], [ %tmp5, %bb ]              ; <i32> [#uses=2]
     20         %tmp = load volatile i8*, i8** %va           ; <i8*> [#uses=2]
     21         %tmp2 = getelementptr i8, i8* %tmp, i32 4           ; <i8*> [#uses=1]
     22         store volatile i8* %tmp2, i8** %va
     23         %tmp5 = add i32 %a_addr.0, -1           ; <i32> [#uses=1]
     24         %tmp.upgrd.2 = icmp eq i32 %a_addr.0, 1         ; <i1> [#uses=1]
     25         br i1 %tmp.upgrd.2, label %bb7, label %bb
     26 
     27 bb7:            ; preds = %bb
     28         %tmp3 = bitcast i8* %tmp to i32*                ; <i32*> [#uses=1]
     29         %tmp.upgrd.3 = load i32, i32* %tmp3          ; <i32> [#uses=1]
     30         %tmp10 = call i32 (i8*, ...) @printf( i8* getelementptr ([4 x i8], [4 x i8]* @str, i32 0, i64 0), i32 %tmp.upgrd.3 )                ; <i32> [#uses=0]
     31         %va.upgrd.4 = bitcast i8** %va to i8*           ; <i8*> [#uses=1]
     32         call void @llvm.va_end( i8* %va.upgrd.4 )
     33         ret void
     34 
     35 ; The return sequence should pop the lr to r0-3, recover the stack space used to
     36 ; store variadic argument registers, then return via r3. Possibly there is a pop
     37 ; before this, but only if the function happened to use callee-saved registers.
     38 ; CHECK: pop {[[POP_REG:r[0-3]]]}
     39 ; CHECK: add sp, #[[IMM]]
     40 ; CHECK: bx [[POP_REG]]
     41 }
     42 
     43 declare void @llvm.va_start(i8*)
     44 
     45 declare i32 @printf(i8*, ...)
     46 
     47 declare void @llvm.va_end(i8*)
     48