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