Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc -mtriple arm-unknown-linux-gnueabi -filetype asm -o - %s | FileCheck %s --check-prefix=CHECK-FP
      2 ; RUN: llc -mtriple arm-unknown-linux-gnueabi -filetype asm -o - %s -disable-fp-elim | FileCheck %s --check-prefix=CHECK-FP-ELIM
      3 ; RUN: llc -mtriple thumb-unknown-linux-gnueabi -filetype asm -o - %s | FileCheck %s --check-prefix=CHECK-THUMB-FP
      4 ; RUN: llc -mtriple thumb-unknown-linux-gnueabi -filetype asm -o - %s -disable-fp-elim | FileCheck %s --check-prefix=CHECK-THUMB-FP-ELIM
      5 
      6 ; Tests that the initial space allocated to the varargs on the stack is
      7 ; taken into account in the the .cfi_ directives.
      8 
      9 ; Generated from the C program:
     10 ; #include <stdarg.h>
     11 ;
     12 ; extern int foo(int);
     13 ;
     14 ; int sum(int count, ...) {
     15 ;  va_list vl;
     16 ;  va_start(vl, count);
     17 ;  int sum = 0;
     18 ;  for (int i = 0; i < count; i++) {
     19 ;   sum += foo(va_arg(vl, int));
     20 ;  }
     21 ;  va_end(vl);
     22 ; }
     23 
     24 !llvm.dbg.cu = !{!0}
     25 !llvm.module.flags = !{!9, !10}
     26 !llvm.ident = !{!11}
     27 
     28 !0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.5 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/tmp/var.c] [DW_LANG_C99]
     29 !1 = metadata !{metadata !"var.c", metadata !"/tmp"}
     30 !2 = metadata !{}
     31 !3 = metadata !{metadata !4}
     32 !4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"sum", metadata !"sum", metadata !"", i32 5, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32, ...)* @sum, null, null, metadata !2, i32 5} ; [ DW_TAG_subprogram ] [line 5] [def] [sum]
     33 !5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/tmp/var.c]
     34 !6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
     35 !7 = metadata !{metadata !8, metadata !8}
     36 !8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
     37 !9 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
     38 !10 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
     39 !11 = metadata !{metadata !"clang version 3.5 "}
     40 !12 = metadata !{i32 786689, metadata !4, metadata !"count", metadata !5, i32 16777221, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [count] [line 5]
     41 !13 = metadata !{i32 5, i32 0, metadata !4, null}
     42 !14 = metadata !{i32 786688, metadata !4, metadata !"vl", metadata !5, i32 6, metadata !15, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [vl] [line 6]
     43 !15 = metadata !{i32 786454, metadata !16, null, metadata !"va_list", i32 30, i64 0, i64 0, i64 0, i32 0, metadata !17} ; [ DW_TAG_typedef ] [va_list] [line 30, size 0, align 0, offset 0] [from __builtin_va_list]
     44 !16 = metadata !{metadata !"/linux-x86_64-high/gcc_4.7.2/dbg/llvm/bin/../lib/clang/3.5/include/stdarg.h", metadata !"/tmp"}
     45 !17 = metadata !{i32 786454, metadata !1, null, metadata !"__builtin_va_list", i32 6, i64 0, i64 0, i64 0, i32 0, metadata !18} ; [ DW_TAG_typedef ] [__builtin_va_list] [line 6, size 0, align 0, offset 0] [from __va_list]
     46 !18 = metadata !{i32 786451, metadata !1, null, metadata !"__va_list", i32 6, i64 32, i64 32, i32 0, i32 0, null, metadata !19, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [__va_list] [line 6, size 32, align 32, offset 0] [def] [from ]
     47 !19 = metadata !{metadata !20}
     48 !20 = metadata !{i32 786445, metadata !1, metadata !18, metadata !"__ap", i32 6, i64 32, i64 32, i64 0, i32 0, metadata !21} ; [ DW_TAG_member ] [__ap] [line 6, size 32, align 32, offset 0] [from ]
     49 !21 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 32, i64 32, i64 0, i32 0, null} ; [ DW_TAG_pointer_type ] [line 0, size 32, align 32, offset 0] [from ]
     50 !22 = metadata !{i32 6, i32 0, metadata !4, null}
     51 !23 = metadata !{i32 7, i32 0, metadata !4, null}
     52 !24 = metadata !{i32 786688, metadata !4, metadata !"sum", metadata !5, i32 8, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [sum] [line 8]
     53 !25 = metadata !{i32 8, i32 0, metadata !4, null} ; [ DW_TAG_imported_declaration ]
     54 !26 = metadata !{i32 786688, metadata !27, metadata !"i", metadata !5, i32 9, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [i] [line 9]
     55 !27 = metadata !{i32 786443, metadata !1, metadata !4, i32 9, i32 0, i32 0} ; [ DW_TAG_lexical_block ] [/tmp/var.c]
     56 !28 = metadata !{i32 9, i32 0, metadata !27, null}
     57 !29 = metadata !{i32 10, i32 0, metadata !30, null}
     58 !30 = metadata !{i32 786443, metadata !1, metadata !27, i32 9, i32 0, i32 1} ; [ DW_TAG_lexical_block ] [/tmp/var.c]
     59 !31 = metadata !{i32 11, i32 0, metadata !30, null}
     60 !32 = metadata !{i32 12, i32 0, metadata !4, null}
     61 !33 = metadata !{i32 13, i32 0, metadata !4, null}
     62 
     63 ; CHECK-FP-LABEL: sum
     64 ; CHECK-FP: .cfi_startproc
     65 ; CHECK-FP: sub    sp, sp, #16
     66 ; CHECK-FP: .cfi_def_cfa_offset 16
     67 ; CHECK-FP: push   {r4, lr}
     68 ; CHECK-FP: .cfi_def_cfa_offset 24
     69 ; CHECK-FP: .cfi_offset lr, -20
     70 ; CHECK-FP: .cfi_offset r4, -24
     71 ; CHECK-FP: sub    sp, sp, #8
     72 ; CHECK-FP: .cfi_def_cfa_offset 32
     73 
     74 ; CHECK-FP-ELIM-LABEL: sum
     75 ; CHECK-FP-ELIM: .cfi_startproc
     76 ; CHECK-FP-ELIM: sub    sp, sp, #16
     77 ; CHECK-FP-ELIM: .cfi_def_cfa_offset 16
     78 ; CHECK-FP-ELIM: push   {r4, r10, r11, lr}
     79 ; CHECK-FP-ELIM: .cfi_def_cfa_offset 32
     80 ; CHECK-FP-ELIM: .cfi_offset lr, -20
     81 ; CHECK-FP-ELIM: .cfi_offset r11, -24
     82 ; CHECK-FP-ELIM: .cfi_offset r10, -28
     83 ; CHECK-FP-ELIM: .cfi_offset r4, -32
     84 ; CHECK-FP-ELIM: add    r11, sp, #8
     85 ; CHECK-FP-ELIM: .cfi_def_cfa r11, 24
     86 
     87 ; CHECK-THUMB-FP-LABEL: sum
     88 ; CHECK-THUMB-FP: .cfi_startproc
     89 ; CHECK-THUMB-FP: sub    sp, #16
     90 ; CHECK-THUMB-FP: .cfi_def_cfa_offset 16
     91 ; CHECK-THUMB-FP: push   {r4, r5, r7, lr}
     92 ; CHECK-THUMB-FP: .cfi_def_cfa_offset 32
     93 ; CHECK-THUMB-FP: .cfi_offset lr, -20
     94 ; CHECK-THUMB-FP: .cfi_offset r7, -24
     95 ; CHECK-THUMB-FP: .cfi_offset r5, -28
     96 ; CHECK-THUMB-FP: .cfi_offset r4, -32
     97 ; CHECK-THUMB-FP: sub    sp, #8
     98 ; CHECK-THUMB-FP: .cfi_def_cfa_offset 40
     99 
    100 ; CHECK-THUMB-FP-ELIM-LABEL: sum
    101 ; CHECK-THUMB-FP-ELIM: .cfi_startproc
    102 ; CHECK-THUMB-FP-ELIM: sub    sp, #16
    103 ; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 16
    104 ; CHECK-THUMB-FP-ELIM: push   {r4, r5, r7, lr}
    105 ; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 32
    106 ; CHECK-THUMB-FP-ELIM: .cfi_offset lr, -20
    107 ; CHECK-THUMB-FP-ELIM: .cfi_offset r7, -24
    108 ; CHECK-THUMB-FP-ELIM: .cfi_offset r5, -28
    109 ; CHECK-THUMB-FP-ELIM: .cfi_offset r4, -32
    110 ; CHECK-THUMB-FP-ELIM: add    r7, sp, #8
    111 ; CHECK-THUMB-FP-ELIM: .cfi_def_cfa r7, 24
    112 
    113 define i32 @sum(i32 %count, ...) {
    114 entry:
    115   %vl = alloca i8*, align 4
    116   %vl1 = bitcast i8** %vl to i8*
    117   call void @llvm.va_start(i8* %vl1)
    118   %cmp4 = icmp sgt i32 %count, 0
    119   br i1 %cmp4, label %for.body, label %for.end
    120 
    121 for.body:                                         ; preds = %entry, %for.body
    122   %i.05 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
    123   %ap.cur = load i8** %vl, align 4
    124   %ap.next = getelementptr i8* %ap.cur, i32 4
    125   store i8* %ap.next, i8** %vl, align 4
    126   %0 = bitcast i8* %ap.cur to i32*
    127   %1 = load i32* %0, align 4
    128   %call = call i32 @foo(i32 %1) #1
    129   %inc = add nsw i32 %i.05, 1
    130   %exitcond = icmp eq i32 %inc, %count
    131   br i1 %exitcond, label %for.end, label %for.body
    132 
    133 for.end:                                          ; preds = %for.body, %entry
    134   call void @llvm.va_end(i8* %vl1)
    135   ret i32 undef
    136 }
    137 
    138 declare void @llvm.va_start(i8*) nounwind
    139 
    140 declare i32 @foo(i32)
    141 
    142 declare void @llvm.va_end(i8*) nounwind
    143