1 //===- llvm/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp -------------===//
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
7 //===----------------------------------------------------------------------===//
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"
34 #define DEBUG_TYPE "dwarfdebug"
37 using EntryIndex
= DbgValueHistoryMap::EntryIndex
;
40 void InstructionOrdering::initialize(const MachineFunction
&MF
) {
41 // We give meta instructions the same ordinal as the preceding instruction
42 // because this class is written for the task of comparing positions of
43 // variable location ranges against scope ranges. To reflect what we'll see
44 // in the binary, when we look at location ranges we must consider all
45 // DBG_VALUEs between two real instructions at the same position. And a
46 // scope range which ends on a meta instruction should be considered to end
47 // at the last seen real instruction. E.g.
49 // 1 instruction p Both the variable location for x and for y start
50 // 1 DBG_VALUE for "x" after instruction p so we give them all the same
51 // 1 DBG_VALUE for "y" number. If a scope range ends at DBG_VALUE for "y",
52 // 2 instruction q we should treat it as ending after instruction p
53 // because it will be the last real instruction in the
54 // range. DBG_VALUEs at or after this position for
55 // variables declared in the scope will have no effect.
57 unsigned Position
= 0;
58 for (const MachineBasicBlock
&MBB
: MF
)
59 for (const MachineInstr
&MI
: MBB
)
60 InstNumberMap
[&MI
] = MI
.isMetaInstruction() ? Position
: ++Position
;
63 bool InstructionOrdering::isBefore(const MachineInstr
*A
,
64 const MachineInstr
*B
) const {
65 assert(A
->getParent() && B
->getParent() && "Operands must have a parent");
66 assert(A
->getMF() == B
->getMF() &&
67 "Operands must be in the same MachineFunction");
68 return InstNumberMap
.lookup(A
) < InstNumberMap
.lookup(B
);
71 bool DbgValueHistoryMap::startDbgValue(InlinedEntity Var
,
72 const MachineInstr
&MI
,
73 EntryIndex
&NewIndex
) {
74 // Instruction range should start with a DBG_VALUE instruction for the
76 assert(MI
.isDebugValue() && "not a DBG_VALUE");
77 auto &Entries
= VarEntries
[Var
];
78 if (!Entries
.empty() && Entries
.back().isDbgValue() &&
79 !Entries
.back().isClosed() &&
80 Entries
.back().getInstr()->isIdenticalTo(MI
)) {
81 LLVM_DEBUG(dbgs() << "Coalescing identical DBG_VALUE entries:\n"
82 << "\t" << Entries
.back().getInstr() << "\t" << MI
86 Entries
.emplace_back(&MI
, Entry::DbgValue
);
87 NewIndex
= Entries
.size() - 1;
91 EntryIndex
DbgValueHistoryMap::startClobber(InlinedEntity Var
,
92 const MachineInstr
&MI
) {
93 auto &Entries
= VarEntries
[Var
];
94 // If an instruction clobbers multiple registers that the variable is
95 // described by, then we may have already created a clobbering instruction.
96 if (Entries
.back().isClobber() && Entries
.back().getInstr() == &MI
)
97 return Entries
.size() - 1;
98 Entries
.emplace_back(&MI
, Entry::Clobber
);
99 return Entries
.size() - 1;
102 void DbgValueHistoryMap::Entry::endEntry(EntryIndex Index
) {
103 // For now, instruction ranges are not allowed to cross basic block
105 assert(isDbgValue() && "Setting end index for non-debug value");
106 assert(!isClosed() && "End index has already been set");
110 /// Check if the instruction range [StartMI, EndMI] intersects any instruction
111 /// range in Ranges. EndMI can be nullptr to indicate that the range is
112 /// unbounded. Assumes Ranges is ordered and disjoint. Returns true and points
113 /// to the first intersecting scope range if one exists.
114 static Optional
<ArrayRef
<InsnRange
>::iterator
>
115 intersects(const MachineInstr
*StartMI
, const MachineInstr
*EndMI
,
116 const ArrayRef
<InsnRange
> &Ranges
,
117 const InstructionOrdering
&Ordering
) {
118 for (auto RangesI
= Ranges
.begin(), RangesE
= Ranges
.end();
119 RangesI
!= RangesE
; ++RangesI
) {
120 if (EndMI
&& Ordering
.isBefore(EndMI
, RangesI
->first
))
122 if (EndMI
&& !Ordering
.isBefore(RangesI
->second
, EndMI
))
124 if (Ordering
.isBefore(StartMI
, RangesI
->second
))
130 void DbgValueHistoryMap::trimLocationRanges(
131 const MachineFunction
&MF
, LexicalScopes
&LScopes
,
132 const InstructionOrdering
&Ordering
) {
133 // The indices of the entries we're going to remove for each variable.
134 SmallVector
<EntryIndex
, 4> ToRemove
;
135 // Entry reference count for each variable. Clobbers left with no references
137 SmallVector
<int, 4> ReferenceCount
;
138 // Entries reference other entries by index. Offsets is used to remap these
139 // references if any entries are removed.
140 SmallVector
<size_t, 4> Offsets
;
142 for (auto &Record
: VarEntries
) {
143 auto &HistoryMapEntries
= Record
.second
;
144 if (HistoryMapEntries
.empty())
147 InlinedEntity Entity
= Record
.first
;
148 const DILocalVariable
*LocalVar
= cast
<DILocalVariable
>(Entity
.first
);
150 LexicalScope
*Scope
= nullptr;
151 if (const DILocation
*InlinedAt
= Entity
.second
) {
152 Scope
= LScopes
.findInlinedScope(LocalVar
->getScope(), InlinedAt
);
154 Scope
= LScopes
.findLexicalScope(LocalVar
->getScope());
155 // Ignore variables for non-inlined function level scopes. The scope
156 // ranges (from scope->getRanges()) will not include any instructions
157 // before the first one with a debug-location, which could cause us to
158 // incorrectly drop a location. We could introduce special casing for
159 // these variables, but it doesn't seem worth it because no out-of-scope
160 // locations have been observed for variables declared in function level
163 (Scope
->getScopeNode() == Scope
->getScopeNode()->getSubprogram()) &&
164 (Scope
->getScopeNode() == LocalVar
->getScope()))
168 // If there is no scope for the variable then something has probably gone
174 // Zero the reference counts.
175 ReferenceCount
.assign(HistoryMapEntries
.size(), 0);
176 // Index of the DBG_VALUE which marks the start of the current location
178 EntryIndex StartIndex
= 0;
179 ArrayRef
<InsnRange
> ScopeRanges(Scope
->getRanges());
180 for (auto EI
= HistoryMapEntries
.begin(), EE
= HistoryMapEntries
.end();
181 EI
!= EE
; ++EI
, ++StartIndex
) {
182 // Only DBG_VALUEs can open location ranges so skip anything else.
183 if (!EI
->isDbgValue())
186 // Index of the entry which closes this range.
187 EntryIndex EndIndex
= EI
->getEndIndex();
188 // If this range is closed bump the reference count of the closing entry.
189 if (EndIndex
!= NoEntry
)
190 ReferenceCount
[EndIndex
] += 1;
191 // Skip this location range if the opening entry is still referenced. It
192 // may close a location range which intersects a scope range.
193 // TODO: We could be 'smarter' and trim these kinds of ranges such that
194 // they do not leak out of the scope ranges if they partially overlap.
195 if (ReferenceCount
[StartIndex
] > 0)
198 const MachineInstr
*StartMI
= EI
->getInstr();
199 const MachineInstr
*EndMI
= EndIndex
!= NoEntry
200 ? HistoryMapEntries
[EndIndex
].getInstr()
202 // Check if the location range [StartMI, EndMI] intersects with any scope
203 // range for the variable.
204 if (auto R
= intersects(StartMI
, EndMI
, ScopeRanges
, Ordering
)) {
205 // Adjust ScopeRanges to exclude ranges which subsequent location ranges
206 // cannot possibly intersect.
207 ScopeRanges
= ArrayRef
<InsnRange
>(R
.getValue(), ScopeRanges
.end());
209 // If the location range does not intersect any scope range then the
210 // DBG_VALUE which opened this location range is usless, mark it for
212 ToRemove
.push_back(StartIndex
);
213 // Because we'll be removing this entry we need to update the reference
214 // count of the closing entry, if one exists.
215 if (EndIndex
!= NoEntry
)
216 ReferenceCount
[EndIndex
] -= 1;
220 // If there is nothing to remove then jump to next variable.
221 if (ToRemove
.empty())
224 // Mark clobbers that will no longer close any location ranges for removal.
225 for (size_t i
= 0; i
< HistoryMapEntries
.size(); ++i
)
226 if (ReferenceCount
[i
] <= 0 && HistoryMapEntries
[i
].isClobber())
227 ToRemove
.push_back(i
);
229 llvm::sort(ToRemove
);
231 // Build an offset map so we can update the EndIndex of the remaining
234 Offsets
.assign(HistoryMapEntries
.size(), 0);
235 size_t CurOffset
= 0;
236 auto ToRemoveItr
= ToRemove
.begin();
237 for (size_t EntryIdx
= *ToRemoveItr
; EntryIdx
< HistoryMapEntries
.size();
239 // Check if this is an entry which will be removed.
240 if (ToRemoveItr
!= ToRemove
.end() && *ToRemoveItr
== EntryIdx
) {
244 Offsets
[EntryIdx
] = CurOffset
;
247 // Update the EndIndex of the entries to account for those which will be
249 for (auto &Entry
: HistoryMapEntries
)
250 if (Entry
.isClosed())
251 Entry
.EndIndex
-= Offsets
[Entry
.EndIndex
];
253 // Now actually remove the entries. Iterate backwards so that our remaining
254 // ToRemove indices are valid after each erase.
255 for (EntryIndex Idx
: llvm::reverse(ToRemove
))
256 HistoryMapEntries
.erase(HistoryMapEntries
.begin() + Idx
);
260 bool DbgValueHistoryMap::hasNonEmptyLocation(const Entries
&Entries
) const {
261 for (const auto &Entry
: Entries
) {
262 if (!Entry
.isDbgValue())
265 const MachineInstr
*MI
= Entry
.getInstr();
266 assert(MI
->isDebugValue());
267 // A DBG_VALUE $noreg is an empty variable location
268 if (MI
->getOperand(0).isReg() && MI
->getOperand(0).getReg() == 0)
277 void DbgLabelInstrMap::addInstr(InlinedEntity Label
, const MachineInstr
&MI
) {
278 assert(MI
.isDebugLabel() && "not a DBG_LABEL");
279 LabelInstr
[Label
] = &MI
;
284 // Maps physreg numbers to the variables they describe.
285 using InlinedEntity
= DbgValueHistoryMap::InlinedEntity
;
286 using RegDescribedVarsMap
= std::map
<unsigned, SmallVector
<InlinedEntity
, 1>>;
288 // Keeps track of the debug value entries that are currently live for each
289 // inlined entity. As the history map entries are stored in a SmallVector, they
290 // may be moved at insertion of new entries, so store indices rather than
292 using DbgValueEntriesMap
= std::map
<InlinedEntity
, SmallSet
<EntryIndex
, 1>>;
294 } // end anonymous namespace
296 // Claim that @Var is not described by @RegNo anymore.
297 static void dropRegDescribedVar(RegDescribedVarsMap
&RegVars
, unsigned RegNo
,
299 const auto &I
= RegVars
.find(RegNo
);
300 assert(RegNo
!= 0U && I
!= RegVars
.end());
301 auto &VarSet
= I
->second
;
302 const auto &VarPos
= llvm::find(VarSet
, Var
);
303 assert(VarPos
!= VarSet
.end());
304 VarSet
.erase(VarPos
);
305 // Don't keep empty sets in a map to keep it as small as possible.
310 // Claim that @Var is now described by @RegNo.
311 static void addRegDescribedVar(RegDescribedVarsMap
&RegVars
, unsigned RegNo
,
314 auto &VarSet
= RegVars
[RegNo
];
315 assert(!is_contained(VarSet
, Var
));
316 VarSet
.push_back(Var
);
319 /// Create a clobbering entry and end all open debug value entries
320 /// for \p Var that are described by \p RegNo using that entry. Inserts into \p
321 /// FellowRegisters the set of Registers that were also used to describe \p Var
322 /// alongside \p RegNo.
323 static void clobberRegEntries(InlinedEntity Var
, unsigned RegNo
,
324 const MachineInstr
&ClobberingInstr
,
325 DbgValueEntriesMap
&LiveEntries
,
326 DbgValueHistoryMap
&HistMap
,
327 SmallVectorImpl
<Register
> &FellowRegisters
) {
328 EntryIndex ClobberIndex
= HistMap
.startClobber(Var
, ClobberingInstr
);
329 // Close all entries whose values are described by the register.
330 SmallVector
<EntryIndex
, 4> IndicesToErase
;
331 // If a given register appears in a live DBG_VALUE_LIST for Var alongside the
332 // clobbered register, and never appears in a live DBG_VALUE* for Var without
333 // the clobbered register, then it is no longer linked to the variable.
334 SmallSet
<Register
, 4> MaybeRemovedRegisters
;
335 SmallSet
<Register
, 4> KeepRegisters
;
336 for (auto Index
: LiveEntries
[Var
]) {
337 auto &Entry
= HistMap
.getEntry(Var
, Index
);
338 assert(Entry
.isDbgValue() && "Not a DBG_VALUE in LiveEntries");
339 if (Entry
.getInstr()->isDebugEntryValue())
341 if (Entry
.getInstr()->hasDebugOperandForReg(RegNo
)) {
342 IndicesToErase
.push_back(Index
);
343 Entry
.endEntry(ClobberIndex
);
344 for (auto &MO
: Entry
.getInstr()->debug_operands())
345 if (MO
.isReg() && MO
.getReg() && MO
.getReg() != RegNo
)
346 MaybeRemovedRegisters
.insert(MO
.getReg());
348 for (auto &MO
: Entry
.getInstr()->debug_operands())
349 if (MO
.isReg() && MO
.getReg())
350 KeepRegisters
.insert(MO
.getReg());
354 for (Register Reg
: MaybeRemovedRegisters
)
355 if (!KeepRegisters
.contains(Reg
))
356 FellowRegisters
.push_back(Reg
);
358 // Drop all entries that have ended.
359 for (auto Index
: IndicesToErase
)
360 LiveEntries
[Var
].erase(Index
);
363 /// Add a new debug value for \p Var. Closes all overlapping debug values.
364 static void handleNewDebugValue(InlinedEntity Var
, const MachineInstr
&DV
,
365 RegDescribedVarsMap
&RegVars
,
366 DbgValueEntriesMap
&LiveEntries
,
367 DbgValueHistoryMap
&HistMap
) {
369 if (HistMap
.startDbgValue(Var
, DV
, NewIndex
)) {
370 SmallDenseMap
<unsigned, bool, 4> TrackedRegs
;
372 // If we have created a new debug value entry, close all preceding
373 // live entries that overlap.
374 SmallVector
<EntryIndex
, 4> IndicesToErase
;
375 const DIExpression
*DIExpr
= DV
.getDebugExpression();
376 for (auto Index
: LiveEntries
[Var
]) {
377 auto &Entry
= HistMap
.getEntry(Var
, Index
);
378 assert(Entry
.isDbgValue() && "Not a DBG_VALUE in LiveEntries");
379 const MachineInstr
&DV
= *Entry
.getInstr();
380 bool Overlaps
= DIExpr
->fragmentsOverlap(DV
.getDebugExpression());
382 IndicesToErase
.push_back(Index
);
383 Entry
.endEntry(NewIndex
);
385 if (!DV
.isDebugEntryValue())
386 for (const MachineOperand
&Op
: DV
.debug_operands())
387 if (Op
.isReg() && Op
.getReg())
388 TrackedRegs
[Op
.getReg()] |= !Overlaps
;
391 // If the new debug value is described by a register, add tracking of
392 // that register if it is not already tracked.
393 if (!DV
.isDebugEntryValue()) {
394 for (const MachineOperand
&Op
: DV
.debug_operands()) {
395 if (Op
.isReg() && Op
.getReg()) {
396 Register NewReg
= Op
.getReg();
397 if (!TrackedRegs
.count(NewReg
))
398 addRegDescribedVar(RegVars
, NewReg
, Var
);
399 LiveEntries
[Var
].insert(NewIndex
);
400 TrackedRegs
[NewReg
] = true;
405 // Drop tracking of registers that are no longer used.
406 for (auto I
: TrackedRegs
)
408 dropRegDescribedVar(RegVars
, I
.first
, Var
);
410 // Drop all entries that have ended, and mark the new entry as live.
411 for (auto Index
: IndicesToErase
)
412 LiveEntries
[Var
].erase(Index
);
413 LiveEntries
[Var
].insert(NewIndex
);
417 // Terminate the location range for variables described by register at
418 // @I by inserting @ClobberingInstr to their history.
419 static void clobberRegisterUses(RegDescribedVarsMap
&RegVars
,
420 RegDescribedVarsMap::iterator I
,
421 DbgValueHistoryMap
&HistMap
,
422 DbgValueEntriesMap
&LiveEntries
,
423 const MachineInstr
&ClobberingInstr
) {
424 // Iterate over all variables described by this register and add this
425 // instruction to their history, clobbering it. All registers that also
426 // describe the clobbered variables (i.e. in variadic debug values) will have
427 // those Variables removed from their DescribedVars.
428 for (const auto &Var
: I
->second
) {
429 SmallVector
<Register
, 4> FellowRegisters
;
430 clobberRegEntries(Var
, I
->first
, ClobberingInstr
, LiveEntries
, HistMap
,
432 for (Register RegNo
: FellowRegisters
)
433 dropRegDescribedVar(RegVars
, RegNo
, Var
);
438 // Terminate the location range for variables described by register
439 // @RegNo by inserting @ClobberingInstr to their history.
440 static void clobberRegisterUses(RegDescribedVarsMap
&RegVars
, unsigned RegNo
,
441 DbgValueHistoryMap
&HistMap
,
442 DbgValueEntriesMap
&LiveEntries
,
443 const MachineInstr
&ClobberingInstr
) {
444 const auto &I
= RegVars
.find(RegNo
);
445 if (I
== RegVars
.end())
447 clobberRegisterUses(RegVars
, I
, HistMap
, LiveEntries
, ClobberingInstr
);
450 void llvm::calculateDbgEntityHistory(const MachineFunction
*MF
,
451 const TargetRegisterInfo
*TRI
,
452 DbgValueHistoryMap
&DbgValues
,
453 DbgLabelInstrMap
&DbgLabels
) {
454 const TargetLowering
*TLI
= MF
->getSubtarget().getTargetLowering();
455 Register SP
= TLI
->getStackPointerRegisterToSaveRestore();
456 Register FrameReg
= TRI
->getFrameRegister(*MF
);
457 RegDescribedVarsMap RegVars
;
458 DbgValueEntriesMap LiveEntries
;
459 for (const auto &MBB
: *MF
) {
460 for (const auto &MI
: MBB
) {
461 if (MI
.isDebugValue()) {
462 assert(MI
.getNumOperands() > 1 && "Invalid DBG_VALUE instruction!");
463 // Use the base variable (without any DW_OP_piece expressions)
464 // as index into History. The full variables including the
465 // piece expressions are attached to the MI.
466 const DILocalVariable
*RawVar
= MI
.getDebugVariable();
467 assert(RawVar
->isValidLocationForIntrinsic(MI
.getDebugLoc()) &&
468 "Expected inlined-at fields to agree");
469 InlinedEntity
Var(RawVar
, MI
.getDebugLoc()->getInlinedAt());
471 handleNewDebugValue(Var
, MI
, RegVars
, LiveEntries
, DbgValues
);
472 } else if (MI
.isDebugLabel()) {
473 assert(MI
.getNumOperands() == 1 && "Invalid DBG_LABEL instruction!");
474 const DILabel
*RawLabel
= MI
.getDebugLabel();
475 assert(RawLabel
->isValidLocationForIntrinsic(MI
.getDebugLoc()) &&
476 "Expected inlined-at fields to agree");
477 // When collecting debug information for labels, there is no MCSymbol
478 // generated for it. So, we keep MachineInstr in DbgLabels in order
479 // to query MCSymbol afterward.
480 InlinedEntity
L(RawLabel
, MI
.getDebugLoc()->getInlinedAt());
481 DbgLabels
.addInstr(L
, MI
);
484 // Meta Instructions have no output and do not change any values and so
485 // can be safely ignored.
486 if (MI
.isMetaInstruction())
489 // Not a DBG_VALUE instruction. It may clobber registers which describe
491 for (const MachineOperand
&MO
: MI
.operands()) {
492 if (MO
.isReg() && MO
.isDef() && MO
.getReg()) {
493 // Ignore call instructions that claim to clobber SP. The AArch64
494 // backend does this for aggregate function arguments.
495 if (MI
.isCall() && MO
.getReg() == SP
)
497 // If this is a virtual register, only clobber it since it doesn't
499 if (Register::isVirtualRegister(MO
.getReg()))
500 clobberRegisterUses(RegVars
, MO
.getReg(), DbgValues
, LiveEntries
,
502 // If this is a register def operand, it may end a debug value
503 // range. Ignore frame-register defs in the epilogue and prologue,
504 // we expect debuggers to understand that stack-locations are
505 // invalid outside of the function body.
506 else if (MO
.getReg() != FrameReg
||
507 (!MI
.getFlag(MachineInstr::FrameDestroy
) &&
508 !MI
.getFlag(MachineInstr::FrameSetup
))) {
509 for (MCRegAliasIterator
AI(MO
.getReg(), TRI
, true); AI
.isValid();
511 clobberRegisterUses(RegVars
, *AI
, DbgValues
, LiveEntries
, MI
);
513 } else if (MO
.isRegMask()) {
514 // If this is a register mask operand, clobber all debug values in
516 SmallVector
<unsigned, 32> RegsToClobber
;
517 // Don't consider SP to be clobbered by register masks.
518 for (auto It
: RegVars
) {
519 unsigned int Reg
= It
.first
;
520 if (Reg
!= SP
&& Register::isPhysicalRegister(Reg
) &&
521 MO
.clobbersPhysReg(Reg
))
522 RegsToClobber
.push_back(Reg
);
525 for (unsigned Reg
: RegsToClobber
) {
526 clobberRegisterUses(RegVars
, Reg
, DbgValues
, LiveEntries
, MI
);
532 // Make sure locations for all variables are valid only until the end of
533 // the basic block (unless it's the last basic block, in which case let
534 // their liveness run off to the end of the function).
535 if (!MBB
.empty() && &MBB
!= &MF
->back()) {
536 // Iterate over all variables that have open debug values.
537 for (auto &Pair
: LiveEntries
) {
538 if (Pair
.second
.empty())
541 // Create a clobbering entry.
542 EntryIndex ClobIdx
= DbgValues
.startClobber(Pair
.first
, MBB
.back());
545 for (EntryIndex Idx
: Pair
.second
) {
546 DbgValueHistoryMap::Entry
&Ent
= DbgValues
.getEntry(Pair
.first
, Idx
);
547 assert(Ent
.isDbgValue() && !Ent
.isClosed());
548 Ent
.endEntry(ClobIdx
);
558 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
559 LLVM_DUMP_METHOD
void DbgValueHistoryMap::dump() const {
560 dbgs() << "DbgValueHistoryMap:\n";
561 for (const auto &VarRangePair
: *this) {
562 const InlinedEntity
&Var
= VarRangePair
.first
;
563 const Entries
&Entries
= VarRangePair
.second
;
565 const DILocalVariable
*LocalVar
= cast
<DILocalVariable
>(Var
.first
);
566 const DILocation
*Location
= Var
.second
;
568 dbgs() << " - " << LocalVar
->getName() << " at ";
571 dbgs() << Location
->getFilename() << ":" << Location
->getLine() << ":"
572 << Location
->getColumn();
574 dbgs() << "<unknown location>";
578 for (const auto &E
: enumerate(Entries
)) {
579 const auto &Entry
= E
.value();
580 dbgs() << " Entry[" << E
.index() << "]: ";
581 if (Entry
.isDbgValue())
582 dbgs() << "Debug value\n";
584 dbgs() << "Clobber\n";
585 dbgs() << " Instr: " << *Entry
.getInstr();
586 if (Entry
.isDbgValue()) {
587 if (Entry
.getEndIndex() == NoEntry
)
588 dbgs() << " - Valid until end of function\n";
590 dbgs() << " - Closed by Entry[" << Entry
.getEndIndex() << "]\n";