llvm.org GIT mirror llvm / b2d73d1
DebugInfo: Introduce DebugLocList to encapsulate a list of DebugLocEntries and an MC Label to refer to them This removes the magic-number-esque code creating/retrieving the same label for a debug_loc entry from two places and removes the last small piece of reusable logic from emitDebugLoc so that there will be less duplication when refactoring it into two functions (one for debug_loc, the other for debug_loc.dwo). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205382 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 6 years ago
5 changed file(s) with 39 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
559559 ///
560560 void DIELocList::EmitValue(AsmPrinter *AP, dwarf::Form Form) const {
561561 DwarfDebug *DD = AP->getDwarfDebug();
562 MCSymbol *Label = AP->GetTempSymbol("debug_loc", Index);
562 MCSymbol *Label = DD->getDebugLocEntries()[Index].Label;
563563
564564 if (AP->MAI->doesDwarfUseRelocationsAcrossSections() && !DD->useSplitDwarf())
565565 AP->EmitSectionOffset(Label, DD->getDebugLocSym());
283283 // Hash the contents of a loclistptr class.
284284 void DIEHash::hashLocList(const DIELocList &LocList) {
285285 HashingByteStreamer Streamer(*this);
286 DwarfDebug &DD = *AP->getDwarfDebug();
286287 for (const auto &Entry :
287 AP->getDwarfDebug()->getDebugLocEntries()[LocList.getValue()])
288 AP->getDwarfDebug()->emitDebugLocEntry(Streamer, Entry);
288 DD.getDebugLocEntries()[LocList.getValue()].List)
289 DD.emitDebugLocEntry(Streamer, Entry);
289290 }
290291
291292 // Hash an individual attribute \param Attr based on the type of attribute and
0 //===--- lib/CodeGen/DebugLocList.h - DWARF debug_loc list ------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef CODEGEN_ASMPRINTER_DEBUGLOCLIST_H__
10 #define CODEGEN_ASMPRINTER_DEBUGLOCLIST_H__
11
12 #include "llvm/MC/MCSymbol.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "DebugLocEntry.h"
15
16 namespace llvm {
17 struct DebugLocList {
18 MCSymbol *Label;
19 SmallVector List;
20 };
21 }
22 #endif
12701270 // Handle multiple DBG_VALUE instructions describing one variable.
12711271 RegVar->setDotDebugLocOffset(DotDebugLocEntries.size());
12721272
1273 SmallVector DebugLoc;
1273 DotDebugLocEntries.resize(DotDebugLocEntries.size() + 1);
1274 DebugLocList &LocList = DotDebugLocEntries.back();
1275 LocList.Label =
1276 Asm->GetTempSymbol("debug_loc", DotDebugLocEntries.size() - 1);
1277 SmallVector &DebugLoc = LocList.List;
12741278 for (SmallVectorImpl::const_iterator
12751279 HI = History.begin(),
12761280 HE = History.end();
13121316 if (DebugLoc.empty() || !DebugLoc.back().Merge(Loc))
13131317 DebugLoc.push_back(std::move(Loc));
13141318 }
1315 DotDebugLocEntries.push_back(std::move(DebugLoc));
13161319 }
13171320
13181321 // Collect info for variables that were optimized out.
24052408 useSplitDwarf() ? Asm->getObjFileLowering().getDwarfLocDWOSection()
24062409 : Asm->getObjFileLowering().getDwarfLocSection());
24072410 unsigned char Size = Asm->getDataLayout().getPointerSize();
2408 unsigned index = 0;
24092411 for (const auto &DebugLoc : DotDebugLocEntries) {
2410 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_loc", index));
2411 for (const auto &Entry : DebugLoc) {
2412 Asm->OutStreamer.EmitLabel(DebugLoc.Label);
2413 for (const auto &Entry : DebugLoc.List) {
24122414 // Set up the range. This range is relative to the entry point of the
24132415 // compile unit. This is a hard coded 0 for low_pc when we're emitting
24142416 // ranges, or the DW_AT_low_pc on the compile unit otherwise.
24392441 Asm->OutStreamer.EmitIntValue(0, Size);
24402442 Asm->OutStreamer.EmitIntValue(0, Size);
24412443 }
2442 ++index;
24432444 }
24442445 }
24452446
1616 #include "AsmPrinterHandler.h"
1717 #include "DIE.h"
1818 #include "DebugLocEntry.h"
19 #include "DebugLocList.h"
1920 #include "llvm/ADT/DenseMap.h"
2021 #include "llvm/ADT/MapVector.h"
2122 #include "llvm/ADT/SmallPtrSet.h"
287288 // Collection of abstract variables.
288289 DenseMap AbstractVariables;
289290
290 // Collection of DebugLocEntry.
291 SmallVector, 4> DotDebugLocEntries;
291 // Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
292 // can refer to them in spite of insertions into this list.
293 SmallVector DotDebugLocEntries;
292294
293295 // Collection of subprogram DIEs that are marked (at the end of the module)
294296 // as DW_AT_inline.
685687 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
686688
687689 /// Returns the entries for the .debug_loc section.
688 const SmallVectorImpl<SmallVector> &
690 const SmallVectorImpl<DebugLocList> &
689691 getDebugLocEntries() const {
690692 return DotDebugLocEntries;
691693 }