@@ -373,6 +373,18 @@ static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV,
373
373
DbgValueHistoryMap &HistMap) {
374
374
EntryIndex NewIndex;
375
375
if (HistMap.startDbgValue (Var, DV, NewIndex)) {
376
+ // As we already need to iterate all LiveEntries when handling a DbgValue,
377
+ // we use this map to avoid a more expensive check against RegVars. There
378
+ // is an assert that we handle this correclty in addRegDescribedVar.
379
+ //
380
+ // In other terms, the presense in this map indicates the presense of a
381
+ // corresponding entry in RegVars.
382
+ //
383
+ // The bool value then tracks whether an entry is to be retained (true) or
384
+ // removed (false); as we end previous entries we speculatively assume they
385
+ // can be dropped from RegVars, but we then also visit the new entry whose
386
+ // set of debug register operands may overlap and "save" a reg from being
387
+ // dropped.
376
388
SmallDenseMap<unsigned , bool , 4 > TrackedRegs;
377
389
378
390
// If we have created a new debug value entry, close all preceding
@@ -466,9 +478,6 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF,
466
478
for (const auto &MI : MBB) {
467
479
if (MI.isDebugValue ()) {
468
480
assert (MI.getNumOperands () > 1 && " Invalid DBG_VALUE instruction!" );
469
- // Use the base variable (without any DW_OP_piece expressions)
470
- // as index into History. The full variables including the
471
- // piece expressions are attached to the MI.
472
481
const DILocalVariable *RawVar = MI.getDebugVariable ();
473
482
assert (RawVar->isValidLocationForIntrinsic (MI.getDebugLoc ()) &&
474
483
" Expected inlined-at fields to agree" );
@@ -492,8 +501,7 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF,
492
501
if (MI.isMetaInstruction ())
493
502
continue ;
494
503
495
- // Not a DBG_VALUE instruction. It may clobber registers which describe
496
- // some variables.
504
+ // Other instruction may clobber registers which describe some variables.
497
505
for (const MachineOperand &MO : MI.operands ()) {
498
506
if (MO.isReg () && MO.isDef () && MO.getReg ()) {
499
507
// Ignore call instructions that claim to clobber SP. The AArch64
0 commit comments