[llvm] r214933 - DebugInfo: Move the reference to the CU from the location list entry to the list itself, since it is constant across an entire list.

David Blaikie dblaikie at gmail.com
Tue Aug 5 16:14:16 PDT 2014


Author: dblaikie
Date: Tue Aug  5 18:14:16 2014
New Revision: 214933

URL: http://llvm.org/viewvc/llvm-project?rev=214933&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocList.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h?rev=214933&r1=214932&r2=214933&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h Tue Aug  5 18:14:16 2014
@@ -15,7 +15,6 @@
 #include "llvm/MC/MCSymbol.h"
 
 namespace llvm {
-class DwarfCompileUnit;
 class MDNode;
 /// \brief This struct describes location entries emitted in the .debug_loc
 /// section.
@@ -91,14 +90,10 @@ private:
   /// A list of locations/constants belonging to this entry.
   SmallVector<Value, 1> Values;
 
-  /// The compile unit that this location entry is referenced by.
-  const DwarfCompileUnit *Unit;
-
 public:
-  DebugLocEntry() : Begin(nullptr), End(nullptr), Unit(nullptr) {}
-  DebugLocEntry(const MCSymbol *B, const MCSymbol *E,
-                Value Val, const DwarfCompileUnit *U)
-      : Begin(B), End(E), Unit(U) {
+  DebugLocEntry() : Begin(nullptr), End(nullptr) {}
+  DebugLocEntry(const MCSymbol *B, const MCSymbol *E, Value Val)
+      : Begin(B), End(E) {
     Values.push_back(std::move(Val));
   }
 
@@ -130,7 +125,6 @@ public:
 
   const MCSymbol *getBeginSym() const { return Begin; }
   const MCSymbol *getEndSym() const { return End; }
-  const DwarfCompileUnit *getCU() const { return Unit; }
   const ArrayRef<Value> getValues() const { return Values; }
   void addValue(Value Val) {
     assert(DIVariable(Val.Variable).isVariablePiece() &&

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocList.h?rev=214933&r1=214932&r2=214933&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocList.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocList.h Tue Aug  5 18:14:16 2014
@@ -10,13 +10,15 @@
 #ifndef CODEGEN_ASMPRINTER_DEBUGLOCLIST_H__
 #define CODEGEN_ASMPRINTER_DEBUGLOCLIST_H__
 
-#include "llvm/MC/MCSymbol.h"
 #include "llvm/ADT/SmallVector.h"
 #include "DebugLocEntry.h"
 
 namespace llvm {
+class DwarfCompileUnit;
+class MCSymbol;
 struct DebugLocList {
   MCSymbol *Label;
+  DwarfCompileUnit *CU;
   SmallVector<DebugLocEntry, 4> List;
 };
 }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=214933&r1=214932&r2=214933&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Aug  5 18:14:16 2014
@@ -1229,10 +1229,9 @@ static bool piecesOverlap(DIVariable P1,
 // [1-3]    [x, (reg0, piece  0, 32), (reg1, piece 32, 32)]
 // [3-4]    [x, (reg1, piece 32, 32)]
 // [4- ]    [x, (mem,  piece  0, 64)]
-void DwarfDebug::
-buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
-                  const DbgValueHistoryMap::InstrRanges &Ranges,
-                  DwarfCompileUnit *TheCU) {
+void
+DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
+                              const DbgValueHistoryMap::InstrRanges &Ranges) {
   typedef std::pair<DIVariable, DebugLocEntry::Value> Range;
   SmallVector<Range, 4> OpenRanges;
 
@@ -1271,7 +1270,7 @@ buildLocationList(SmallVectorImpl<DebugL
     DEBUG(dbgs() << "DotDebugLoc: " << *Begin << "\n");
 
     auto Value = getDebugLocValue(Begin);
-    DebugLocEntry Loc(StartLabel, EndLabel, Value, TheCU);
+    DebugLocEntry Loc(StartLabel, EndLabel, Value);
     if (DebugLoc.empty() || !DebugLoc.back().Merge(Loc)) {
       // Add all values from still valid non-overlapping pieces.
       for (auto Range : OpenRanges)
@@ -1340,11 +1339,12 @@ DwarfDebug::collectVariableInfo(SmallPtr
 
     DotDebugLocEntries.resize(DotDebugLocEntries.size() + 1);
     DebugLocList &LocList = DotDebugLocEntries.back();
+    LocList.CU = TheCU;
     LocList.Label =
         Asm->GetTempSymbol("debug_loc", DotDebugLocEntries.size() - 1);
 
     // Build the location list for this variable.
-    buildLocationList(LocList.List, Ranges, TheCU);
+    buildLocationList(LocList.List, Ranges);
   }
 
   // Collect info for variables that were optimized out.
@@ -2198,11 +2198,11 @@ void DwarfDebug::emitDebugLoc() {
   unsigned char Size = Asm->getDataLayout().getPointerSize();
   for (const auto &DebugLoc : DotDebugLocEntries) {
     Asm->OutStreamer.EmitLabel(DebugLoc.Label);
+    const DwarfCompileUnit *CU = DebugLoc.CU;
     for (const auto &Entry : DebugLoc.List) {
       // Set up the range. This range is relative to the entry point of the
       // compile unit. This is a hard coded 0 for low_pc when we're emitting
       // ranges, or the DW_AT_low_pc on the compile unit otherwise.
-      const DwarfCompileUnit *CU = Entry.getCU();
       if (CU->getRanges().size() == 1) {
         // Grab the begin symbol from the first range as our base.
         const MCSymbol *Base = CU->getRanges()[0].getStart();

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=214933&r1=214932&r2=214933&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Aug  5 18:14:16 2014
@@ -538,8 +538,7 @@ class DwarfDebug : public AsmPrinterHand
   /// \brief Build the location list for all DBG_VALUEs in the
   /// function that describe the same variable.
   void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
-                         const DbgValueHistoryMap::InstrRanges &Ranges,
-                         DwarfCompileUnit *TheCU);
+                         const DbgValueHistoryMap::InstrRanges &Ranges);
 
   /// \brief Collect variable information from the side table maintained
   /// by MMI.





More information about the llvm-commits mailing list