[llvm] r312751 - [DWARF] Line 0 should not have a discriminator.
Paul Robinson via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 7 15:15:44 PDT 2017
Author: probinson
Date: Thu Sep 7 15:15:44 2017
New Revision: 312751
URL: http://llvm.org/viewvc/llvm-project?rev=312751&view=rev
Log:
[DWARF] Line 0 should not have a discriminator.
It's meaningless and takes up extra space in the line table.
Differential Revision: https://reviews.llvm.org/D37364
Added:
llvm/trunk/test/CodeGen/X86/dbg-line-0-no-discriminator.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=312751&r1=312750&r2=312751&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Sep 7 15:15:44 2017
@@ -1362,8 +1362,8 @@ void DwarfDebug::recordSourceLine(unsign
if (auto *Scope = cast_or_null<DIScope>(S)) {
Fn = Scope->getFilename();
Dir = Scope->getDirectory();
- if (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope))
- if (getDwarfVersion() >= 4)
+ if (Line != 0 && getDwarfVersion() >= 4)
+ if (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope))
Discriminator = LBF->getDiscriminator();
unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID();
Added: llvm/trunk/test/CodeGen/X86/dbg-line-0-no-discriminator.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-line-0-no-discriminator.ll?rev=312751&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/dbg-line-0-no-discriminator.ll (added)
+++ llvm/trunk/test/CodeGen/X86/dbg-line-0-no-discriminator.ll Thu Sep 7 15:15:44 2017
@@ -0,0 +1,39 @@
+; RUN: llc -filetype=obj -use-unknown-locations=Enable -mtriple=x86_64-unknown-linux %s -o %t
+; RUN: llvm-dwarfdump -debug-dump=line %t | FileCheck %s
+
+define void @_Z3bazv() !dbg !6 {
+ call void @_Z3foov(), !dbg !9
+ call void @_Z3foov() ; no !dbg, so will be marked as line 0
+ ret void, !dbg !11
+}
+
+declare void @_Z3foov()
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+!llvm.ident = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 267219)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "test.cc", directory: ".")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{!"clang version 3.9.0 (trunk 267219)"}
+!6 = distinct !DISubprogram(name: "baz", linkageName: "_Z3bazv", scope: !1, file: !1, line: 3, type: !7, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!7 = !DISubroutineType(types: !8)
+!8 = !{null}
+!9 = !DILocation(line: 4, column: 3, scope: !10)
+!10 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 1)
+!11 = !DILocation(line: 6, column: 1, scope: !6)
+
+; Look at the lengths. We can't verify the line-number-program size
+; directly, but the difference in the two lengths should not change
+; unexpectedly.
+; CHECK: total_length: 0x00000043
+; CHECK: prologue_length: 0x0000001e
+;
+; Verify that we see a line entry with a discriminator, and the next entry
+; has line 0 and no discriminator.
+; line column file ISA discriminator
+; CHECK: 4 3 1 0 1
+; CHECK-NEXT: 0 3 1 0 0
More information about the llvm-commits
mailing list