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 .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 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 29!1 = !DIFile(filename: "var.c", directory: "/tmp") 30!2 = !{} 31!4 = distinct !DISubprogram(name: "sum", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !6, variables: !2) 32!5 = !DIFile(filename: "var.c", directory: "/tmp") 33!6 = !DISubroutineType(types: !7) 34!7 = !{!8, !8} 35!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 36!9 = !{i32 2, !"Dwarf Version", i32 4} 37!10 = !{i32 1, !"Debug Info Version", i32 3} 38!11 = !{!"clang version 3.5 "} 39!12 = !DILocalVariable(name: "count", line: 5, arg: 1, scope: !4, file: !5, type: !8) 40!13 = !DILocation(line: 5, scope: !4) 41!14 = !DILocalVariable(name: "vl", line: 6, scope: !4, file: !5, type: !15) 42!15 = !DIDerivedType(tag: DW_TAG_typedef, name: "va_list", line: 30, file: !16, baseType: !17) 43!16 = !DIFile(filename: "/linux-x86_64-high/gcc_4.7.2/dbg/llvm/bin/../lib/clang/3.5/include/stdarg.h", directory: "/tmp") 44!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "__builtin_va_list", line: 6, file: !1, baseType: !18) 45!18 = !DICompositeType(tag: DW_TAG_structure_type, name: "__va_list", line: 6, size: 32, align: 32, file: !1, elements: !19) 46!19 = !{!20} 47!20 = !DIDerivedType(tag: DW_TAG_member, name: "__ap", line: 6, size: 32, align: 32, file: !1, scope: !18, baseType: !21) 48!21 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 32, align: 32, baseType: null) 49!22 = !DILocation(line: 6, scope: !4) 50!23 = !DILocation(line: 7, scope: !4) 51!24 = !DILocalVariable(name: "sum", line: 8, scope: !4, file: !5, type: !8) 52!25 = !DILocation(line: 8, scope: !4) 53!26 = !DILocalVariable(name: "i", line: 9, scope: !27, file: !5, type: !8) 54!27 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !4) 55!28 = !DILocation(line: 9, scope: !27) 56!29 = !DILocation(line: 10, scope: !30) 57!30 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !27) 58!31 = !DILocation(line: 11, scope: !30) 59!32 = !DILocation(line: 12, scope: !4) 60!33 = !DILocation(line: 13, scope: !4) 61 62; CHECK-FP-LABEL: sum 63; CHECK-FP: .cfi_startproc 64; CHECK-FP: sub sp, sp, #12 65; CHECK-FP: .cfi_def_cfa_offset 12 66; CHECK-FP: push {r4, lr} 67; CHECK-FP: .cfi_def_cfa_offset 20 68; CHECK-FP: .cfi_offset lr, -16 69; CHECK-FP: .cfi_offset r4, -20 70; CHECK-FP: sub sp, sp, #4 71; CHECK-FP: .cfi_def_cfa_offset 24 72 73; CHECK-FP-ELIM-LABEL: sum 74; CHECK-FP-ELIM: .cfi_startproc 75; CHECK-FP-ELIM: sub sp, sp, #12 76; CHECK-FP-ELIM: .cfi_def_cfa_offset 12 77; CHECK-FP-ELIM: push {r4, r10, r11, lr} 78; CHECK-FP-ELIM: .cfi_def_cfa_offset 28 79; CHECK-FP-ELIM: .cfi_offset lr, -16 80; CHECK-FP-ELIM: .cfi_offset r11, -20 81; CHECK-FP-ELIM: .cfi_offset r10, -24 82; CHECK-FP-ELIM: .cfi_offset r4, -28 83; CHECK-FP-ELIM: add r11, sp, #8 84; CHECK-FP-ELIM: .cfi_def_cfa r11, 20 85 86; CHECK-THUMB-FP-LABEL: sum 87; CHECK-THUMB-FP: .cfi_startproc 88; CHECK-THUMB-FP: sub sp, #12 89; CHECK-THUMB-FP: .cfi_def_cfa_offset 12 90; CHECK-THUMB-FP: push {r4, lr} 91; CHECK-THUMB-FP: .cfi_def_cfa_offset 20 92; CHECK-THUMB-FP: .cfi_offset lr, -16 93; CHECK-THUMB-FP: .cfi_offset r4, -20 94; CHECK-THUMB-FP: sub sp, #4 95; CHECK-THUMB-FP: .cfi_def_cfa_offset 24 96 97; CHECK-THUMB-FP-ELIM-LABEL: sum 98; CHECK-THUMB-FP-ELIM: .cfi_startproc 99; CHECK-THUMB-FP-ELIM: sub sp, #12 100; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 12 101; CHECK-THUMB-FP-ELIM: push {r4, r6, r7, lr} 102; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 28 103; CHECK-THUMB-FP-ELIM: .cfi_offset lr, -16 104; CHECK-THUMB-FP-ELIM: .cfi_offset r7, -20 105; CHECK-THUMB-FP-ELIM: .cfi_offset r6, -24 106; CHECK-THUMB-FP-ELIM: .cfi_offset r4, -28 107; CHECK-THUMB-FP-ELIM: add r7, sp, #8 108; CHECK-THUMB-FP-ELIM: .cfi_def_cfa r7, 20 109 110define i32 @sum(i32 %count, ...) !dbg !4 { 111entry: 112 %vl = alloca i8*, align 4 113 %vl1 = bitcast i8** %vl to i8* 114 call void @llvm.va_start(i8* %vl1) 115 %cmp4 = icmp sgt i32 %count, 0 116 br i1 %cmp4, label %for.body, label %for.end 117 118for.body: ; preds = %entry, %for.body 119 %i.05 = phi i32 [ %inc, %for.body ], [ 0, %entry ] 120 %ap.cur = load i8*, i8** %vl, align 4 121 %ap.next = getelementptr i8, i8* %ap.cur, i32 4 122 store i8* %ap.next, i8** %vl, align 4 123 %0 = bitcast i8* %ap.cur to i32* 124 %1 = load i32, i32* %0, align 4 125 %call = call i32 @foo(i32 %1) #1 126 %inc = add nsw i32 %i.05, 1 127 %exitcond = icmp eq i32 %inc, %count 128 br i1 %exitcond, label %for.end, label %for.body 129 130for.end: ; preds = %for.body, %entry 131 call void @llvm.va_end(i8* %vl1) 132 ret i32 undef 133} 134 135declare void @llvm.va_start(i8*) nounwind 136 137declare i32 @foo(i32) 138 139declare void @llvm.va_end(i8*) nounwind 140