Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
      2 ; RUN: llvm-dwarfdump -v %t | FileCheck %s
      3 ; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
      4 
      5 ; RUN: llc -dwarf-version=5 -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
      6 ; RUN: llvm-dwarfdump -v %t | FileCheck --check-prefix=V5RNGLISTS %s
      7 
      8 ; CHECK: .debug_info contents:
      9 ; CHECK: DW_TAG_compile_unit
     10 ; CHECK-NEXT: DW_AT_stmt_list
     11 ; CHECK-NEXT: DW_AT_GNU_dwo_name
     12 ; CHECK-NEXT: DW_AT_comp_dir
     13 ; CHECK-NEXT: DW_AT_GNU_dwo_id
     14 ; CHECK-NEXT: DW_AT_GNU_addr_base [DW_FORM_sec_offset]                   (0x00000000)
     15 
     16 ; CHECK: .debug_info.dwo contents:
     17 ; CHECK: DW_AT_location [DW_FORM_sec_offset]   ([[A:0x[0-9a-z]*]]
     18 ; CHECK: DW_AT_location [DW_FORM_sec_offset]   ([[E:0x[0-9a-z]*]]
     19 ; CHECK: DW_AT_location [DW_FORM_sec_offset]   ([[B:0x[0-9a-z]*]]
     20 ; CHECK: DW_AT_location [DW_FORM_sec_offset]   ([[D:0x[0-9a-z]*]]
     21 ; CHECK: DW_AT_ranges [DW_FORM_sec_offset]   (0x00000000
     22 ; CHECK-NOT: .debug_loc contents:
     23 ; CHECK-NOT: Beginning address offset
     24 ; CHECK: .debug_loc.dwo contents:
     25 
     26 ; Don't assume these locations are entirely correct - feel free to update them
     27 ; if they've changed due to a bugfix, change in register allocation, etc.
     28 
     29 ; CHECK:      [[A]]:
     30 ; CHECK-NEXT:   Addr idx 2 (w/ length 169): DW_OP_consts +0, DW_OP_stack_value
     31 ; CHECK-NEXT:   Addr idx 3 (w/ length 25): DW_OP_reg0 RAX
     32 ; CHECK:      [[E]]:
     33 ; CHECK-NEXT:   Addr idx 4 (w/ length 19): DW_OP_reg0 RAX
     34 ; CHECK:      [[B]]:
     35 ; CHECK-NEXT:   Addr idx 5 (w/ length 17): DW_OP_reg0 RAX
     36 ; CHECK:      [[D]]:
     37 ; CHECK-NEXT:   Addr idx 6 (w/ length 17): DW_OP_reg0 RAX
     38 
     39 ; Make sure we don't produce any relocations in any .dwo section (though in particular, debug_info.dwo)
     40 ; HDR-NOT: .rela.{{.*}}.dwo
     41 
     42 ; Make sure we have enough stuff in the debug_addr to cover the address indexes
     43 ; (6 is the last index in debug_loc.dwo, making 7 entries of 8 bytes each, 7 * 8
     44 ; == 56 base 10 == 38 base 16)
     45 
     46 ; HDR: .debug_addr 00000038
     47 ; HDR-NOT: .rela.{{.*}}.dwo
     48 
     49 ; Check for the existence of a DWARF v5-style range list table in the .debug_rnglists
     50 ; section and that the compile unit has a DW_AT_rnglists_base attribute.
     51 ; The table should contain at least one rangelist with at least 2 individual ranges.
     52 
     53 ; V5RNGLISTS:      .debug_info contents:
     54 ; V5RNGLISTS:      DW_TAG_compile_unit
     55 ; V5RNGLISTS-NOT:  DW_TAG
     56 ; V5RNGLISTS:      DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x0000000c)
     57 ; V5RNGLISTS:      .debug_rnglists contents:
     58 ; V5RNGLISTS-NEXT: 0x00000000: range list header: length = 0x00000014, version = 0x0005,
     59 ; V5RNGLISTS-SAME: addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
     60 ; V5RNGLISTS-NEXT: ranges:
     61 ; V5RNGLISTS-NEXT: 0x0000000c: [DW_RLE_offset_pair]:
     62 ; V5RNGLISTS-NEXT: 0x0000000f: [DW_RLE_offset_pair]:
     63 ; V5RNGLISTS:      0x{{[0-9a-f]+}}: [DW_RLE_end_of_list]
     64 
     65 ; From the code:
     66 
     67 ; extern int c;
     68 ; static void foo (int p)
     69 ; {
     70 ;   int a, b; 
     71 ;   unsigned int d, e;
     72 
     73 ;   for (a = 0; a < 30; a++)
     74 ;     for (d = 0; d < 30; d++)
     75 ;       for (b = 0; b < 30; b++)
     76 ;         for (e = 0; e < 30; e++)
     77 ;           {
     78 ;             int *w = &c; 
     79 ;             *w &= p; 
     80 ;           }
     81 ; }
     82 
     83 ; void 
     84 ; bar ()
     85 ; {
     86 ;   foo (1);
     87 ; }
     88 
     89 ; compiled with:
     90 
     91 ; clang -g -S -gsplit-dwarf -O1 small.c
     92 
     93 @c = external global i32
     94 
     95 ; Function Attrs: nounwind uwtable
     96 define void @bar() #0 !dbg !4 {
     97 entry:
     98   tail call fastcc void @foo(), !dbg !27
     99   ret void, !dbg !28
    100 }
    101 
    102 ; Function Attrs: nounwind uwtable
    103 define internal fastcc void @foo() #0 !dbg !8 {
    104 entry:
    105   tail call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !DIExpression()), !dbg !30
    106   tail call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression()), !dbg !31
    107   %c.promoted9 = load i32, i32* @c, align 4, !dbg !32, !tbaa !33
    108   br label %for.cond1.preheader, !dbg !31
    109 
    110 for.cond1.preheader:                              ; preds = %for.inc16, %entry
    111   %and.lcssa.lcssa.lcssa10 = phi i32 [ %c.promoted9, %entry ], [ %and, %for.inc16 ]
    112   %a.08 = phi i32 [ 0, %entry ], [ %inc17, %for.inc16 ]
    113   br label %for.cond4.preheader, !dbg !37
    114 
    115 for.cond4.preheader:                              ; preds = %for.inc13, %for.cond1.preheader
    116   %and.lcssa.lcssa7 = phi i32 [ %and.lcssa.lcssa.lcssa10, %for.cond1.preheader ], [ %and, %for.inc13 ]
    117   %d.06 = phi i32 [ 0, %for.cond1.preheader ], [ %inc14, %for.inc13 ]
    118   br label %for.cond7.preheader, !dbg !38
    119 
    120 for.cond7.preheader:                              ; preds = %for.inc10, %for.cond4.preheader
    121   %and.lcssa5 = phi i32 [ %and.lcssa.lcssa7, %for.cond4.preheader ], [ %and, %for.inc10 ]
    122   %b.03 = phi i32 [ 0, %for.cond4.preheader ], [ %inc11, %for.inc10 ]
    123   br label %for.body9, !dbg !39
    124 
    125 for.body9:                                        ; preds = %for.body9, %for.cond7.preheader
    126   %and2 = phi i32 [ %and.lcssa5, %for.cond7.preheader ], [ %and, %for.body9 ], !dbg !40
    127   %e.01 = phi i32 [ 0, %for.cond7.preheader ], [ %inc, %for.body9 ]
    128   tail call void @llvm.dbg.value(metadata i32* @c, metadata !19, metadata !DIExpression()), !dbg !40
    129   %and = and i32 %and2, 1, !dbg !32
    130   %inc = add i32 %e.01, 1, !dbg !39
    131   tail call void @llvm.dbg.value(metadata i32 %inc, metadata !18, metadata !DIExpression()), !dbg !39
    132   %exitcond = icmp eq i32 %inc, 30, !dbg !39
    133   br i1 %exitcond, label %for.inc10, label %for.body9, !dbg !39
    134 
    135 for.inc10:                                        ; preds = %for.body9
    136   %inc11 = add nsw i32 %b.03, 1, !dbg !38
    137   tail call void @llvm.dbg.value(metadata i32 %inc11, metadata !15, metadata !DIExpression()), !dbg !38
    138   %exitcond11 = icmp eq i32 %inc11, 30, !dbg !38
    139   br i1 %exitcond11, label %for.inc13, label %for.cond7.preheader, !dbg !38
    140 
    141 for.inc13:                                        ; preds = %for.inc10
    142   %inc14 = add i32 %d.06, 1, !dbg !37
    143   tail call void @llvm.dbg.value(metadata i32 %inc14, metadata !16, metadata !DIExpression()), !dbg !37
    144   %exitcond12 = icmp eq i32 %inc14, 30, !dbg !37
    145   br i1 %exitcond12, label %for.inc16, label %for.cond4.preheader, !dbg !37
    146 
    147 for.inc16:                                        ; preds = %for.inc13
    148   %inc17 = add nsw i32 %a.08, 1, !dbg !31
    149   tail call void @llvm.dbg.value(metadata i32 %inc17, metadata !14, metadata !DIExpression()), !dbg !31
    150   %exitcond13 = icmp eq i32 %inc17, 30, !dbg !31
    151   br i1 %exitcond13, label %for.end18, label %for.cond1.preheader, !dbg !31
    152 
    153 for.end18:                                        ; preds = %for.inc16
    154   store i32 %and, i32* @c, align 4, !dbg !32, !tbaa !33
    155   ret void, !dbg !42
    156 }
    157 
    158 ; Function Attrs: nounwind readnone
    159 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
    160 
    161 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
    162 attributes #1 = { nounwind readnone }
    163 
    164 !llvm.dbg.cu = !{!0}
    165 !llvm.module.flags = !{!26, !43}
    166 
    167 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (trunk 191700) (llvm/trunk 191710)", isOptimized: true, splitDebugFilename: "small.dwo", emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
    168 !1 = !DIFile(filename: "small.c", directory: "/usr/local/google/home/echristo/tmp")
    169 !2 = !{}
    170 !4 = distinct !DISubprogram(name: "bar", line: 18, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !0, scopeLine: 19, file: !1, scope: !5, type: !6, retainedNodes: !2)
    171 !5 = !DIFile(filename: "small.c", directory: "/usr/local/google/home/echristo/tmp")
    172 !6 = !DISubroutineType(types: !7)
    173 !7 = !{null}
    174 !8 = distinct !DISubprogram(name: "foo", line: 2, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !9, retainedNodes: !12)
    175 !9 = !DISubroutineType(types: !10)
    176 !10 = !{null, !11}
    177 !11 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
    178 !12 = !{!13, !14, !15, !16, !18, !19}
    179 !13 = !DILocalVariable(name: "p", line: 2, arg: 1, scope: !8, file: !5, type: !11)
    180 !14 = !DILocalVariable(name: "a", line: 4, scope: !8, file: !5, type: !11)
    181 !15 = !DILocalVariable(name: "b", line: 4, scope: !8, file: !5, type: !11)
    182 !16 = !DILocalVariable(name: "d", line: 5, scope: !8, file: !5, type: !17)
    183 !17 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
    184 !18 = !DILocalVariable(name: "e", line: 5, scope: !8, file: !5, type: !17)
    185 !19 = !DILocalVariable(name: "w", line: 12, scope: !20, file: !5, type: !25)
    186 !20 = distinct !DILexicalBlock(line: 11, column: 0, file: !1, scope: !21)
    187 !21 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !22)
    188 !22 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !23)
    189 !23 = distinct !DILexicalBlock(line: 8, column: 0, file: !1, scope: !24)
    190 !24 = distinct !DILexicalBlock(line: 7, column: 0, file: !1, scope: !8)
    191 !25 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !11)
    192 !26 = !{i32 2, !"Dwarf Version", i32 4}
    193 !27 = !DILocation(line: 20, scope: !4)
    194 !28 = !DILocation(line: 21, scope: !4)
    195 !29 = !{i32 1}
    196 !30 = !DILocation(line: 2, scope: !8)
    197 !31 = !DILocation(line: 7, scope: !24)
    198 !32 = !DILocation(line: 13, scope: !20)
    199 !33 = !{!34, !34, i64 0}
    200 !34 = !{!"int", !35, i64 0}
    201 !35 = !{!"omnipotent char", !36, i64 0}
    202 !36 = !{!"Simple C/C++ TBAA"}
    203 !37 = !DILocation(line: 8, scope: !23)
    204 !38 = !DILocation(line: 9, scope: !22)
    205 !39 = !DILocation(line: 10, scope: !21)
    206 !40 = !DILocation(line: 12, scope: !20)
    207 !41 = !{i32* @c}
    208 !42 = !DILocation(line: 15, scope: !8)
    209 !43 = !{i32 1, !"Debug Info Version", i32 3}
    210 !44 = !{i32 0}
    211