]> granicus.if.org Git - llvm/commitdiff
[DebugInfo] Rename DbgValueHistoryMap::{InstrRange -> Entry}, NFC
authorDavid Stenberg <david.stenberg@ericsson.com>
Wed, 10 Apr 2019 09:07:43 +0000 (09:07 +0000)
committerDavid Stenberg <david.stenberg@ericsson.com>
Wed, 10 Apr 2019 09:07:43 +0000 (09:07 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358060 91177308-0d34-0410-b5e6-96231b3b80d8

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

index a28b66f45b93a4e28c4119b29c411e24a7fceb64..82f882f86d8d656828c5292ffdef4c5a2f4cbdd6 100644 (file)
@@ -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;
index b91f40de1487ddeee76c4987ea5875127db22d78..75a63df083aa51e8ba7b9ecca87c9f37a4d1dbe1 100644 (file)
@@ -1154,13 +1154,13 @@ static bool needsReferenceType(const DbgVariableLocation &Loc) {
 }
 
 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 DISubprogram *SP) {
     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(const DISubprogram *SP) {
     LocalVariable Var;
     Var.DIVar = DIVar;
 
-    calculateRanges(Var, Ranges);
+    calculateRanges(Var, Entries);
     recordLocalVariable(std::move(Var), Scope);
   }
 }
index 7cf7b19ec70b48ca0e52b4dec69c37bc7c85393d..35902302c2152340d65f80f0cd83f58257485846 100644 (file)
@@ -222,7 +222,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase {
   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,
index bf510b9e21dcbbeec3d84d09f1453dc344ccabf5..618fee9544d79eac105f510f59dd9c9424ac84df 100644 (file)
@@ -41,30 +41,28 @@ static unsigned isDescribedByReg(const MachineInstr &MI) {
   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::endRange(const MachineInstr &MI) {
 }
 
 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(RegDescribedVarsMap &RegVars,
   // 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(const MachineFunction *MF,
         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::dump() const {
   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::dump() const {
 
     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";
     }
   }
index 7a435422652b6da1d927b34c722e6473cf2f4376..00e4cea3135319b321da25638e40583e6cf5bbe4 100644 (file)
@@ -211,8 +211,8 @@ void DebugHandlerBase::beginFunction(const MachineFunction *MF) {
 
   // 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(const MachineFunction *MF) {
     // 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(const MachineFunction *MF) {
       }
     }
 
-    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());
     }
   }
 
index 1547822b69576b821c6661aeb9f98127a399eaaf..07232b5082abe24e90a1eacc8362bbc78962a4fa 100644 (file)
@@ -1117,14 +1117,13 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
 // [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(SmallVectorImpl<DebugLocEntry> &DebugLoc,
     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(DwarfCompileUnit &TheCU,
       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(DwarfCompileUnit &TheCU,
     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(DwarfCompileUnit &TheCU,
 
     // 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
index ec5040f6c1024c02eacda4967e79e95578144551..a8cadaa60ebc314c9af8847a18201becd8c40992 100644 (file)
@@ -559,7 +559,7 @@ class DwarfDebug : public DebugHandlerBase {
   /// 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,