1 //===- llvm/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/CodeGen/DbgEntityHistoryCalculator.h"
10 #include "llvm/ADT/BitVector.h"
11 #include "llvm/ADT/Optional.h"
12 #include "llvm/ADT/STLExtras.h"
13 #include "llvm/ADT/SmallSet.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/CodeGen/LexicalScopes.h"
16 #include "llvm/CodeGen/MachineBasicBlock.h"
17 #include "llvm/CodeGen/MachineFunction.h"
18 #include "llvm/CodeGen/MachineInstr.h"
19 #include "llvm/CodeGen/MachineOperand.h"
20 #include "llvm/CodeGen/TargetLowering.h"
21 #include "llvm/CodeGen/TargetRegisterInfo.h"
22 #include "llvm/CodeGen/TargetSubtargetInfo.h"
23 #include "llvm/IR/DebugInfoMetadata.h"
24 #include "llvm/IR/DebugLoc.h"
25 #include "llvm/MC/MCRegisterInfo.h"
26 #include "llvm/Support/Debug.h"
27 #include "llvm/Support/raw_ostream.h"
28 #include <cassert>
29 #include <map>
30 #include <utility>
31 
32 using namespace llvm;
33 
34 #define DEBUG_TYPE "dwarfdebug"
35 
36 namespace {
37 using EntryIndex = DbgValueHistoryMap::EntryIndex;
38 }
39 
40 // If @MI is a DBG_VALUE with debug value described by a
41 // defined register, returns the number of this register.
42 // In the other case, returns 0.
43 static Register isDescribedByReg(const MachineInstr &MI) {
44   assert(MI.isDebugValue());
45   assert(MI.getNumOperands() == 4);
46   // If the location of variable is an entry value (DW_OP_LLVM_entry_value)
47   // do not consider it as a register location.
48   if (MI.getDebugExpression()->isEntryValue())
49     return 0;
50   // If location of variable is described using a register (directly or
51   // indirectly), this register is always a first operand.
52   return MI.getDebugOperand(0).isReg() ? MI.getDebugOperand(0).getReg()
53                                        : Register();
54 }
55 
56 void InstructionOrdering::initialize(const MachineFunction &MF) {
57   // We give meta instructions the same ordinal as the preceding instruction
58   // because this class is written for the task of comparing positions of
59   // variable location ranges against scope ranges. To reflect what we'll see
60   // in the binary, when we look at location ranges we must consider all
61   // DBG_VALUEs between two real instructions at the same position. And a
62   // scope range which ends on a meta instruction should be considered to end
63   // at the last seen real instruction. E.g.
64   //
65   //  1 instruction p      Both the variable location for x and for y start
66   //  1 DBG_VALUE for "x"  after instruction p so we give them all the same
67   //  1 DBG_VALUE for "y"  number. If a scope range ends at DBG_VALUE for "y",
68   //  2 instruction q      we should treat it as ending after instruction p
69   //                       because it will be the last real instruction in the
70   //                       range. DBG_VALUEs at or after this position for
71   //                       variables declared in the scope will have no effect.
72   clear();
73   unsigned Position = 0;
74   for (const MachineBasicBlock &MBB : MF)
75     for (const MachineInstr &MI : MBB)
76       InstNumberMap[&MI] = MI.isMetaInstruction() ? Position : ++Position;
77 }
78 
79 bool InstructionOrdering::isBefore(const MachineInstr *A,
80                                    const MachineInstr *B) const {
81   assert(A->getParent() && B->getParent() && "Operands must have a parent");
82   assert(A->getMF() == B->getMF() &&
83          "Operands must be in the same MachineFunction");
84   return InstNumberMap.lookup(A) < InstNumberMap.lookup(B);
85 }
86 
87 bool DbgValueHistoryMap::startDbgValue(InlinedEntity Var,
88                                        const MachineInstr &MI,
89                                        EntryIndex &NewIndex) {
90   // Instruction range should start with a DBG_VALUE instruction for the
91   // variable.
92   assert(MI.isDebugValue() && "not a DBG_VALUE");
93   auto &Entries = VarEntries[Var];
94   if (!Entries.empty() && Entries.back().isDbgValue() &&
95       !Entries.back().isClosed() &&
96       Entries.back().getInstr()->isIdenticalTo(MI)) {
97     LLVM_DEBUG(dbgs() << "Coalescing identical DBG_VALUE entries:\n"
98                       << "\t" << Entries.back().getInstr() << "\t" << MI
99                       << "\n");
100     return false;
101   }
102   Entries.emplace_back(&MI, Entry::DbgValue);
103   NewIndex = Entries.size() - 1;
104   return true;
105 }
106 
107 EntryIndex DbgValueHistoryMap::startClobber(InlinedEntity Var,
108                                             const MachineInstr &MI) {
109   auto &Entries = VarEntries[Var];
110   // If an instruction clobbers multiple registers that the variable is
111   // described by, then we may have already created a clobbering instruction.
112   if (Entries.back().isClobber() && Entries.back().getInstr() == &MI)
113     return Entries.size() - 1;
114   Entries.emplace_back(&MI, Entry::Clobber);
115   return Entries.size() - 1;
116 }
117 
118 void DbgValueHistoryMap::Entry::endEntry(EntryIndex Index) {
119   // For now, instruction ranges are not allowed to cross basic block
120   // boundaries.
121   assert(isDbgValue() && "Setting end index for non-debug value");
122   assert(!isClosed() && "End index has already been set");
123   EndIndex = Index;
124 }
125 
126 /// Check if the instruction range [StartMI, EndMI] intersects any instruction
127 /// range in Ranges. EndMI can be nullptr to indicate that the range is
128 /// unbounded. Assumes Ranges is ordered and disjoint. Returns true and points
129 /// to the first intersecting scope range if one exists.
130 static Optional<ArrayRef<InsnRange>::iterator>
131 intersects(const MachineInstr *StartMI, const MachineInstr *EndMI,
132            const ArrayRef<InsnRange> &Ranges,
133            const InstructionOrdering &Ordering) {
134   for (auto RangesI = Ranges.begin(), RangesE = Ranges.end();
135        RangesI != RangesE; ++RangesI) {
136     if (EndMI && Ordering.isBefore(EndMI, RangesI->first))
137       return None;
138     if (EndMI && !Ordering.isBefore(RangesI->second, EndMI))
139       return RangesI;
140     if (Ordering.isBefore(StartMI, RangesI->second))
141       return RangesI;
142   }
143   return None;
144 }
145 
146 void DbgValueHistoryMap::trimLocationRanges(
147     const MachineFunction &MF, LexicalScopes &LScopes,
148     const InstructionOrdering &Ordering) {
149   // The indices of the entries we're going to remove for each variable.
150   SmallVector<EntryIndex, 4> ToRemove;
151   // Entry reference count for each variable. Clobbers left with no references
152   // will be removed.
153   SmallVector<int, 4> ReferenceCount;
154   // Entries reference other entries by index. Offsets is used to remap these
155   // references if any entries are removed.
156   SmallVector<size_t, 4> Offsets;
157 
158   for (auto &Record : VarEntries) {
159     auto &HistoryMapEntries = Record.second;
160     if (HistoryMapEntries.empty())
161       continue;
162 
163     InlinedEntity Entity = Record.first;
164     const DILocalVariable *LocalVar = cast<DILocalVariable>(Entity.first);
165 
166     LexicalScope *Scope = nullptr;
167     if (const DILocation *InlinedAt = Entity.second) {
168       Scope = LScopes.findInlinedScope(LocalVar->getScope(), InlinedAt);
169     } else {
170       Scope = LScopes.findLexicalScope(LocalVar->getScope());
171       // Ignore variables for non-inlined function level scopes. The scope
172       // ranges (from scope->getRanges()) will not include any instructions
173       // before the first one with a debug-location, which could cause us to
174       // incorrectly drop a location. We could introduce special casing for
175       // these variables, but it doesn't seem worth it because no out-of-scope
176       // locations have been observed for variables declared in function level
177       // scopes.
178       if (Scope &&
179           (Scope->getScopeNode() == Scope->getScopeNode()->getSubprogram()) &&
180           (Scope->getScopeNode() == LocalVar->getScope()))
181         continue;
182     }
183 
184     // If there is no scope for the variable then something has probably gone
185     // wrong.
186     if (!Scope)
187       continue;
188 
189     ToRemove.clear();
190     // Zero the reference counts.
191     ReferenceCount.assign(HistoryMapEntries.size(), 0);
192     // Index of the DBG_VALUE which marks the start of the current location
193     // range.
194     EntryIndex StartIndex = 0;
195     ArrayRef<InsnRange> ScopeRanges(Scope->getRanges());
196     for (auto EI = HistoryMapEntries.begin(), EE = HistoryMapEntries.end();
197          EI != EE; ++EI, ++StartIndex) {
198       // Only DBG_VALUEs can open location ranges so skip anything else.
199       if (!EI->isDbgValue())
200         continue;
201 
202       // Index of the entry which closes this range.
203       EntryIndex EndIndex = EI->getEndIndex();
204       // If this range is closed bump the reference count of the closing entry.
205       if (EndIndex != NoEntry)
206         ReferenceCount[EndIndex] += 1;
207       // Skip this location range if the opening entry is still referenced. It
208       // may close a location range which intersects a scope range.
209       // TODO: We could be 'smarter' and trim these kinds of ranges such that
210       // they do not leak out of the scope ranges if they partially overlap.
211       if (ReferenceCount[StartIndex] > 0)
212         continue;
213 
214       const MachineInstr *StartMI = EI->getInstr();
215       const MachineInstr *EndMI = EndIndex != NoEntry
216                                       ? HistoryMapEntries[EndIndex].getInstr()
217                                       : nullptr;
218       // Check if the location range [StartMI, EndMI] intersects with any scope
219       // range for the variable.
220       if (auto R = intersects(StartMI, EndMI, ScopeRanges, Ordering)) {
221         // Adjust ScopeRanges to exclude ranges which subsequent location ranges
222         // cannot possibly intersect.
223         ScopeRanges = ArrayRef<InsnRange>(R.getValue(), ScopeRanges.end());
224       } else {
225         // If the location range does not intersect any scope range then the
226         // DBG_VALUE which opened this location range is usless, mark it for
227         // removal.
228         ToRemove.push_back(StartIndex);
229         // Because we'll be removing this entry we need to update the reference
230         // count of the closing entry, if one exists.
231         if (EndIndex != NoEntry)
232           ReferenceCount[EndIndex] -= 1;
233       }
234     }
235 
236     // If there is nothing to remove then jump to next variable.
237     if (ToRemove.empty())
238       continue;
239 
240     // Mark clobbers that will no longer close any location ranges for removal.
241     for (size_t i = 0; i < HistoryMapEntries.size(); ++i)
242       if (ReferenceCount[i] <= 0 && HistoryMapEntries[i].isClobber())
243         ToRemove.push_back(i);
244 
245     llvm::sort(ToRemove);
246 
247     // Build an offset map so we can update the EndIndex of the remaining
248     // entries.
249     // Zero the offsets.
250     Offsets.assign(HistoryMapEntries.size(), 0);
251     size_t CurOffset = 0;
252     auto ToRemoveItr = ToRemove.begin();
253     for (size_t EntryIdx = *ToRemoveItr; EntryIdx < HistoryMapEntries.size();
254          ++EntryIdx) {
255       // Check if this is an entry which will be removed.
256       if (ToRemoveItr != ToRemove.end() && *ToRemoveItr == EntryIdx) {
257         ++ToRemoveItr;
258         ++CurOffset;
259       }
260       Offsets[EntryIdx] = CurOffset;
261     }
262 
263     // Update the EndIndex of the entries to account for those which will be
264     // removed.
265     for (auto &Entry : HistoryMapEntries)
266       if (Entry.isClosed())
267         Entry.EndIndex -= Offsets[Entry.EndIndex];
268 
269     // Now actually remove the entries. Iterate backwards so that our remaining
270     // ToRemove indices are valid after each erase.
271     for (auto Itr = ToRemove.rbegin(), End = ToRemove.rend(); Itr != End; ++Itr)
272       HistoryMapEntries.erase(HistoryMapEntries.begin() + *Itr);
273   }
274 }
275 
276 void DbgLabelInstrMap::addInstr(InlinedEntity Label, const MachineInstr &MI) {
277   assert(MI.isDebugLabel() && "not a DBG_LABEL");
278   LabelInstr[Label] = &MI;
279 }
280 
281 namespace {
282 
283 // Maps physreg numbers to the variables they describe.
284 using InlinedEntity = DbgValueHistoryMap::InlinedEntity;
285 using RegDescribedVarsMap = std::map<unsigned, SmallVector<InlinedEntity, 1>>;
286 
287 // Keeps track of the debug value entries that are currently live for each
288 // inlined entity. As the history map entries are stored in a SmallVector, they
289 // may be moved at insertion of new entries, so store indices rather than
290 // pointers.
291 using DbgValueEntriesMap = std::map<InlinedEntity, SmallSet<EntryIndex, 1>>;
292 
293 } // end anonymous namespace
294 
295 // Claim that @Var is not described by @RegNo anymore.
296 static void dropRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo,
297                                 InlinedEntity Var) {
298   const auto &I = RegVars.find(RegNo);
299   assert(RegNo != 0U && I != RegVars.end());
300   auto &VarSet = I->second;
301   const auto &VarPos = llvm::find(VarSet, Var);
302   assert(VarPos != VarSet.end());
303   VarSet.erase(VarPos);
304   // Don't keep empty sets in a map to keep it as small as possible.
305   if (VarSet.empty())
306     RegVars.erase(I);
307 }
308 
309 // Claim that @Var is now described by @RegNo.
310 static void addRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo,
311                                InlinedEntity Var) {
312   assert(RegNo != 0U);
313   auto &VarSet = RegVars[RegNo];
314   assert(!is_contained(VarSet, Var));
315   VarSet.push_back(Var);
316 }
317 
318 /// Create a clobbering entry and end all open debug value entries
319 /// for \p Var that are described by \p RegNo using that entry.
320 static void clobberRegEntries(InlinedEntity Var, unsigned RegNo,
321                               const MachineInstr &ClobberingInstr,
322                               DbgValueEntriesMap &LiveEntries,
323                               DbgValueHistoryMap &HistMap) {
324   EntryIndex ClobberIndex = HistMap.startClobber(Var, ClobberingInstr);
325 
326   // Close all entries whose values are described by the register.
327   SmallVector<EntryIndex, 4> IndicesToErase;
328   for (auto Index : LiveEntries[Var]) {
329     auto &Entry = HistMap.getEntry(Var, Index);
330     assert(Entry.isDbgValue() && "Not a DBG_VALUE in LiveEntries");
331     if (isDescribedByReg(*Entry.getInstr()) == RegNo) {
332       IndicesToErase.push_back(Index);
333       Entry.endEntry(ClobberIndex);
334     }
335   }
336 
337   // Drop all entries that have ended.
338   for (auto Index : IndicesToErase)
339     LiveEntries[Var].erase(Index);
340 }
341 
342 /// Add a new debug value for \p Var. Closes all overlapping debug values.
343 static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV,
344                                 RegDescribedVarsMap &RegVars,
345                                 DbgValueEntriesMap &LiveEntries,
346                                 DbgValueHistoryMap &HistMap) {
347   EntryIndex NewIndex;
348   if (HistMap.startDbgValue(Var, DV, NewIndex)) {
349     SmallDenseMap<unsigned, bool, 4> TrackedRegs;
350 
351     // If we have created a new debug value entry, close all preceding
352     // live entries that overlap.
353     SmallVector<EntryIndex, 4> IndicesToErase;
354     const DIExpression *DIExpr = DV.getDebugExpression();
355     for (auto Index : LiveEntries[Var]) {
356       auto &Entry = HistMap.getEntry(Var, Index);
357       assert(Entry.isDbgValue() && "Not a DBG_VALUE in LiveEntries");
358       const MachineInstr &DV = *Entry.getInstr();
359       bool Overlaps = DIExpr->fragmentsOverlap(DV.getDebugExpression());
360       if (Overlaps) {
361         IndicesToErase.push_back(Index);
362         Entry.endEntry(NewIndex);
363       }
364       if (Register Reg = isDescribedByReg(DV))
365         TrackedRegs[Reg] |= !Overlaps;
366     }
367 
368     // If the new debug value is described by a register, add tracking of
369     // that register if it is not already tracked.
370     if (Register NewReg = isDescribedByReg(DV)) {
371       if (!TrackedRegs.count(NewReg))
372         addRegDescribedVar(RegVars, NewReg, Var);
373       LiveEntries[Var].insert(NewIndex);
374       TrackedRegs[NewReg] = true;
375     }
376 
377     // Drop tracking of registers that are no longer used.
378     for (auto I : TrackedRegs)
379       if (!I.second)
380         dropRegDescribedVar(RegVars, I.first, Var);
381 
382     // Drop all entries that have ended, and mark the new entry as live.
383     for (auto Index : IndicesToErase)
384       LiveEntries[Var].erase(Index);
385     LiveEntries[Var].insert(NewIndex);
386   }
387 }
388 
389 // Terminate the location range for variables described by register at
390 // @I by inserting @ClobberingInstr to their history.
391 static void clobberRegisterUses(RegDescribedVarsMap &RegVars,
392                                 RegDescribedVarsMap::iterator I,
393                                 DbgValueHistoryMap &HistMap,
394                                 DbgValueEntriesMap &LiveEntries,
395                                 const MachineInstr &ClobberingInstr) {
396   // Iterate over all variables described by this register and add this
397   // instruction to their history, clobbering it.
398   for (const auto &Var : I->second)
399     clobberRegEntries(Var, I->first, ClobberingInstr, LiveEntries, HistMap);
400   RegVars.erase(I);
401 }
402 
403 // Terminate the location range for variables described by register
404 // @RegNo by inserting @ClobberingInstr to their history.
405 static void clobberRegisterUses(RegDescribedVarsMap &RegVars, unsigned RegNo,
406                                 DbgValueHistoryMap &HistMap,
407                                 DbgValueEntriesMap &LiveEntries,
408                                 const MachineInstr &ClobberingInstr) {
409   const auto &I = RegVars.find(RegNo);
410   if (I == RegVars.end())
411     return;
412   clobberRegisterUses(RegVars, I, HistMap, LiveEntries, ClobberingInstr);
413 }
414 
415 void llvm::calculateDbgEntityHistory(const MachineFunction *MF,
416                                      const TargetRegisterInfo *TRI,
417                                      DbgValueHistoryMap &DbgValues,
418                                      DbgLabelInstrMap &DbgLabels) {
419   const TargetLowering *TLI = MF->getSubtarget().getTargetLowering();
420   Register SP = TLI->getStackPointerRegisterToSaveRestore();
421   Register FrameReg = TRI->getFrameRegister(*MF);
422   RegDescribedVarsMap RegVars;
423   DbgValueEntriesMap LiveEntries;
424   for (const auto &MBB : *MF) {
425     for (const auto &MI : MBB) {
426       if (MI.isDebugValue()) {
427         assert(MI.getNumOperands() > 1 && "Invalid DBG_VALUE instruction!");
428         // Use the base variable (without any DW_OP_piece expressions)
429         // as index into History. The full variables including the
430         // piece expressions are attached to the MI.
431         const DILocalVariable *RawVar = MI.getDebugVariable();
432         assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
433                "Expected inlined-at fields to agree");
434         InlinedEntity Var(RawVar, MI.getDebugLoc()->getInlinedAt());
435 
436         handleNewDebugValue(Var, MI, RegVars, LiveEntries, DbgValues);
437       } else if (MI.isDebugLabel()) {
438         assert(MI.getNumOperands() == 1 && "Invalid DBG_LABEL instruction!");
439         const DILabel *RawLabel = MI.getDebugLabel();
440         assert(RawLabel->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
441             "Expected inlined-at fields to agree");
442         // When collecting debug information for labels, there is no MCSymbol
443         // generated for it. So, we keep MachineInstr in DbgLabels in order
444         // to query MCSymbol afterward.
445         InlinedEntity L(RawLabel, MI.getDebugLoc()->getInlinedAt());
446         DbgLabels.addInstr(L, MI);
447       }
448 
449       // Meta Instructions have no output and do not change any values and so
450       // can be safely ignored.
451       if (MI.isMetaInstruction())
452         continue;
453 
454       // Not a DBG_VALUE instruction. It may clobber registers which describe
455       // some variables.
456       for (const MachineOperand &MO : MI.operands()) {
457         if (MO.isReg() && MO.isDef() && MO.getReg()) {
458           // Ignore call instructions that claim to clobber SP. The AArch64
459           // backend does this for aggregate function arguments.
460           if (MI.isCall() && MO.getReg() == SP)
461             continue;
462           // If this is a virtual register, only clobber it since it doesn't
463           // have aliases.
464           if (Register::isVirtualRegister(MO.getReg()))
465             clobberRegisterUses(RegVars, MO.getReg(), DbgValues, LiveEntries,
466                                 MI);
467           // If this is a register def operand, it may end a debug value
468           // range. Ignore frame-register defs in the epilogue and prologue,
469           // we expect debuggers to understand that stack-locations are
470           // invalid outside of the function body.
471           else if (MO.getReg() != FrameReg ||
472                    (!MI.getFlag(MachineInstr::FrameDestroy) &&
473                    !MI.getFlag(MachineInstr::FrameSetup))) {
474             for (MCRegAliasIterator AI(MO.getReg(), TRI, true); AI.isValid();
475                  ++AI)
476               clobberRegisterUses(RegVars, *AI, DbgValues, LiveEntries, MI);
477           }
478         } else if (MO.isRegMask()) {
479           // If this is a register mask operand, clobber all debug values in
480           // non-CSRs.
481           SmallVector<unsigned, 32> RegsToClobber;
482           // Don't consider SP to be clobbered by register masks.
483           for (auto It : RegVars) {
484             unsigned int Reg = It.first;
485             if (Reg != SP && Register::isPhysicalRegister(Reg) &&
486                 MO.clobbersPhysReg(Reg))
487               RegsToClobber.push_back(Reg);
488           }
489 
490           for (unsigned Reg : RegsToClobber) {
491             clobberRegisterUses(RegVars, Reg, DbgValues, LiveEntries, MI);
492           }
493         }
494       } // End MO loop.
495     }   // End instr loop.
496 
497     // Make sure locations for all variables are valid only until the end of
498     // the basic block (unless it's the last basic block, in which case let
499     // their liveness run off to the end of the function).
500     if (!MBB.empty() && &MBB != &MF->back()) {
501       // Iterate over all variables that have open debug values.
502       for (auto &Pair : LiveEntries) {
503         if (Pair.second.empty())
504           continue;
505 
506         // Create a clobbering entry.
507         EntryIndex ClobIdx = DbgValues.startClobber(Pair.first, MBB.back());
508 
509         // End all entries.
510         for (EntryIndex Idx : Pair.second) {
511           DbgValueHistoryMap::Entry &Ent = DbgValues.getEntry(Pair.first, Idx);
512           assert(Ent.isDbgValue() && !Ent.isClosed());
513           Ent.endEntry(ClobIdx);
514         }
515       }
516 
517       LiveEntries.clear();
518       RegVars.clear();
519     }
520   }
521 }
522 
523 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
524 LLVM_DUMP_METHOD void DbgValueHistoryMap::dump() const {
525   dbgs() << "DbgValueHistoryMap:\n";
526   for (const auto &VarRangePair : *this) {
527     const InlinedEntity &Var = VarRangePair.first;
528     const Entries &Entries = VarRangePair.second;
529 
530     const DILocalVariable *LocalVar = cast<DILocalVariable>(Var.first);
531     const DILocation *Location = Var.second;
532 
533     dbgs() << " - " << LocalVar->getName() << " at ";
534 
535     if (Location)
536       dbgs() << Location->getFilename() << ":" << Location->getLine() << ":"
537              << Location->getColumn();
538     else
539       dbgs() << "<unknown location>";
540 
541     dbgs() << " --\n";
542 
543     for (const auto &E : enumerate(Entries)) {
544       const auto &Entry = E.value();
545       dbgs() << "  Entry[" << E.index() << "]: ";
546       if (Entry.isDbgValue())
547         dbgs() << "Debug value\n";
548       else
549         dbgs() << "Clobber\n";
550       dbgs() << "   Instr: " << *Entry.getInstr();
551       if (Entry.isDbgValue()) {
552         if (Entry.getEndIndex() == NoEntry)
553           dbgs() << "   - Valid until end of function\n";
554         else
555           dbgs() << "   - Closed by Entry[" << Entry.getEndIndex() << "]\n";
556       }
557       dbgs() << "\n";
558     }
559   }
560 }
561 #endif
562