brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · bd95dc4 Raw
138 lines · plain
1; RUN: llc -mtriple arm-unknown-linux-gnueabi -filetype asm -o - %s | FileCheck %s --check-prefix=CHECK-FP2; RUN: llc -mtriple arm-unknown-linux-gnueabi -filetype asm -o - %s -frame-pointer=all | FileCheck %s --check-prefix=CHECK-FP-ELIM3; RUN: llc -mtriple thumb-unknown-linux-gnueabi -filetype asm -o - %s | FileCheck %s --check-prefix=CHECK-THUMB-FP4; RUN: llc -mtriple thumb-unknown-linux-gnueabi -filetype asm -o - %s -frame-pointer=all | FileCheck %s --check-prefix=CHECK-THUMB-FP-ELIM5 6; Tests that the initial space allocated to the varargs on the stack is7; 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, retainedNodes: !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: sum63; CHECK-FP: .cfi_startproc64; CHECK-FP: sub    sp, sp, #1265; CHECK-FP: .cfi_def_cfa_offset 1266; CHECK-FP: push   {r4, lr}67; CHECK-FP: .cfi_def_cfa_offset 2068; CHECK-FP: .cfi_offset lr, -1669; CHECK-FP: .cfi_offset r4, -2070; CHECK-FP: sub    sp, sp, #471; CHECK-FP: .cfi_def_cfa_offset 2472 73; CHECK-FP-ELIM-LABEL: sum74; CHECK-FP-ELIM: .cfi_startproc75; CHECK-FP-ELIM: sub    sp, sp, #1276; CHECK-FP-ELIM: .cfi_def_cfa_offset 1277; CHECK-FP-ELIM: push   {r4, r10, r11, lr}78; CHECK-FP-ELIM: .cfi_def_cfa_offset 2879; CHECK-FP-ELIM: .cfi_offset lr, -1680; CHECK-FP-ELIM: .cfi_offset r11, -2081; CHECK-FP-ELIM: .cfi_offset r10, -2482; CHECK-FP-ELIM: .cfi_offset r4, -2883; CHECK-FP-ELIM: add    r11, sp, #884; CHECK-FP-ELIM: .cfi_def_cfa r11, 2085 86; CHECK-THUMB-FP-LABEL: sum87; CHECK-THUMB-FP: .cfi_startproc88; CHECK-THUMB-FP: sub    sp, #1289; CHECK-THUMB-FP: .cfi_def_cfa_offset 1290; CHECK-THUMB-FP: push   {r4, lr}91; CHECK-THUMB-FP: .cfi_def_cfa_offset 2092; CHECK-THUMB-FP: .cfi_offset lr, -1693; CHECK-THUMB-FP: .cfi_offset r4, -2094; CHECK-THUMB-FP: sub    sp, #495; CHECK-THUMB-FP: .cfi_def_cfa_offset 2496 97; CHECK-THUMB-FP-ELIM-LABEL: sum98; CHECK-THUMB-FP-ELIM: .cfi_startproc99; CHECK-THUMB-FP-ELIM: sub    sp, #12100; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 12101; CHECK-THUMB-FP-ELIM: push   {r4, r6, r7, lr}102; CHECK-THUMB-FP-ELIM: .cfi_def_cfa_offset 28103; CHECK-THUMB-FP-ELIM: .cfi_offset lr, -16104; CHECK-THUMB-FP-ELIM: .cfi_offset r7, -20105; CHECK-THUMB-FP-ELIM: .cfi_offset r6, -24106; CHECK-THUMB-FP-ELIM: .cfi_offset r4, -28107; CHECK-THUMB-FP-ELIM: add    r7, sp, #8108; CHECK-THUMB-FP-ELIM: .cfi_def_cfa r7, 20109 110define i32 @sum(i32 %count, ...) !dbg !4 {111entry:112  %vl = alloca ptr, align 4113  call void @llvm.va_start(ptr %vl)114  %cmp4 = icmp sgt i32 %count, 0115  br i1 %cmp4, label %for.body, label %for.end116 117for.body:                                         ; preds = %entry, %for.body118  %i.05 = phi i32 [ %inc, %for.body ], [ 0, %entry ]119  %ap.cur = load ptr, ptr %vl, align 4120  %ap.next = getelementptr i8, ptr %ap.cur, i32 4121  store ptr %ap.next, ptr %vl, align 4122  %0 = load i32, ptr %ap.cur, align 4123  %call = call i32 @foo(i32 %0) #1124  %inc = add nsw i32 %i.05, 1125  %exitcond = icmp eq i32 %inc, %count126  br i1 %exitcond, label %for.end, label %for.body127 128for.end:                                          ; preds = %for.body, %entry129  call void @llvm.va_end(ptr %vl)130  ret i32 undef131}132 133declare void @llvm.va_start(ptr) nounwind134 135declare i32 @foo(i32)136 137declare void @llvm.va_end(ptr) nounwind138