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