From d09fbfaf7096c492a0ce0c4b8658500b3b175c23 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 26 May 2010 23:55:23 +0000 Subject: Simplify. Eliminate unneeded debug_loc entry. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104785 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 18 +++++++++--------- test/CodeGen/X86/2010-05-26-DotDebugLoc.ll | 2 +- test/DebugInfo/2010-05-25-DotDebugLoc.ll | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index acc168e..890507c 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2210,9 +2210,10 @@ void DwarfDebug::collectVariableInfo(const MachineFunction *MF) { } // handle multiple DBG_VALUE instructions describing one variable. - RegVar->setDotDebugLocOffset(DotDebugLocEntries.size()); if (DotDebugLocEntries.empty()) - DotDebugLocEntries.push_back(DotDebugLocEntry()); + RegVar->setDotDebugLocOffset(0); + else + RegVar->setDotDebugLocOffset(DotDebugLocEntries.size()); const MachineInstr *Begin = NULL; const MachineInstr *End = NULL; for (SmallVector::iterator @@ -3481,23 +3482,22 @@ void DwarfDebug::emitDebugStr() { /// emitDebugLoc - Emit visible names into a debug loc section. /// void DwarfDebug::emitDebugLoc() { + if (DotDebugLocEntries.empty()) + return; + // Start the dwarf loc section. Asm->OutStreamer.SwitchSection( Asm->getObjFileLowering().getDwarfLocSection()); unsigned char Size = Asm->getTargetData().getPointerSize(); - unsigned index = 0; - bool needMarker = true; + Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_loc", 0)); + unsigned index = 1; for (SmallVector::iterator I = DotDebugLocEntries.begin(), E = DotDebugLocEntries.end(); I != E; ++I, ++index) { DotDebugLocEntry Entry = *I; - if (needMarker) { - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_loc", index)); - needMarker = false; - } if (Entry.isEmpty()) { Asm->OutStreamer.EmitIntValue(0, Size, /*addrspace*/0); Asm->OutStreamer.EmitIntValue(0, Size, /*addrspace*/0); - needMarker = true; + Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_loc", index)); } else { Asm->OutStreamer.EmitSymbolValue(Entry.Begin, Size, 0); Asm->OutStreamer.EmitSymbolValue(Entry.End, Size, 0); diff --git a/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll b/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll index 1b24614..13f72a9 100644 --- a/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll +++ b/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll @@ -55,7 +55,7 @@ declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone !29 = metadata !{i32 524299, metadata !9, i32 17, i32 0} ; [ DW_TAG_lexical_block ] !30 = metadata !{i32 19, i32 0, metadata !29, null} -; CHECK: Ldebug_loc1 +; CHECK: Ldebug_loc0: ; CHECK-NEXT: .quad Lfunc_begin0 ; CHECK-NEXT: .quad Ltmp3 ; CHECK-NEXT: .short 1 diff --git a/test/DebugInfo/2010-05-25-DotDebugLoc.ll b/test/DebugInfo/2010-05-25-DotDebugLoc.ll index e6a7a6c..4c477ee 100644 --- a/test/DebugInfo/2010-05-25-DotDebugLoc.ll +++ b/test/DebugInfo/2010-05-25-DotDebugLoc.ll @@ -1,5 +1,5 @@ -; RUN: llc -O2 < %s | grep debug_loc13 -; Test to check .debug_loc support. This test case emits 14 debug_loc entries. +; RUN: llc -O2 < %s | grep debug_loc12 +; Test to check .debug_loc support. This test case emits 13 debug_loc entries. %0 = type { double } -- cgit v1.1