From 8fec3da00ce186f06dbbf08ff4f38cd90f079308 Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Wed, 14 Dec 2016 00:27:35 +0000 Subject: [PATCH] [DWARF] Preserve column number when emitting 'line 0' record Follow-up to r289256, address a FIXME to avoid resetting the column number. This reduced .debug_line by 2.6% in a RelWithDebInfo self-build of clang. llvm-svn: 289620 --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 13 +++++++++---- llvm/test/CodeGen/X86/unknown-location.ll | 5 ++--- llvm/test/DebugInfo/X86/dwarf-no-source-loc.ll | 4 ++-- llvm/test/DebugInfo/X86/tail-merge.ll | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 4ebc54555cc8..3b67aa024f0f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1048,11 +1048,16 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) { // location from the physically previous (maybe unrelated) block. if (UnknownLocations == Enable || PrevLabel || (PrevInstBB && PrevInstBB != MI->getParent())) { - // Preserve the file number, if we can, to save space in the line table. + // Preserve the file and column numbers, if we can, to save space in + // the encoded line table. // Do not update PrevInstLoc, it remembers the last non-0 line. - // FIXME: Also preserve the column number, to save more space? - const MDNode *Scope = PrevInstLoc ? PrevInstLoc.getScope() : nullptr; - recordSourceLine(0, 0, Scope, 0); + const MDNode *Scope = nullptr; + unsigned Column = 0; + if (PrevInstLoc) { + Scope = PrevInstLoc.getScope(); + Column = PrevInstLoc.getCol(); + } + recordSourceLine(/*Line=*/0, Column, Scope, /*Flags=*/0); } return; } diff --git a/llvm/test/CodeGen/X86/unknown-location.ll b/llvm/test/CodeGen/X86/unknown-location.ll index b4c44fc3e46e..3b90cf04b697 100644 --- a/llvm/test/CodeGen/X86/unknown-location.ll +++ b/llvm/test/CodeGen/X86/unknown-location.ll @@ -1,11 +1,10 @@ ; RUN: llc < %s -asm-verbose=false -mtriple=x86_64-apple-darwin10 -use-unknown-locations=Enable | FileCheck %s ; The divide instruction does not have a debug location. CodeGen should -; represent this in the debug information. This is done by setting line -; and column to 0 +; represent this in the debug information. This is done by setting line to 0. ; CHECK: leal -; CHECK-NEXT: .loc 1 0 0 +; CHECK-NEXT: .loc 1 0 3 ; CHECK: cltd ; CHECK-NEXT: idivl ; CHECK-NEXT: .loc 1 4 3 diff --git a/llvm/test/DebugInfo/X86/dwarf-no-source-loc.ll b/llvm/test/DebugInfo/X86/dwarf-no-source-loc.ll index 1230e97d8037..c94f494e3e0c 100644 --- a/llvm/test/DebugInfo/X86/dwarf-no-source-loc.ll +++ b/llvm/test/DebugInfo/X86/dwarf-no-source-loc.ll @@ -42,11 +42,11 @@ if.end: ; preds = %if.then, %entry ; CHECK: .loc 1 7 7 ; CHECK-NOT: .loc -; CHECK: .loc 1 0 0 is_stmt 0 +; CHECK: .loc 1 0 7 is_stmt 0 ; CHECK-NOT: .loc ; CHECK: .loc 2 20 5 is_stmt 1 ; CHECK: .LBB0_2: -; CHECK-NEXT: .loc 2 0 0 is_stmt 0 +; CHECK-NEXT: .loc 2 0 5 is_stmt 0 ; CHECK-NOT: .loc ; CHECK: .loc 1 10 3 is_stmt 1 ; diff --git a/llvm/test/DebugInfo/X86/tail-merge.ll b/llvm/test/DebugInfo/X86/tail-merge.ll index cbdcf1ac29c8..e0f860463052 100644 --- a/llvm/test/DebugInfo/X86/tail-merge.ll +++ b/llvm/test/DebugInfo/X86/tail-merge.ll @@ -27,7 +27,7 @@ ; CHECK: .loc 1 8 10 ; CHECK: callq bar ; CHECK: [[TAIL]]: -; CHECK: .loc 1 0 0 +; CHECK: .loc 1 0 ; CHECK: addl [[REG]], %eax ; CHECK: .loc 1 9 3