llvm.org GIT mirror llvm / 5bfa4ba
DebugInfo: Move the reference to the CU from the location list entry to the list itself, since it is constant across an entire list. This simplifies construction and usage while making the data structure smaller. It was a holdover from the days when we didn't have a separate DebugLocList and all we had was a flat list of DebugLocEntries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214933 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 6 years ago
4 changed file(s) with 14 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
1414 #include "llvm/MC/MCSymbol.h"
1515
1616 namespace llvm {
17 class DwarfCompileUnit;
1817 class MDNode;
1918 /// \brief This struct describes location entries emitted in the .debug_loc
2019 /// section.
9089 /// A list of locations/constants belonging to this entry.
9190 SmallVector Values;
9291
93 /// The compile unit that this location entry is referenced by.
94 const DwarfCompileUnit *Unit;
95
9692 public:
97 DebugLocEntry() : Begin(nullptr), End(nullptr), Unit(nullptr) {}
98 DebugLocEntry(const MCSymbol *B, const MCSymbol *E,
99 Value Val, const DwarfCompileUnit *U)
100 : Begin(B), End(E), Unit(U) {
93 DebugLocEntry() : Begin(nullptr), End(nullptr) {}
94 DebugLocEntry(const MCSymbol *B, const MCSymbol *E, Value Val)
95 : Begin(B), End(E) {
10196 Values.push_back(std::move(Val));
10297 }
10398
129124
130125 const MCSymbol *getBeginSym() const { return Begin; }
131126 const MCSymbol *getEndSym() const { return End; }
132 const DwarfCompileUnit *getCU() const { return Unit; }
133127 const ArrayRef getValues() const { return Values; }
134128 void addValue(Value Val) {
135129 assert(DIVariable(Val.Variable).isVariablePiece() &&
99 #ifndef CODEGEN_ASMPRINTER_DEBUGLOCLIST_H__
1010 #define CODEGEN_ASMPRINTER_DEBUGLOCLIST_H__
1111
12 #include "llvm/MC/MCSymbol.h"
1312 #include "llvm/ADT/SmallVector.h"
1413 #include "DebugLocEntry.h"
1514
1615 namespace llvm {
16 class DwarfCompileUnit;
17 class MCSymbol;
1718 struct DebugLocList {
1819 MCSymbol *Label;
20 DwarfCompileUnit *CU;
1921 SmallVector List;
2022 };
2123 }
12281228 // [1-3] [x, (reg0, piece 0, 32), (reg1, piece 32, 32)]
12291229 // [3-4] [x, (reg1, piece 32, 32)]
12301230 // [4- ] [x, (mem, piece 0, 64)]
1231 void DwarfDebug::
1232 buildLocationList(SmallVectorImpl &DebugLoc,
1233 const DbgValueHistoryMap::InstrRanges &Ranges,
1234 DwarfCompileUnit *TheCU) {
1231 void
1232 DwarfDebug::buildLocationList(SmallVectorImpl &DebugLoc,
1233 const DbgValueHistoryMap::InstrRanges &Ranges) {
12351234 typedef std::pair Range;
12361235 SmallVector OpenRanges;
12371236
12701269 DEBUG(dbgs() << "DotDebugLoc: " << *Begin << "\n");
12711270
12721271 auto Value = getDebugLocValue(Begin);
1273 DebugLocEntry Loc(StartLabel, EndLabel, Value, TheCU);
1272 DebugLocEntry Loc(StartLabel, EndLabel, Value);
12741273 if (DebugLoc.empty() || !DebugLoc.back().Merge(Loc)) {
12751274 // Add all values from still valid non-overlapping pieces.
12761275 for (auto Range : OpenRanges)
13391338
13401339 DotDebugLocEntries.resize(DotDebugLocEntries.size() + 1);
13411340 DebugLocList &LocList = DotDebugLocEntries.back();
1341 LocList.CU = TheCU;
13421342 LocList.Label =
13431343 Asm->GetTempSymbol("debug_loc", DotDebugLocEntries.size() - 1);
13441344
13451345 // Build the location list for this variable.
1346 buildLocationList(LocList.List, Ranges, TheCU);
1346 buildLocationList(LocList.List, Ranges);
13471347 }
13481348
13491349 // Collect info for variables that were optimized out.
21972197 unsigned char Size = Asm->getDataLayout().getPointerSize();
21982198 for (const auto &DebugLoc : DotDebugLocEntries) {
21992199 Asm->OutStreamer.EmitLabel(DebugLoc.Label);
2200 const DwarfCompileUnit *CU = DebugLoc.CU;
22002201 for (const auto &Entry : DebugLoc.List) {
22012202 // Set up the range. This range is relative to the entry point of the
22022203 // compile unit. This is a hard coded 0 for low_pc when we're emitting
22032204 // ranges, or the DW_AT_low_pc on the compile unit otherwise.
2204 const DwarfCompileUnit *CU = Entry.getCU();
22052205 if (CU->getRanges().size() == 1) {
22062206 // Grab the begin symbol from the first range as our base.
22072207 const MCSymbol *Base = CU->getRanges()[0].getStart();
537537 /// \brief Build the location list for all DBG_VALUEs in the
538538 /// function that describe the same variable.
539539 void buildLocationList(SmallVectorImpl &DebugLoc,
540 const DbgValueHistoryMap::InstrRanges &Ranges,
541 DwarfCompileUnit *TheCU);
540 const DbgValueHistoryMap::InstrRanges &Ranges);
542541
543542 /// \brief Collect variable information from the side table maintained
544543 /// by MMI.