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