Skip to content

Commit aaa5a5e

Browse files
committed
DebugInfo: Include DW_AT_base_addr even in gmlt with no inline functions
Since the address pool doesn't get populated in this case (due to the lack of inlining, no child DIEs are added to the CU - so no addresses are needed for the DIEs themselves) until the range list is emitted - at the time the attributes are added to the CU, the address pool is empty. So check whether the address pool will be used for the range lists & add an addr_base if that's the case.
1 parent 553a727 commit aaa5a5e

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ void DwarfDebug::finalizeModuleInfo() {
11561156

11571157
// We don't keep track of which addresses are used in which CU so this
11581158
// is a bit pessimistic under LTO.
1159-
if (!AddrPool.isEmpty() &&
1159+
if ((!AddrPool.isEmpty() || TheCU.hasRangeLists()) &&
11601160
(getDwarfVersion() >= 5 || HasSplitUnit))
11611161
U.addAddrTableBase();
11621162

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
; RUN: %llc_dwarf --function-sections < %s -filetype=obj | llvm-dwarfdump -v -debug-info - | FileCheck %s
2+
3+
; CHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000010
4+
; CHECK: [0x0000000000000000, 0x0000000000000006) ".text._Z2f1v"
5+
; CHECK: [0x0000000000000000, 0x0000000000000006) ".text._Z2f2v")
6+
; CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
7+
8+
9+
; Function A
10+
define dso_local void @_Z2f1v() #0 !dbg !7 {
11+
ret void, !dbg !9
12+
}
13+
14+
; Function Attrs: noinline nounwind optnone uwtable
15+
define dso_local void @_Z2f2v() #0 !dbg !10 {
16+
ret void, !dbg !11
17+
}
18+
19+
attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
20+
21+
!llvm.dbg.cu = !{!0}
22+
!llvm.module.flags = !{!3, !4, !5}
23+
!llvm.ident = !{!6}
24+
25+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0 (trunk 371665) (llvm/trunk 371681)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, nameTableKind: None)
26+
!1 = !DIFile(filename: "gmlt-empty-base-address.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch", checksumkind: CSK_MD5, checksum: "74f7c574cd1ba04403967d02e757afeb")
27+
!2 = !{}
28+
!3 = !{i32 2, !"Dwarf Version", i32 5}
29+
!4 = !{i32 2, !"Debug Info Version", i32 3}
30+
!5 = !{i32 1, !"wchar_size", i32 4}
31+
!6 = !{!"clang version 10.0.0 (trunk 371665) (llvm/trunk 371681)"}
32+
!7 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
33+
!8 = !DISubroutineType(types: !2)
34+
!9 = !DILocation(line: 2, column: 1, scope: !7)
35+
!10 = distinct !DISubprogram(name: "f2", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
36+
!11 = !DILocation(line: 4, column: 1, scope: !10)

0 commit comments

Comments
 (0)