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 bool DbgValueHistoryMap::hasNonEmptyLocation(const Entries &Entries) const { 277 for (const auto &Entry : Entries) { 278 if (!Entry.isDbgValue()) 279 continue; 280 281 const MachineInstr *MI = Entry.getInstr(); 282 assert(MI->isDebugValue()); 283 // A DBG_VALUE $noreg is an empty variable location 284 if (MI->getOperand(0).isReg() && MI->getOperand(0).getReg() == 0) 285 continue; 286 287 return true; 288 } 289 290 return false; 291 } 292 293 void DbgLabelInstrMap::addInstr(InlinedEntity Label, const MachineInstr &MI) { 294 assert(MI.isDebugLabel() && "not a DBG_LABEL"); 295 LabelInstr[Label] = &MI; 296 } 297 298 namespace { 299 300 // Maps physreg numbers to the variables they describe. 301 using InlinedEntity = DbgValueHistoryMap::InlinedEntity; 302 using RegDescribedVarsMap = std::map<unsigned, SmallVector<InlinedEntity, 1>>; 303 304 // Keeps track of the debug value entries that are currently live for each 305 // inlined entity. As the history map entries are stored in a SmallVector, they 306 // may be moved at insertion of new entries, so store indices rather than 307 // pointers. 308 using DbgValueEntriesMap = std::map<InlinedEntity, SmallSet<EntryIndex, 1>>; 309 310 } // end anonymous namespace 311 312 // Claim that @Var is not described by @RegNo anymore. 313 static void dropRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, 314 InlinedEntity Var) { 315 const auto &I = RegVars.find(RegNo); 316 assert(RegNo != 0U && I != RegVars.end()); 317 auto &VarSet = I->second; 318 const auto &VarPos = llvm::find(VarSet, Var); 319 assert(VarPos != VarSet.end()); 320 VarSet.erase(VarPos); 321 // Don't keep empty sets in a map to keep it as small as possible. 322 if (VarSet.empty()) 323 RegVars.erase(I); 324 } 325 326 // Claim that @Var is now described by @RegNo. 327 static void addRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo, 328 InlinedEntity Var) { 329 assert(RegNo != 0U); 330 auto &VarSet = RegVars[RegNo]; 331 assert(!is_contained(VarSet, Var)); 332 VarSet.push_back(Var); 333 } 334 335 /// Create a clobbering entry and end all open debug value entries 336 /// for \p Var that are described by \p RegNo using that entry. 337 static void clobberRegEntries(InlinedEntity Var, unsigned RegNo, 338 const MachineInstr &ClobberingInstr, 339 DbgValueEntriesMap &LiveEntries, 340 DbgValueHistoryMap &HistMap) { 341 EntryIndex ClobberIndex = HistMap.startClobber(Var, ClobberingInstr); 342 343 // Close all entries whose values are described by the register. 344 SmallVector<EntryIndex, 4> IndicesToErase; 345 for (auto Index : LiveEntries[Var]) { 346 auto &Entry = HistMap.getEntry(Var, Index); 347 assert(Entry.isDbgValue() && "Not a DBG_VALUE in LiveEntries"); 348 if (isDescribedByReg(*Entry.getInstr()) == RegNo) { 349 IndicesToErase.push_back(Index); 350 Entry.endEntry(ClobberIndex); 351 } 352 } 353 354 // Drop all entries that have ended. 355 for (auto Index : IndicesToErase) 356 LiveEntries[Var].erase(Index); 357 } 358 359 /// Add a new debug value for \p Var. Closes all overlapping debug values. 360 static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV, 361 RegDescribedVarsMap &RegVars, 362 DbgValueEntriesMap &LiveEntries, 363 DbgValueHistoryMap &HistMap) { 364 EntryIndex NewIndex; 365 if (HistMap.startDbgValue(Var, DV, NewIndex)) { 366 SmallDenseMap<unsigned, bool, 4> TrackedRegs; 367 368 // If we have created a new debug value entry, close all preceding 369 // live entries that overlap. 370 SmallVector<EntryIndex, 4> IndicesToErase; 371 const DIExpression *DIExpr = DV.getDebugExpression(); 372 for (auto Index : LiveEntries[Var]) { 373 auto &Entry = HistMap.getEntry(Var, Index); 374 assert(Entry.isDbgValue() && "Not a DBG_VALUE in LiveEntries"); 375 const MachineInstr &DV = *Entry.getInstr(); 376 bool Overlaps = DIExpr->fragmentsOverlap(DV.getDebugExpression()); 377 if (Overlaps) { 378 IndicesToErase.push_back(Index); 379 Entry.endEntry(NewIndex); 380 } 381 if (Register Reg = isDescribedByReg(DV)) 382 TrackedRegs[Reg] |= !Overlaps; 383 } 384 385 // If the new debug value is described by a register, add tracking of 386 // that register if it is not already tracked. 387 if (Register NewReg = isDescribedByReg(DV)) { 388 if (!TrackedRegs.count(NewReg)) 389 addRegDescribedVar(RegVars, NewReg, Var); 390 LiveEntries[Var].insert(NewIndex); 391 TrackedRegs[NewReg] = true; 392 } 393 394 // Drop tracking of registers that are no longer used. 395 for (auto I : TrackedRegs) 396 if (!I.second) 397 dropRegDescribedVar(RegVars, I.first, Var); 398 399 // Drop all entries that have ended, and mark the new entry as live. 400 for (auto Index : IndicesToErase) 401 LiveEntries[Var].erase(Index); 402 LiveEntries[Var].insert(NewIndex); 403 } 404 } 405 406 // Terminate the location range for variables described by register at 407 // @I by inserting @ClobberingInstr to their history. 408 static void clobberRegisterUses(RegDescribedVarsMap &RegVars, 409 RegDescribedVarsMap::iterator I, 410 DbgValueHistoryMap &HistMap, 411 DbgValueEntriesMap &LiveEntries, 412 const MachineInstr &ClobberingInstr) { 413 // Iterate over all variables described by this register and add this 414 // instruction to their history, clobbering it. 415 for (const auto &Var : I->second) 416 clobberRegEntries(Var, I->first, ClobberingInstr, LiveEntries, HistMap); 417 RegVars.erase(I); 418 } 419 420 // Terminate the location range for variables described by register 421 // @RegNo by inserting @ClobberingInstr to their history. 422 static void clobberRegisterUses(RegDescribedVarsMap &RegVars, unsigned RegNo, 423 DbgValueHistoryMap &HistMap, 424 DbgValueEntriesMap &LiveEntries, 425 const MachineInstr &ClobberingInstr) { 426 const auto &I = RegVars.find(RegNo); 427 if (I == RegVars.end()) 428 return; 429 clobberRegisterUses(RegVars, I, HistMap, LiveEntries, ClobberingInstr); 430 } 431 432 void llvm::calculateDbgEntityHistory(const MachineFunction *MF, 433 const TargetRegisterInfo *TRI, 434 DbgValueHistoryMap &DbgValues, 435 DbgLabelInstrMap &DbgLabels) { 436 const TargetLowering *TLI = MF->getSubtarget().getTargetLowering(); 437 Register SP = TLI->getStackPointerRegisterToSaveRestore(); 438 Register FrameReg = TRI->getFrameRegister(*MF); 439 RegDescribedVarsMap RegVars; 440 DbgValueEntriesMap LiveEntries; 441 for (const auto &MBB : *MF) { 442 for (const auto &MI : MBB) { 443 if (MI.isDebugValue()) { 444 assert(MI.getNumOperands() > 1 && "Invalid DBG_VALUE instruction!"); 445 // Use the base variable (without any DW_OP_piece expressions) 446 // as index into History. The full variables including the 447 // piece expressions are attached to the MI. 448 const DILocalVariable *RawVar = MI.getDebugVariable(); 449 assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) && 450 "Expected inlined-at fields to agree"); 451 InlinedEntity Var(RawVar, MI.getDebugLoc()->getInlinedAt()); 452 453 handleNewDebugValue(Var, MI, RegVars, LiveEntries, DbgValues); 454 } else if (MI.isDebugLabel()) { 455 assert(MI.getNumOperands() == 1 && "Invalid DBG_LABEL instruction!"); 456 const DILabel *RawLabel = MI.getDebugLabel(); 457 assert(RawLabel->isValidLocationForIntrinsic(MI.getDebugLoc()) && 458 "Expected inlined-at fields to agree"); 459 // When collecting debug information for labels, there is no MCSymbol 460 // generated for it. So, we keep MachineInstr in DbgLabels in order 461 // to query MCSymbol afterward. 462 InlinedEntity L(RawLabel, MI.getDebugLoc()->getInlinedAt()); 463 DbgLabels.addInstr(L, MI); 464 } 465 466 // Meta Instructions have no output and do not change any values and so 467 // can be safely ignored. 468 if (MI.isMetaInstruction()) 469 continue; 470 471 // Not a DBG_VALUE instruction. It may clobber registers which describe 472 // some variables. 473 for (const MachineOperand &MO : MI.operands()) { 474 if (MO.isReg() && MO.isDef() && MO.getReg()) { 475 // Ignore call instructions that claim to clobber SP. The AArch64 476 // backend does this for aggregate function arguments. 477 if (MI.isCall() && MO.getReg() == SP) 478 continue; 479 // If this is a virtual register, only clobber it since it doesn't 480 // have aliases. 481 if (Register::isVirtualRegister(MO.getReg())) 482 clobberRegisterUses(RegVars, MO.getReg(), DbgValues, LiveEntries, 483 MI); 484 // If this is a register def operand, it may end a debug value 485 // range. Ignore frame-register defs in the epilogue and prologue, 486 // we expect debuggers to understand that stack-locations are 487 // invalid outside of the function body. 488 else if (MO.getReg() != FrameReg || 489 (!MI.getFlag(MachineInstr::FrameDestroy) && 490 !MI.getFlag(MachineInstr::FrameSetup))) { 491 for (MCRegAliasIterator AI(MO.getReg(), TRI, true); AI.isValid(); 492 ++AI) 493 clobberRegisterUses(RegVars, *AI, DbgValues, LiveEntries, MI); 494 } 495 } else if (MO.isRegMask()) { 496 // If this is a register mask operand, clobber all debug values in 497 // non-CSRs. 498 SmallVector<unsigned, 32> RegsToClobber; 499 // Don't consider SP to be clobbered by register masks. 500 for (auto It : RegVars) { 501 unsigned int Reg = It.first; 502 if (Reg != SP && Register::isPhysicalRegister(Reg) && 503 MO.clobbersPhysReg(Reg)) 504 RegsToClobber.push_back(Reg); 505 } 506 507 for (unsigned Reg : RegsToClobber) { 508 clobberRegisterUses(RegVars, Reg, DbgValues, LiveEntries, MI); 509 } 510 } 511 } // End MO loop. 512 } // End instr loop. 513 514 // Make sure locations for all variables are valid only until the end of 515 // the basic block (unless it's the last basic block, in which case let 516 // their liveness run off to the end of the function). 517 if (!MBB.empty() && &MBB != &MF->back()) { 518 // Iterate over all variables that have open debug values. 519 for (auto &Pair : LiveEntries) { 520 if (Pair.second.empty()) 521 continue; 522 523 // Create a clobbering entry. 524 EntryIndex ClobIdx = DbgValues.startClobber(Pair.first, MBB.back()); 525 526 // End all entries. 527 for (EntryIndex Idx : Pair.second) { 528 DbgValueHistoryMap::Entry &Ent = DbgValues.getEntry(Pair.first, Idx); 529 assert(Ent.isDbgValue() && !Ent.isClosed()); 530 Ent.endEntry(ClobIdx); 531 } 532 } 533 534 LiveEntries.clear(); 535 RegVars.clear(); 536 } 537 } 538 } 539 540 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 541 LLVM_DUMP_METHOD void DbgValueHistoryMap::dump() const { 542 dbgs() << "DbgValueHistoryMap:\n"; 543 for (const auto &VarRangePair : *this) { 544 const InlinedEntity &Var = VarRangePair.first; 545 const Entries &Entries = VarRangePair.second; 546 547 const DILocalVariable *LocalVar = cast<DILocalVariable>(Var.first); 548 const DILocation *Location = Var.second; 549 550 dbgs() << " - " << LocalVar->getName() << " at "; 551 552 if (Location) 553 dbgs() << Location->getFilename() << ":" << Location->getLine() << ":" 554 << Location->getColumn(); 555 else 556 dbgs() << "<unknown location>"; 557 558 dbgs() << " --\n"; 559 560 for (const auto &E : enumerate(Entries)) { 561 const auto &Entry = E.value(); 562 dbgs() << " Entry[" << E.index() << "]: "; 563 if (Entry.isDbgValue()) 564 dbgs() << "Debug value\n"; 565 else 566 dbgs() << "Clobber\n"; 567 dbgs() << " Instr: " << *Entry.getInstr(); 568 if (Entry.isDbgValue()) { 569 if (Entry.getEndIndex() == NoEntry) 570 dbgs() << " - Valid until end of function\n"; 571 else 572 dbgs() << " - Closed by Entry[" << Entry.getEndIndex() << "]\n"; 573 } 574 dbgs() << "\n"; 575 } 576 } 577 } 578 #endif 579