[PATCH] D61940: [WIP][DebugInfo] Don't always extend variable locations when the reg location is unchanging

David Stenberg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 05:50:31 PDT 2019


dstenb added inline comments.


================
Comment at: lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp:360-393
       // Iterate over all variables that have open debug values.
       SmallSet<unsigned, 8> RegsToClobber;
       for (auto &Pair : LiveEntries) {
         // Iterate over history entries for all open fragments.
         SmallVector<EntryIndex, 8> IdxesToRemove;
         for (EntryIndex Idx : Pair.second) {
           DbgValueHistoryMap::Entry &Ent = DbgValues.getEntry(Pair.first, Idx);
----------------
(I saw the note about this not being for review right now; just pointing this out if this is productified later on.)

Now that we close all register-described values I think that this code can be simplified a bit (e.g. not calling `clobberRegisterUses`), by instead closing all values by iterating over `LiveEntries`.

Something like this (I have not even tested compiling it, so it is probably a bit broken):

```
// Clobber all live debug values (both those that are register-described and
// those that are described by other values).
for (auto &Pair : LiveEntries) {
  if (Pair.second.empty())
    continue;

  // Create a clobbering entry.
  EntryIndex ClobIdx = DbgValues.startClobber(Pair.first, MBB.back());

  // End all entries.
  for (EntryIndex Idx : Pair.second) {
    DbgValueHistoryMap::Entry &Ent = DbgValues.getEntry(Pair.first, Idx);
    assert(Ent.isDbgValue() && !Ent.isClosed());
    Ent.endEntry(ClobIdx);
  }
}

LiveEntries.erase();
RegVars.erase();
```

Or if there is something that I have overlooked that makes it required (or preferable) to use `clobberRegisterUses` for closing register-described values, we should be able to change it to something like this:

```
// Clobber registers at the end of BB.
for (auto I = RegVars.begin(), E = RegVars.end(); I != E;) {
  auto CurElem = I++; // CurElem can be erased below.
  clobberRegisterUses(RegVars, CurElem, DbgValues, LiveEntries,
                      MBB.back());
}

// Clobber the rest of the live debug values.
for (auto &Pair : LiveEntries) {
  if (Pair.second.empty())
    continue;

  // Create a clobbering entry.
  EntryIndex ClobIdx = DbgValues.startClobber(Pair.first, MBB.back());

  // End all entries.
  for (EntryIndex Idx : Pair.second) {
    DbgValueHistoryMap::Entry &Ent = DbgValues.getEntry(Pair.first, Idx);
    assert(Ent.isDbgValue() && !Ent.isClosed());
    Ent.endEntry(ClobIdx);
  }
}

LiveEntries.erase();
```


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61940/new/

https://reviews.llvm.org/D61940





More information about the llvm-commits mailing list