[llvm] r358060 - [DebugInfo] Rename DbgValueHistoryMap::{InstrRange -> Entry}, NFC

David Stenberg via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 02:07:44 PDT 2019


Author: dstenb
Date: Wed Apr 10 02:07:43 2019
New Revision: 358060

URL: http://llvm.org/viewvc/llvm-project?rev=358060&view=rev
Log:
[DebugInfo] Rename DbgValueHistoryMap::{InstrRange -> Entry}, NFC

Summary:
In an upcoming commit the history map will be changed so that it
contains explicit entries for instructions that clobber preceding debug
values, rather than Begin- End range pairs, so generalize the name to
"Entry".

Also, prefix the iterator variable names in buildLocationList() with
"E". In an upcoming commit the entry will have query functions such as
"isD(e)b(u)gValue", which could at a glance make one confuse it for
iterations over MachineInstrs, so make the iterator names a bit more
distinct to avoid that.

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59939

Modified:
    llvm/trunk/include/llvm/CodeGen/DbgEntityHistoryCalculator.h
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h

Modified: llvm/trunk/include/llvm/CodeGen/DbgEntityHistoryCalculator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DbgEntityHistoryCalculator.h?rev=358060&r1=358059&r2=358060&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DbgEntityHistoryCalculator.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DbgEntityHistoryCalculator.h Wed Apr 10 02:07:43 2019
@@ -32,39 +32,39 @@ public:
   /// End is not specified, the location is valid until the first overlapping
   /// DBG_VALUE if any such DBG_VALUE exists, otherwise it is valid until the
   /// end of the function.
-  class InstrRange {
+  class Entry {
     const MachineInstr *Begin;
     const MachineInstr *End;
 
   public:
-    InstrRange(const MachineInstr *Begin) : Begin(Begin), End(nullptr) {}
+    Entry(const MachineInstr *Begin) : Begin(Begin), End(nullptr) {}
 
     const MachineInstr *getBegin() const { return Begin; }
     const MachineInstr *getEnd() const { return End; }
 
     bool isClosed() const { return End; }
 
-    void endRange(const MachineInstr &End);
+    void endEntry(const MachineInstr &End);
   };
-  using InstrRanges = SmallVector<InstrRange, 4>;
+  using Entries = SmallVector<Entry, 4>;
   using InlinedEntity = std::pair<const DINode *, const DILocation *>;
-  using InstrRangesMap = MapVector<InlinedEntity, InstrRanges>;
+  using EntriesMap = MapVector<InlinedEntity, Entries>;
 
 private:
-  InstrRangesMap VarInstrRanges;
+  EntriesMap VarEntries;
 
 public:
-  void startInstrRange(InlinedEntity Var, const MachineInstr &MI);
-  void endInstrRange(InlinedEntity Var, const MachineInstr &MI);
+  void startEntry(InlinedEntity Var, const MachineInstr &MI);
+  void endEntry(InlinedEntity Var, const MachineInstr &MI);
 
   // Returns register currently describing @Var. If @Var is currently
   // unaccessible or is not described by a register, returns 0.
   unsigned getRegisterForVar(InlinedEntity Var) const;
 
-  bool empty() const { return VarInstrRanges.empty(); }
-  void clear() { VarInstrRanges.clear(); }
-  InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); }
-  InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); }
+  bool empty() const { return VarEntries.empty(); }
+  void clear() { VarEntries.clear(); }
+  EntriesMap::const_iterator begin() const { return VarEntries.begin(); }
+  EntriesMap::const_iterator end() const { return VarEntries.end(); }
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   LLVM_DUMP_METHOD void dump() const;

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=358060&r1=358059&r2=358060&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Wed Apr 10 02:07:43 2019
@@ -1154,13 +1154,13 @@ static bool needsReferenceType(const Dbg
 }
 
 void CodeViewDebug::calculateRanges(
-    LocalVariable &Var, const DbgValueHistoryMap::InstrRanges &Ranges) {
+    LocalVariable &Var, const DbgValueHistoryMap::Entries &Entries) {
   const TargetRegisterInfo *TRI = Asm->MF->getSubtarget().getRegisterInfo();
 
   // Calculate the definition ranges.
-  for (auto I = Ranges.begin(), E = Ranges.end(); I != E; ++I) {
-    const auto &Range = *I;
-    const MachineInstr *DVInst = Range.getBegin();
+  for (auto I = Entries.begin(), E = Entries.end(); I != E; ++I) {
+    const auto &Entry = *I;
+    const MachineInstr *DVInst = Entry.getBegin();
     assert(DVInst->isDebugValue() && "Invalid History entry");
     // FIXME: Find a way to represent constant variables, since they are
     // relatively common.
@@ -1187,7 +1187,7 @@ void CodeViewDebug::calculateRanges(
       // Start over using that.
       Var.UseReferenceType = true;
       Var.DefRanges.clear();
-      calculateRanges(Var, Ranges);
+      calculateRanges(Var, Entries);
       return;
     }
 
@@ -1215,8 +1215,8 @@ void CodeViewDebug::calculateRanges(
     }
 
     // Compute the label range.
-    const MCSymbol *Begin = getLabelBeforeInsn(Range.getBegin());
-    const MCSymbol *End = getLabelAfterInsn(Range.getEnd());
+    const MCSymbol *Begin = getLabelBeforeInsn(Entry.getBegin());
+    const MCSymbol *End = getLabelAfterInsn(Entry.getEnd());
     if (!End) {
       // This range is valid until the next overlapping bitpiece. In the
       // common case, ranges will not be bitpieces, so they will overlap.
@@ -1257,7 +1257,7 @@ void CodeViewDebug::collectVariableInfo(
     const DILocation *InlinedAt = IV.second;
 
     // Instruction ranges, specifying where IV is accessible.
-    const auto &Ranges = I.second;
+    const auto &Entries = I.second;
 
     LexicalScope *Scope = nullptr;
     if (InlinedAt)
@@ -1271,7 +1271,7 @@ void CodeViewDebug::collectVariableInfo(
     LocalVariable Var;
     Var.DIVar = DIVar;
 
-    calculateRanges(Var, Ranges);
+    calculateRanges(Var, Entries);
     recordLocalVariable(std::move(Var), Scope);
   }
 }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=358060&r1=358059&r2=358060&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h Wed Apr 10 02:07:43 2019
@@ -222,7 +222,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe
   codeview::TypeIndex getFuncIdForSubprogram(const DISubprogram *SP);
 
   void calculateRanges(LocalVariable &Var,
-                       const DbgValueHistoryMap::InstrRanges &Ranges);
+                       const DbgValueHistoryMap::Entries &Entries);
 
   static void collectInlineSiteChildren(SmallVectorImpl<unsigned> &Children,
                                         const FunctionInfo &FI,

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp?rev=358060&r1=358059&r2=358060&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp Wed Apr 10 02:07:43 2019
@@ -41,30 +41,28 @@ static unsigned isDescribedByReg(const M
   return MI.getOperand(0).isReg() ? MI.getOperand(0).getReg() : 0;
 }
 
-void DbgValueHistoryMap::startInstrRange(InlinedEntity Var,
-                                         const MachineInstr &MI) {
+void DbgValueHistoryMap::startEntry(InlinedEntity Var, const MachineInstr &MI) {
   // Instruction range should start with a DBG_VALUE instruction for the
   // variable.
   assert(MI.isDebugValue() && "not a DBG_VALUE");
-  auto &Ranges = VarInstrRanges[Var];
-  if (!Ranges.empty() && !Ranges.back().isClosed() &&
-      Ranges.back().getBegin()->isIdenticalTo(MI)) {
+  auto &Entries = VarEntries[Var];
+  if (!Entries.empty() && !Entries.back().isClosed() &&
+      Entries.back().getBegin()->isIdenticalTo(MI)) {
     LLVM_DEBUG(dbgs() << "Coalescing identical DBG_VALUE entries:\n"
-                      << "\t" << Ranges.back().getBegin() << "\t" << MI
+                      << "\t" << Entries.back().getBegin() << "\t" << MI
                       << "\n");
     return;
   }
-  Ranges.emplace_back(&MI);
+  Entries.emplace_back(&MI);
 }
 
-void DbgValueHistoryMap::endInstrRange(InlinedEntity Var,
-                                       const MachineInstr &MI) {
-  auto &Ranges = VarInstrRanges[Var];
-  assert(!Ranges.empty() && "No range exists for variable!");
-  Ranges.back().endRange(MI);
+void DbgValueHistoryMap::endEntry(InlinedEntity Var, const MachineInstr &MI) {
+  auto &Entries = VarEntries[Var];
+  assert(!Entries.empty() && "No range exists for variable!");
+  Entries.back().endEntry(MI);
 }
 
-void DbgValueHistoryMap::InstrRange::endRange(const MachineInstr &MI) {
+void DbgValueHistoryMap::Entry::endEntry(const MachineInstr &MI) {
   // For now, instruction ranges are not allowed to cross basic block
   // boundaries.
   assert(Begin->getParent() == MI.getParent());
@@ -73,13 +71,13 @@ void DbgValueHistoryMap::InstrRange::end
 }
 
 unsigned DbgValueHistoryMap::getRegisterForVar(InlinedEntity Var) const {
-  const auto &I = VarInstrRanges.find(Var);
-  if (I == VarInstrRanges.end())
+  const auto &I = VarEntries.find(Var);
+  if (I == VarEntries.end())
     return 0;
-  const auto &Ranges = I->second;
-  if (Ranges.empty() || Ranges.back().isClosed())
+  const auto &Entries = I->second;
+  if (Entries.empty() || Entries.back().isClosed())
     return 0;
-  return isDescribedByReg(*Ranges.back().getBegin());
+  return isDescribedByReg(*Entries.back().getBegin());
 }
 
 void DbgLabelInstrMap::addInstr(InlinedEntity Label, const MachineInstr &MI) {
@@ -127,7 +125,7 @@ static void clobberRegisterUses(RegDescr
   // Iterate over all variables described by this register and add this
   // instruction to their history, clobbering it.
   for (const auto &Var : I->second)
-    HistMap.endInstrRange(Var, ClobberingInstr);
+    HistMap.endEntry(Var, ClobberingInstr);
   RegVars.erase(I);
 }
 
@@ -257,7 +255,7 @@ void llvm::calculateDbgEntityHistory(con
         if (unsigned PrevReg = DbgValues.getRegisterForVar(Var))
           dropRegDescribedVar(RegVars, PrevReg, Var);
 
-        DbgValues.startInstrRange(Var, MI);
+        DbgValues.startEntry(Var, MI);
 
         if (unsigned NewReg = isDescribedByReg(MI))
           addRegDescribedVar(RegVars, NewReg, Var);
@@ -293,7 +291,7 @@ LLVM_DUMP_METHOD void DbgValueHistoryMap
   dbgs() << "DbgValueHistoryMap:\n";
   for (const auto &VarRangePair : *this) {
     const InlinedEntity &Var = VarRangePair.first;
-    const InstrRanges &Ranges = VarRangePair.second;
+    const Entries &Entries = VarRangePair.second;
 
     const DILocalVariable *LocalVar = cast<DILocalVariable>(Var.first);
     const DILocation *Location = Var.second;
@@ -308,10 +306,10 @@ LLVM_DUMP_METHOD void DbgValueHistoryMap
 
     dbgs() << " --\n";
 
-    for (const InstrRange &Range : Ranges) {
-      dbgs() << "   Begin: " << *Range.getBegin();
-      if (Range.getEnd())
-        dbgs() << "   End  : " << *Range.getEnd();
+    for (const auto &Entry : Entries) {
+      dbgs() << "   Begin: " << *Entry.getBegin();
+      if (Entry.getEnd())
+        dbgs() << "   End  : " << *Entry.getEnd();
       dbgs() << "\n";
     }
   }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp?rev=358060&r1=358059&r2=358060&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp Wed Apr 10 02:07:43 2019
@@ -211,8 +211,8 @@ void DebugHandlerBase::beginFunction(con
 
   // Request labels for the full history.
   for (const auto &I : DbgValues) {
-    const auto &Ranges = I.second;
-    if (Ranges.empty())
+    const auto &Entries = I.second;
+    if (Entries.empty())
       continue;
 
     auto IsDescribedByReg = [](const MachineInstr *MI) {
@@ -229,17 +229,17 @@ void DebugHandlerBase::beginFunction(con
     // However, we currently do not emit debug values for constant arguments
     // directly at the start of the function, so this code is still useful.
     const DILocalVariable *DIVar =
-        Ranges.front().getBegin()->getDebugVariable();
+        Entries.front().getBegin()->getDebugVariable();
     if (DIVar->isParameter() &&
         getDISubprogram(DIVar->getScope())->describes(&MF->getFunction())) {
-      if (!IsDescribedByReg(Ranges.front().getBegin()))
-        LabelsBeforeInsn[Ranges.front().getBegin()] = Asm->getFunctionBegin();
-      if (Ranges.front().getBegin()->getDebugExpression()->isFragment()) {
+      if (!IsDescribedByReg(Entries.front().getBegin()))
+        LabelsBeforeInsn[Entries.front().getBegin()] = Asm->getFunctionBegin();
+      if (Entries.front().getBegin()->getDebugExpression()->isFragment()) {
         // Mark all non-overlapping initial fragments.
-        for (auto I = Ranges.begin(); I != Ranges.end(); ++I) {
+        for (auto I = Entries.begin(); I != Entries.end(); ++I) {
           const DIExpression *Fragment = I->getBegin()->getDebugExpression();
-          if (std::any_of(Ranges.begin(), I,
-                          [&](DbgValueHistoryMap::InstrRange Pred) {
+          if (std::any_of(Entries.begin(), I,
+                          [&](DbgValueHistoryMap::Entry Pred) {
                             return Fragment->fragmentsOverlap(
                                 Pred.getBegin()->getDebugExpression());
                           }))
@@ -250,10 +250,10 @@ void DebugHandlerBase::beginFunction(con
       }
     }
 
-    for (const auto &Range : Ranges) {
-      requestLabelBeforeInsn(Range.getBegin());
-      if (Range.getEnd())
-        requestLabelAfterInsn(Range.getEnd());
+    for (const auto &Entry : Entries) {
+      requestLabelBeforeInsn(Entry.getBegin());
+      if (Entry.getEnd())
+        requestLabelAfterInsn(Entry.getEnd());
     }
   }
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=358060&r1=358059&r2=358060&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Apr 10 02:07:43 2019
@@ -1117,14 +1117,13 @@ static DebugLocEntry::Value getDebugLocV
 // [1-3]    [x, (reg0, fragment  0, 32), (reg1, fragment 32, 32)]
 // [3-4]    [x, (reg1, fragment 32, 32)]
 // [4- ]    [x, (mem,  fragment  0, 64)]
-void
-DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
-                              const DbgValueHistoryMap::InstrRanges &Ranges) {
+void DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
+                                   const DbgValueHistoryMap::Entries &Entries) {
   SmallVector<DebugLocEntry::Value, 4> OpenRanges;
 
-  for (auto I = Ranges.begin(), E = Ranges.end(); I != E; ++I) {
-    const MachineInstr *Begin = I->getBegin();
-    const MachineInstr *End = I->getEnd();
+  for (auto EI = Entries.begin(), EE = Entries.end(); EI != EE; ++EI) {
+    const MachineInstr *Begin = EI->getBegin();
+    const MachineInstr *End = EI->getEnd();
     assert(Begin->isDebugValue() && "Invalid History entry");
 
     // Check if a variable is inaccessible in this range.
@@ -1147,10 +1146,10 @@ DwarfDebug::buildLocationList(SmallVecto
     const MCSymbol *EndLabel;
     if (End != nullptr)
       EndLabel = getLabelAfterInsn(End);
-    else if (std::next(I) == Ranges.end())
+    else if (std::next(EI) == Entries.end())
       EndLabel = Asm->getFunctionEnd();
     else
-      EndLabel = getLabelBeforeInsn(std::next(I)->getBegin());
+      EndLabel = getLabelBeforeInsn(std::next(EI)->getBegin());
     assert(EndLabel && "Forgot label after instruction ending a range!");
 
     LLVM_DEBUG(dbgs() << "DotDebugLoc: " << *Begin << "\n");
@@ -1275,8 +1274,8 @@ void DwarfDebug::collectEntityInfo(Dwarf
       continue;
 
     // Instruction ranges, specifying where IV is accessible.
-    const auto &Ranges = I.second;
-    if (Ranges.empty())
+    const auto &HistoryMapEntries = I.second;
+    if (HistoryMapEntries.empty())
       continue;
 
     LexicalScope *Scope = nullptr;
@@ -1293,12 +1292,12 @@ void DwarfDebug::collectEntityInfo(Dwarf
     DbgVariable *RegVar = cast<DbgVariable>(createConcreteEntity(TheCU,
                                             *Scope, LocalVar, IV.second));
 
-    const MachineInstr *MInsn = Ranges.front().getBegin();
+    const MachineInstr *MInsn = HistoryMapEntries.front().getBegin();
     assert(MInsn->isDebugValue() && "History must begin with debug value");
 
     // Check if there is a single DBG_VALUE, valid throughout the var's scope.
-    if (Ranges.size() == 1 &&
-        validThroughout(LScopes, MInsn, Ranges.front().getEnd())) {
+    if (HistoryMapEntries.size() == 1 &&
+        validThroughout(LScopes, MInsn, HistoryMapEntries.front().getEnd())) {
       RegVar->initializeDbgValue(MInsn);
       continue;
     }
@@ -1311,7 +1310,7 @@ void DwarfDebug::collectEntityInfo(Dwarf
 
     // Build the location list for this variable.
     SmallVector<DebugLocEntry, 8> Entries;
-    buildLocationList(Entries, Ranges);
+    buildLocationList(Entries, HistoryMapEntries);
 
     // If the variable has a DIBasicType, extract it.  Basic types cannot have
     // unique identifiers, so don't bother resolving the type with the

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=358060&r1=358059&r2=358060&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Apr 10 02:07:43 2019
@@ -559,7 +559,7 @@ class DwarfDebug : public DebugHandlerBa
   /// 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);
+                         const DbgValueHistoryMap::Entries &Entries);
 
   /// Collect variable information from the side table maintained by MF.
   void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,




More information about the llvm-commits mailing list