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