LLVM  16.0.0git
DbgEntityHistoryCalculator.cpp
Go to the documentation of this file.
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 
10 #include "llvm/ADT/Optional.h"
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/ADT/SmallSet.h"
13 #include "llvm/ADT/SmallVector.h"
23 #include "llvm/IR/DebugLoc.h"
24 #include "llvm/MC/MCRegisterInfo.h"
25 #include "llvm/Support/Debug.h"
27 #include <cassert>
28 #include <map>
29 #include <utility>
30 
31 using namespace llvm;
32 
33 #define DEBUG_TYPE "dwarfdebug"
34 
35 namespace {
36 using EntryIndex = DbgValueHistoryMap::EntryIndex;
37 }
38 
40  // We give meta instructions the same ordinal as the preceding instruction
41  // because this class is written for the task of comparing positions of
42  // variable location ranges against scope ranges. To reflect what we'll see
43  // in the binary, when we look at location ranges we must consider all
44  // DBG_VALUEs between two real instructions at the same position. And a
45  // scope range which ends on a meta instruction should be considered to end
46  // at the last seen real instruction. E.g.
47  //
48  // 1 instruction p Both the variable location for x and for y start
49  // 1 DBG_VALUE for "x" after instruction p so we give them all the same
50  // 1 DBG_VALUE for "y" number. If a scope range ends at DBG_VALUE for "y",
51  // 2 instruction q we should treat it as ending after instruction p
52  // because it will be the last real instruction in the
53  // range. DBG_VALUEs at or after this position for
54  // variables declared in the scope will have no effect.
55  clear();
56  unsigned Position = 0;
57  for (const MachineBasicBlock &MBB : MF)
58  for (const MachineInstr &MI : MBB)
59  InstNumberMap[&MI] = MI.isMetaInstruction() ? Position : ++Position;
60 }
61 
63  const MachineInstr *B) const {
64  assert(A->getParent() && B->getParent() && "Operands must have a parent");
65  assert(A->getMF() == B->getMF() &&
66  "Operands must be in the same MachineFunction");
67  return InstNumberMap.lookup(A) < InstNumberMap.lookup(B);
68 }
69 
71  const MachineInstr &MI,
72  EntryIndex &NewIndex) {
73  // Instruction range should start with a DBG_VALUE instruction for the
74  // variable.
75  assert(MI.isDebugValue() && "not a DBG_VALUE");
76  auto &Entries = VarEntries[Var];
77  if (!Entries.empty() && Entries.back().isDbgValue() &&
78  !Entries.back().isClosed() &&
79  Entries.back().getInstr()->isIdenticalTo(MI)) {
80  LLVM_DEBUG(dbgs() << "Coalescing identical DBG_VALUE entries:\n"
81  << "\t" << Entries.back().getInstr() << "\t" << MI
82  << "\n");
83  return false;
84  }
86  NewIndex = Entries.size() - 1;
87  return true;
88 }
89 
91  const MachineInstr &MI) {
92  auto &Entries = VarEntries[Var];
93  // If an instruction clobbers multiple registers that the variable is
94  // described by, then we may have already created a clobbering instruction.
95  if (Entries.back().isClobber() && Entries.back().getInstr() == &MI)
96  return Entries.size() - 1;
98  return Entries.size() - 1;
99 }
100 
102  // For now, instruction ranges are not allowed to cross basic block
103  // boundaries.
104  assert(isDbgValue() && "Setting end index for non-debug value");
105  assert(!isClosed() && "End index has already been set");
106  EndIndex = Index;
107 }
108 
109 /// Check if the instruction range [StartMI, EndMI] intersects any instruction
110 /// range in Ranges. EndMI can be nullptr to indicate that the range is
111 /// unbounded. Assumes Ranges is ordered and disjoint. Returns true and points
112 /// to the first intersecting scope range if one exists.
114 intersects(const MachineInstr *StartMI, const MachineInstr *EndMI,
115  const ArrayRef<InsnRange> &Ranges,
116  const InstructionOrdering &Ordering) {
117  for (auto RangesI = Ranges.begin(), RangesE = Ranges.end();
118  RangesI != RangesE; ++RangesI) {
119  if (EndMI && Ordering.isBefore(EndMI, RangesI->first))
120  return None;
121  if (EndMI && !Ordering.isBefore(RangesI->second, EndMI))
122  return RangesI;
123  if (Ordering.isBefore(StartMI, RangesI->second))
124  return RangesI;
125  }
126  return None;
127 }
128 
130  const MachineFunction &MF, LexicalScopes &LScopes,
131  const InstructionOrdering &Ordering) {
132  // The indices of the entries we're going to remove for each variable.
134  // Entry reference count for each variable. Clobbers left with no references
135  // will be removed.
136  SmallVector<int, 4> ReferenceCount;
137  // Entries reference other entries by index. Offsets is used to remap these
138  // references if any entries are removed.
140 
141  for (auto &Record : VarEntries) {
142  auto &HistoryMapEntries = Record.second;
143  if (HistoryMapEntries.empty())
144  continue;
145 
146  InlinedEntity Entity = Record.first;
147  const DILocalVariable *LocalVar = cast<DILocalVariable>(Entity.first);
148 
149  LexicalScope *Scope = nullptr;
150  if (const DILocation *InlinedAt = Entity.second) {
151  Scope = LScopes.findInlinedScope(LocalVar->getScope(), InlinedAt);
152  } else {
153  Scope = LScopes.findLexicalScope(LocalVar->getScope());
154  // Ignore variables for non-inlined function level scopes. The scope
155  // ranges (from scope->getRanges()) will not include any instructions
156  // before the first one with a debug-location, which could cause us to
157  // incorrectly drop a location. We could introduce special casing for
158  // these variables, but it doesn't seem worth it because no out-of-scope
159  // locations have been observed for variables declared in function level
160  // scopes.
161  if (Scope &&
162  (Scope->getScopeNode() == Scope->getScopeNode()->getSubprogram()) &&
163  (Scope->getScopeNode() == LocalVar->getScope()))
164  continue;
165  }
166 
167  // If there is no scope for the variable then something has probably gone
168  // wrong.
169  if (!Scope)
170  continue;
171 
172  ToRemove.clear();
173  // Zero the reference counts.
174  ReferenceCount.assign(HistoryMapEntries.size(), 0);
175  // Index of the DBG_VALUE which marks the start of the current location
176  // range.
177  EntryIndex StartIndex = 0;
178  ArrayRef<InsnRange> ScopeRanges(Scope->getRanges());
179  for (auto EI = HistoryMapEntries.begin(), EE = HistoryMapEntries.end();
180  EI != EE; ++EI, ++StartIndex) {
181  // Only DBG_VALUEs can open location ranges so skip anything else.
182  if (!EI->isDbgValue())
183  continue;
184 
185  // Index of the entry which closes this range.
186  EntryIndex EndIndex = EI->getEndIndex();
187  // If this range is closed bump the reference count of the closing entry.
188  if (EndIndex != NoEntry)
189  ReferenceCount[EndIndex] += 1;
190  // Skip this location range if the opening entry is still referenced. It
191  // may close a location range which intersects a scope range.
192  // TODO: We could be 'smarter' and trim these kinds of ranges such that
193  // they do not leak out of the scope ranges if they partially overlap.
194  if (ReferenceCount[StartIndex] > 0)
195  continue;
196 
197  const MachineInstr *StartMI = EI->getInstr();
198  const MachineInstr *EndMI = EndIndex != NoEntry
199  ? HistoryMapEntries[EndIndex].getInstr()
200  : nullptr;
201  // Check if the location range [StartMI, EndMI] intersects with any scope
202  // range for the variable.
203  if (auto R = intersects(StartMI, EndMI, ScopeRanges, Ordering)) {
204  // Adjust ScopeRanges to exclude ranges which subsequent location ranges
205  // cannot possibly intersect.
206  ScopeRanges = ArrayRef<InsnRange>(*R, ScopeRanges.end());
207  } else {
208  // If the location range does not intersect any scope range then the
209  // DBG_VALUE which opened this location range is usless, mark it for
210  // removal.
211  ToRemove.push_back(StartIndex);
212  // Because we'll be removing this entry we need to update the reference
213  // count of the closing entry, if one exists.
214  if (EndIndex != NoEntry)
215  ReferenceCount[EndIndex] -= 1;
216  }
217  }
218 
219  // If there is nothing to remove then jump to next variable.
220  if (ToRemove.empty())
221  continue;
222 
223  // Mark clobbers that will no longer close any location ranges for removal.
224  for (size_t i = 0; i < HistoryMapEntries.size(); ++i)
225  if (ReferenceCount[i] <= 0 && HistoryMapEntries[i].isClobber())
226  ToRemove.push_back(i);
227 
229 
230  // Build an offset map so we can update the EndIndex of the remaining
231  // entries.
232  // Zero the offsets.
233  Offsets.assign(HistoryMapEntries.size(), 0);
234  size_t CurOffset = 0;
235  auto ToRemoveItr = ToRemove.begin();
236  for (size_t EntryIdx = *ToRemoveItr; EntryIdx < HistoryMapEntries.size();
237  ++EntryIdx) {
238  // Check if this is an entry which will be removed.
239  if (ToRemoveItr != ToRemove.end() && *ToRemoveItr == EntryIdx) {
240  ++ToRemoveItr;
241  ++CurOffset;
242  }
243  Offsets[EntryIdx] = CurOffset;
244  }
245 
246  // Update the EndIndex of the entries to account for those which will be
247  // removed.
248  for (auto &Entry : HistoryMapEntries)
249  if (Entry.isClosed())
250  Entry.EndIndex -= Offsets[Entry.EndIndex];
251 
252  // Now actually remove the entries. Iterate backwards so that our remaining
253  // ToRemove indices are valid after each erase.
254  for (EntryIndex Idx : llvm::reverse(ToRemove))
255  HistoryMapEntries.erase(HistoryMapEntries.begin() + Idx);
256  }
257 }
258 
260  for (const auto &Entry : Entries) {
261  if (!Entry.isDbgValue())
262  continue;
263 
264  const MachineInstr *MI = Entry.getInstr();
265  assert(MI->isDebugValue());
266  // A DBG_VALUE $noreg is an empty variable location
267  if (MI->getOperand(0).isReg() && MI->getOperand(0).getReg() == 0)
268  continue;
269 
270  return true;
271  }
272 
273  return false;
274 }
275 
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.
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. Inserts into \p
320 /// FellowRegisters the set of Registers that were also used to describe \p Var
321 /// alongside \p RegNo.
322 static void clobberRegEntries(InlinedEntity Var, unsigned RegNo,
323  const MachineInstr &ClobberingInstr,
324  DbgValueEntriesMap &LiveEntries,
325  DbgValueHistoryMap &HistMap,
326  SmallVectorImpl<Register> &FellowRegisters) {
327  EntryIndex ClobberIndex = HistMap.startClobber(Var, ClobberingInstr);
328  // Close all entries whose values are described by the register.
329  SmallVector<EntryIndex, 4> IndicesToErase;
330  // If a given register appears in a live DBG_VALUE_LIST for Var alongside the
331  // clobbered register, and never appears in a live DBG_VALUE* for Var without
332  // the clobbered register, then it is no longer linked to the variable.
333  SmallSet<Register, 4> MaybeRemovedRegisters;
334  SmallSet<Register, 4> KeepRegisters;
335  for (auto Index : LiveEntries[Var]) {
336  auto &Entry = HistMap.getEntry(Var, Index);
337  assert(Entry.isDbgValue() && "Not a DBG_VALUE in LiveEntries");
338  if (Entry.getInstr()->isDebugEntryValue())
339  continue;
340  if (Entry.getInstr()->hasDebugOperandForReg(RegNo)) {
341  IndicesToErase.push_back(Index);
342  Entry.endEntry(ClobberIndex);
343  for (const auto &MO : Entry.getInstr()->debug_operands())
344  if (MO.isReg() && MO.getReg() && MO.getReg() != RegNo)
345  MaybeRemovedRegisters.insert(MO.getReg());
346  } else {
347  for (const auto &MO : Entry.getInstr()->debug_operands())
348  if (MO.isReg() && MO.getReg())
349  KeepRegisters.insert(MO.getReg());
350  }
351  }
352 
353  for (Register Reg : MaybeRemovedRegisters)
354  if (!KeepRegisters.contains(Reg))
355  FellowRegisters.push_back(Reg);
356 
357  // Drop all entries that have ended.
358  for (auto Index : IndicesToErase)
359  LiveEntries[Var].erase(Index);
360 }
361 
362 /// Add a new debug value for \p Var. Closes all overlapping debug values.
363 static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV,
364  RegDescribedVarsMap &RegVars,
365  DbgValueEntriesMap &LiveEntries,
366  DbgValueHistoryMap &HistMap) {
367  EntryIndex NewIndex;
368  if (HistMap.startDbgValue(Var, DV, NewIndex)) {
370 
371  // If we have created a new debug value entry, close all preceding
372  // live entries that overlap.
373  SmallVector<EntryIndex, 4> IndicesToErase;
374  const DIExpression *DIExpr = DV.getDebugExpression();
375  for (auto Index : LiveEntries[Var]) {
376  auto &Entry = HistMap.getEntry(Var, Index);
377  assert(Entry.isDbgValue() && "Not a DBG_VALUE in LiveEntries");
378  const MachineInstr &DV = *Entry.getInstr();
379  bool Overlaps = DIExpr->fragmentsOverlap(DV.getDebugExpression());
380  if (Overlaps) {
381  IndicesToErase.push_back(Index);
382  Entry.endEntry(NewIndex);
383  }
384  if (!DV.isDebugEntryValue())
385  for (const MachineOperand &Op : DV.debug_operands())
386  if (Op.isReg() && Op.getReg())
387  TrackedRegs[Op.getReg()] |= !Overlaps;
388  }
389 
390  // If the new debug value is described by a register, add tracking of
391  // that register if it is not already tracked.
392  if (!DV.isDebugEntryValue()) {
393  for (const MachineOperand &Op : DV.debug_operands()) {
394  if (Op.isReg() && Op.getReg()) {
395  Register NewReg = Op.getReg();
396  if (!TrackedRegs.count(NewReg))
397  addRegDescribedVar(RegVars, NewReg, Var);
398  LiveEntries[Var].insert(NewIndex);
399  TrackedRegs[NewReg] = true;
400  }
401  }
402  }
403 
404  // Drop tracking of registers that are no longer used.
405  for (auto I : TrackedRegs)
406  if (!I.second)
407  dropRegDescribedVar(RegVars, I.first, Var);
408 
409  // Drop all entries that have ended, and mark the new entry as live.
410  for (auto Index : IndicesToErase)
411  LiveEntries[Var].erase(Index);
412  LiveEntries[Var].insert(NewIndex);
413  }
414 }
415 
416 // Terminate the location range for variables described by register at
417 // @I by inserting @ClobberingInstr to their history.
418 static void clobberRegisterUses(RegDescribedVarsMap &RegVars,
419  RegDescribedVarsMap::iterator I,
420  DbgValueHistoryMap &HistMap,
421  DbgValueEntriesMap &LiveEntries,
422  const MachineInstr &ClobberingInstr) {
423  // Iterate over all variables described by this register and add this
424  // instruction to their history, clobbering it. All registers that also
425  // describe the clobbered variables (i.e. in variadic debug values) will have
426  // those Variables removed from their DescribedVars.
427  for (const auto &Var : I->second) {
428  SmallVector<Register, 4> FellowRegisters;
429  clobberRegEntries(Var, I->first, ClobberingInstr, LiveEntries, HistMap,
430  FellowRegisters);
431  for (Register RegNo : FellowRegisters)
432  dropRegDescribedVar(RegVars, RegNo, Var);
433  }
434  RegVars.erase(I);
435 }
436 
437 // Terminate the location range for variables described by register
438 // @RegNo by inserting @ClobberingInstr to their history.
439 static void clobberRegisterUses(RegDescribedVarsMap &RegVars, unsigned RegNo,
440  DbgValueHistoryMap &HistMap,
441  DbgValueEntriesMap &LiveEntries,
442  const MachineInstr &ClobberingInstr) {
443  const auto &I = RegVars.find(RegNo);
444  if (I == RegVars.end())
445  return;
446  clobberRegisterUses(RegVars, I, HistMap, LiveEntries, ClobberingInstr);
447 }
448 
450  const TargetRegisterInfo *TRI,
451  DbgValueHistoryMap &DbgValues,
452  DbgLabelInstrMap &DbgLabels) {
453  const TargetLowering *TLI = MF->getSubtarget().getTargetLowering();
455  Register FrameReg = TRI->getFrameRegister(*MF);
456  RegDescribedVarsMap RegVars;
457  DbgValueEntriesMap LiveEntries;
458  for (const auto &MBB : *MF) {
459  for (const auto &MI : MBB) {
460  if (MI.isDebugValue()) {
461  assert(MI.getNumOperands() > 1 && "Invalid DBG_VALUE instruction!");
462  // Use the base variable (without any DW_OP_piece expressions)
463  // as index into History. The full variables including the
464  // piece expressions are attached to the MI.
465  const DILocalVariable *RawVar = MI.getDebugVariable();
466  assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
467  "Expected inlined-at fields to agree");
468  InlinedEntity Var(RawVar, MI.getDebugLoc()->getInlinedAt());
469 
470  handleNewDebugValue(Var, MI, RegVars, LiveEntries, DbgValues);
471  } else if (MI.isDebugLabel()) {
472  assert(MI.getNumOperands() == 1 && "Invalid DBG_LABEL instruction!");
473  const DILabel *RawLabel = MI.getDebugLabel();
474  assert(RawLabel->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
475  "Expected inlined-at fields to agree");
476  // When collecting debug information for labels, there is no MCSymbol
477  // generated for it. So, we keep MachineInstr in DbgLabels in order
478  // to query MCSymbol afterward.
479  InlinedEntity L(RawLabel, MI.getDebugLoc()->getInlinedAt());
480  DbgLabels.addInstr(L, MI);
481  }
482 
483  // Meta Instructions have no output and do not change any values and so
484  // can be safely ignored.
485  if (MI.isMetaInstruction())
486  continue;
487 
488  // Not a DBG_VALUE instruction. It may clobber registers which describe
489  // some variables.
490  for (const MachineOperand &MO : MI.operands()) {
491  if (MO.isReg() && MO.isDef() && MO.getReg()) {
492  // Ignore call instructions that claim to clobber SP. The AArch64
493  // backend does this for aggregate function arguments.
494  if (MI.isCall() && MO.getReg() == SP)
495  continue;
496  // If this is a virtual register, only clobber it since it doesn't
497  // have aliases.
498  if (Register::isVirtualRegister(MO.getReg()))
499  clobberRegisterUses(RegVars, MO.getReg(), DbgValues, LiveEntries,
500  MI);
501  // If this is a register def operand, it may end a debug value
502  // range. Ignore frame-register defs in the epilogue and prologue,
503  // we expect debuggers to understand that stack-locations are
504  // invalid outside of the function body.
505  else if (MO.getReg() != FrameReg ||
506  (!MI.getFlag(MachineInstr::FrameDestroy) &&
507  !MI.getFlag(MachineInstr::FrameSetup))) {
508  for (MCRegAliasIterator AI(MO.getReg(), TRI, true); AI.isValid();
509  ++AI)
510  clobberRegisterUses(RegVars, *AI, DbgValues, LiveEntries, MI);
511  }
512  } else if (MO.isRegMask()) {
513  // If this is a register mask operand, clobber all debug values in
514  // non-CSRs.
515  SmallVector<unsigned, 32> RegsToClobber;
516  // Don't consider SP to be clobbered by register masks.
517  for (auto It : RegVars) {
518  unsigned int Reg = It.first;
519  if (Reg != SP && Register::isPhysicalRegister(Reg) &&
520  MO.clobbersPhysReg(Reg))
521  RegsToClobber.push_back(Reg);
522  }
523 
524  for (unsigned Reg : RegsToClobber) {
525  clobberRegisterUses(RegVars, Reg, DbgValues, LiveEntries, MI);
526  }
527  }
528  } // End MO loop.
529  } // End instr loop.
530 
531  // Make sure locations for all variables are valid only until the end of
532  // the basic block (unless it's the last basic block, in which case let
533  // their liveness run off to the end of the function).
534  if (!MBB.empty() && &MBB != &MF->back()) {
535  // Iterate over all variables that have open debug values.
536  for (auto &Pair : LiveEntries) {
537  if (Pair.second.empty())
538  continue;
539 
540  // Create a clobbering entry.
541  EntryIndex ClobIdx = DbgValues.startClobber(Pair.first, MBB.back());
542 
543  // End all entries.
544  for (EntryIndex Idx : Pair.second) {
545  DbgValueHistoryMap::Entry &Ent = DbgValues.getEntry(Pair.first, Idx);
546  assert(Ent.isDbgValue() && !Ent.isClosed());
547  Ent.endEntry(ClobIdx);
548  }
549  }
550 
551  LiveEntries.clear();
552  RegVars.clear();
553  }
554  }
555 }
556 
557 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
559  dbgs() << "DbgValueHistoryMap:\n";
560  for (const auto &VarRangePair : *this) {
561  const InlinedEntity &Var = VarRangePair.first;
562  const Entries &Entries = VarRangePair.second;
563 
564  const DILocalVariable *LocalVar = cast<DILocalVariable>(Var.first);
565  const DILocation *Location = Var.second;
566 
567  dbgs() << " - " << LocalVar->getName() << " at ";
568 
569  if (Location)
570  dbgs() << Location->getFilename() << ":" << Location->getLine() << ":"
571  << Location->getColumn();
572  else
573  dbgs() << "<unknown location>";
574 
575  dbgs() << " --\n";
576 
577  for (const auto &E : enumerate(Entries)) {
578  const auto &Entry = E.value();
579  dbgs() << " Entry[" << E.index() << "]: ";
580  if (Entry.isDbgValue())
581  dbgs() << "Debug value\n";
582  else
583  dbgs() << "Clobber\n";
584  dbgs() << " Instr: " << *Entry.getInstr();
585  if (Entry.isDbgValue()) {
586  if (Entry.getEndIndex() == NoEntry)
587  dbgs() << " - Valid until end of function\n";
588  else
589  dbgs() << " - Closed by Entry[" << Entry.getEndIndex() << "]\n";
590  }
591  dbgs() << "\n";
592  }
593  }
594 }
595 #endif
i
i
Definition: README.txt:29
llvm::InstructionOrdering::initialize
void initialize(const MachineFunction &MF)
Definition: DbgEntityHistoryCalculator.cpp:39
llvm::TargetLoweringBase::getStackPointerRegisterToSaveRestore
Register getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
Definition: TargetLowering.h:1823
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:108
MachineInstr.h
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:492
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::SmallVectorImpl::erase
iterator erase(const_iterator CI)
Definition: SmallVector.h:741
Optional.h
llvm::DbgLabelInstrMap
For each inlined instance of a source-level label, keep the corresponding DBG_LABEL instruction.
Definition: DbgEntityHistoryCalculator.h:132
DebugInfoMetadata.h
llvm::MachineInstr::debug_operands
iterator_range< mop_iterator > debug_operands()
Returns a range over all operands that are used to determine the variable location for this DBG_VALUE...
Definition: MachineInstr.h:663
llvm::DbgValueHistoryMap::Entry
Specifies a change in a variable's debug value history.
Definition: DbgEntityHistoryCalculator.h:72
llvm::lltok::LocalVar
@ LocalVar
Definition: LLToken.h:440
llvm::SmallVector< Entry, 4 >
llvm::LexicalScope
LexicalScope - This class is used to track scope information.
Definition: LexicalScopes.h:44
llvm::enumerate
detail::enumerator< R > enumerate(R &&TheRange)
Given an input range, returns a new range whose values are are pair (A,B) such that A is the 0-based ...
Definition: STLExtras.h:2238
ToRemove
ReachingDefAnalysis InstSet & ToRemove
Definition: ARMLowOverheadLoops.cpp:547
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
llvm::DbgValueHistoryMap::EntryIndex
size_t EntryIndex
Index in the entry vector.
Definition: DbgEntityHistoryCalculator.h:49
llvm::SmallDenseMap
Definition: DenseMap.h:880
intersects
static Optional< ArrayRef< InsnRange >::iterator > intersects(const MachineInstr *StartMI, const MachineInstr *EndMI, const ArrayRef< InsnRange > &Ranges, const InstructionOrdering &Ordering)
Check if the instruction range [StartMI, EndMI] intersects any instruction range in Ranges.
Definition: DbgEntityHistoryCalculator.cpp:114
MachineBasicBlock.h
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:237
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1595
llvm::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:136
llvm::Optional
Definition: APInt.h:33
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::count
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:145
STLExtras.h
llvm::MachineBasicBlock::back
MachineInstr & back()
Definition: MachineBasicBlock.h:285
llvm::DIExpression
DWARF expression.
Definition: DebugInfoMetadata.h:2596
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1628
llvm::DbgValueHistoryMap::startDbgValue
bool startDbgValue(InlinedEntity Var, const MachineInstr &MI, EntryIndex &NewIndex)
Definition: DbgEntityHistoryCalculator.cpp:70
size_t
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
llvm::DbgValueHistoryMap::Entry::getEndIndex
EntryIndex getEndIndex() const
Definition: DbgEntityHistoryCalculator.h:82
llvm::MachineInstr::FrameDestroy
@ FrameDestroy
Definition: MachineInstr.h:86
llvm::DILabel::isValidLocationForIntrinsic
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this label.
Definition: DebugInfoMetadata.h:3242
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::DbgValueHistoryMap::Entry::getInstr
const MachineInstr * getInstr() const
Definition: DbgEntityHistoryCalculator.h:81
TargetLowering.h
llvm::DbgValueHistoryMap::Entry::isClosed
bool isClosed() const
Definition: DbgEntityHistoryCalculator.h:87
llvm::DbgValueHistoryMap::Entry::isDbgValue
bool isDbgValue() const
Definition: DbgEntityHistoryCalculator.h:86
llvm::DILocalVariable
Local variable.
Definition: DebugInfoMetadata.h:3096
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::TargetLowering
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Definition: TargetLowering.h:3486
llvm::Register::isPhysicalRegister
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
Definition: Register.h:65
DbgEntityHistoryCalculator.h
llvm::calculateDbgEntityHistory
void calculateDbgEntityHistory(const MachineFunction *MF, const TargetRegisterInfo *TRI, DbgValueHistoryMap &DbgValues, DbgLabelInstrMap &DbgLabels)
Definition: DbgEntityHistoryCalculator.cpp:449
llvm::InstructionOrdering::isBefore
bool isBefore(const MachineInstr *A, const MachineInstr *B) const
Check if instruction A comes before B, where A and B both belong to the MachineFunction passed to ini...
Definition: DbgEntityHistoryCalculator.cpp:62
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:48
llvm::MachineInstr::FrameSetup
@ FrameSetup
Definition: MachineInstr.h:84
llvm::DbgValueHistoryMap::Entry::Clobber
@ Clobber
Definition: DbgEntityHistoryCalculator.h:76
LexicalScopes.h
llvm::DbgValueHistoryMap::InlinedEntity
std::pair< const DINode *, const DILocation * > InlinedEntity
Definition: DbgEntityHistoryCalculator.h:96
llvm::DILocalVariable::isValidLocationForIntrinsic
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this variable.
Definition: DebugInfoMetadata.h:3175
DebugLoc.h
llvm::DbgValueHistoryMap::hasNonEmptyLocation
bool hasNonEmptyLocation(const Entries &Entries) const
Test whether a vector of entries features any non-empty locations.
Definition: DbgEntityHistoryCalculator.cpp:259
llvm::InstructionOrdering
Record instruction ordering so we can query their relative positions within a function.
Definition: DbgEntityHistoryCalculator.h:30
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1657
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:657
llvm::DbgValueHistoryMap::startClobber
EntryIndex startClobber(InlinedEntity Var, const MachineInstr &MI)
Definition: DbgEntityHistoryCalculator.cpp:90
llvm::DbgValueHistoryMap::dump
LLVM_DUMP_METHOD void dump() const
Definition: DbgEntityHistoryCalculator.cpp:558
handleNewDebugValue
static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV, RegDescribedVarsMap &RegVars, DbgValueEntriesMap &LiveEntries, DbgValueHistoryMap &HistMap)
Add a new debug value for Var. Closes all overlapping debug values.
Definition: DbgEntityHistoryCalculator.cpp:363
llvm::MachineInstr::getDebugExpression
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
Definition: MachineInstr.cpp:866
Index
uint32_t Index
Definition: ELFObjHandler.cpp:82
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:66
llvm::find
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1729
llvm::InstructionOrdering::clear
void clear()
Definition: DbgEntityHistoryCalculator.h:33
llvm::TargetRegisterInfo::getFrameRegister
virtual Register getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
llvm::DbgValueHistoryMap::NoEntry
static const EntryIndex NoEntry
Special value to indicate that an entry is valid until the end of the function.
Definition: DbgEntityHistoryCalculator.h:53
I
#define I(x, y, z)
Definition: MD5.cpp:58
MCRegisterInfo.h
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:1843
llvm::Register::isVirtualRegister
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
Definition: Register.h:71
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::DbgValueHistoryMap::Entry::endEntry
void endEntry(EntryIndex EndIndex)
Definition: DbgEntityHistoryCalculator.cpp:101
llvm::DbgValueHistoryMap::getEntry
Entry & getEntry(InlinedEntity Var, EntryIndex Index)
Definition: DbgEntityHistoryCalculator.h:107
llvm::Record
Definition: Record.h:1573
llvm::DbgValueHistoryMap::trimLocationRanges
void trimLocationRanges(const MachineFunction &MF, LexicalScopes &LScopes, const InstructionOrdering &Ordering)
Drop location ranges which exist entirely outside each variable's scope.
Definition: DbgEntityHistoryCalculator.cpp:129
llvm::MachineFunction
Definition: MachineFunction.h:257
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::DbgValueHistoryMap::Entry::DbgValue
@ DbgValue
Definition: DbgEntityHistoryCalculator.h:76
TargetSubtargetInfo.h
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::DbgValueHistoryMap
For each user variable, keep a list of instruction ranges where this variable is accessible.
Definition: DbgEntityHistoryCalculator.h:46
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::None
constexpr std::nullopt_t None
Definition: None.h:27
llvm::DbgLabelInstrMap::addInstr
void addInstr(InlinedEntity Label, const MachineInstr &MI)
Definition: DbgEntityHistoryCalculator.cpp:276
llvm::SmallVectorImpl::assign
void assign(size_type NumElts, ValueParamT Elt)
Definition: SmallVector.h:708
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:348
llvm::LexicalScopes::findInlinedScope
LexicalScope * findInlinedScope(const DILocalScope *N, const DILocation *IA)
findInlinedScope - Find an inlined scope for the given scope/inlined-at.
Definition: LexicalScopes.h:186
llvm::LexicalScopes::findLexicalScope
LexicalScope * findLexicalScope(const DILocation *DL)
findLexicalScope - Find lexical scope, either regular or inlined, for the given DebugLoc.
Definition: LexicalScopes.cpp:124
llvm::MachineInstr::isDebugEntryValue
bool isDebugEntryValue() const
A DBG_VALUE is an entry value iff its debug expression contains the DW_OP_LLVM_entry_value operation.
Definition: MachineInstr.cpp:870
llvm::SmallSet::insert
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Definition: SmallSet.h:178
llvm::DbgLabelInstrMap::InlinedEntity
std::pair< const DINode *, const DILocation * > InlinedEntity
Definition: DbgEntityHistoryCalculator.h:134
clobberRegEntries
static void clobberRegEntries(InlinedEntity Var, unsigned RegNo, const MachineInstr &ClobberingInstr, DbgValueEntriesMap &LiveEntries, DbgValueHistoryMap &HistMap, SmallVectorImpl< Register > &FellowRegisters)
Create a clobbering entry and end all open debug value entries for Var that are described by RegNo us...
Definition: DbgEntityHistoryCalculator.cpp:322
llvm::MCRegAliasIterator::isValid
bool isValid() const
Definition: MCRegisterInfo.h:813
llvm::TargetSubtargetInfo::getTargetLowering
virtual const TargetLowering * getTargetLowering() const
Definition: TargetSubtargetInfo.h:99
SmallVector.h
llvm::MachineBasicBlock::empty
bool empty() const
Definition: MachineBasicBlock.h:277
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::reverse
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:485
MachineOperand.h
dropRegDescribedVar
static void dropRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, InlinedEntity Var)
Definition: DbgEntityHistoryCalculator.cpp:296
llvm::DILabel
Label.
Definition: DebugInfoMetadata.h:3186
addRegDescribedVar
static void addRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, InlinedEntity Var)
Definition: DbgEntityHistoryCalculator.cpp:310
raw_ostream.h
llvm::SI::KernelInputOffsets::Offsets
Offsets
Offsets in bytes from the start of the input buffer.
Definition: SIInstrInfo.h:1314
llvm::LexicalScopes
LexicalScopes - This class provides interface to collect and use lexical scoping information from mac...
Definition: LexicalScopes.h:141
MachineFunction.h
TargetRegisterInfo.h
Debug.h
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:153
clobberRegisterUses
static void clobberRegisterUses(RegDescribedVarsMap &RegVars, RegDescribedVarsMap::iterator I, DbgValueHistoryMap &HistMap, DbgValueEntriesMap &LiveEntries, const MachineInstr &ClobberingInstr)
Definition: DbgEntityHistoryCalculator.cpp:418
llvm::SmallSet::contains
bool contains(const T &V) const
Check if the SmallSet contains the given element.
Definition: SmallSet.h:235
llvm::MCRegAliasIterator
MCRegAliasIterator enumerates all registers aliasing Reg.
Definition: MCRegisterInfo.h:788
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:941
SmallSet.h
llvm::DIExpression::fragmentsOverlap
static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B)
Check if fragments overlap between a pair of FragmentInfos.
Definition: DebugInfoMetadata.h:2892