[llvm] aaa5a5e - DebugInfo: Include DW_AT_base_addr even in gmlt with no inline functions

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 17:14:55 PST 2019


Author: David Blaikie
Date: 2019-12-18T17:14:28-08:00
New Revision: aaa5a5e7ff1aee632aae75311e7c044f710dd0a0

URL: https://github.com/llvm/llvm-project/commit/aaa5a5e7ff1aee632aae75311e7c044f710dd0a0
DIFF: https://github.com/llvm/llvm-project/commit/aaa5a5e7ff1aee632aae75311e7c044f710dd0a0.diff

LOG: 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.

Added: 
    llvm/test/DebugInfo/X86/gmlt-empty-base-address.ll

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 6d62d4b3e693..0a0322f235ec 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1156,7 +1156,7 @@ void DwarfDebug::finalizeModuleInfo() {
 
     // We don't keep track of which addresses are used in which CU so this
     // is a bit pessimistic under LTO.
-    if (!AddrPool.isEmpty() &&
+    if ((!AddrPool.isEmpty() || TheCU.hasRangeLists()) &&
         (getDwarfVersion() >= 5 || HasSplitUnit))
       U.addAddrTableBase();
 

diff  --git a/llvm/test/DebugInfo/X86/gmlt-empty-base-address.ll b/llvm/test/DebugInfo/X86/gmlt-empty-base-address.ll
new file mode 100644
index 000000000000..2c2330ced699
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/gmlt-empty-base-address.ll
@@ -0,0 +1,36 @@
+; RUN: %llc_dwarf --function-sections < %s -filetype=obj | llvm-dwarfdump -v -debug-info - | FileCheck %s
+
+; CHECK: DW_AT_ranges [DW_FORM_rnglistx]   (indexed (0x0) rangelist = 0x00000010
+; CHECK:                    [0x0000000000000000, 0x0000000000000006) ".text._Z2f1v"
+; CHECK:                    [0x0000000000000000, 0x0000000000000006) ".text._Z2f2v")
+; CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
+
+
+; Function A
+define dso_local void @_Z2f1v() #0 !dbg !7 {
+  ret void, !dbg !9
+}
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local void @_Z2f2v() #0 !dbg !10 {
+  ret void, !dbg !11
+}
+
+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" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!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)
+!1 = !DIFile(filename: "gmlt-empty-base-address.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch", checksumkind: CSK_MD5, checksum: "74f7c574cd1ba04403967d02e757afeb")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 5}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 10.0.0 (trunk 371665) (llvm/trunk 371681)"}
+!7 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!8 = !DISubroutineType(types: !2)
+!9 = !DILocation(line: 2, column: 1, scope: !7)
+!10 = distinct !DISubprogram(name: "f2", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!11 = !DILocation(line: 4, column: 1, scope: !10)


        


More information about the llvm-commits mailing list