Skip to content

Commit 28e8baf

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.6-beta.1
2 parents ef6d187 + f1931b6 commit 28e8baf

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,18 @@ static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV,
373373
DbgValueHistoryMap &HistMap) {
374374
EntryIndex NewIndex;
375375
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.
376388
SmallDenseMap<unsigned, bool, 4> TrackedRegs;
377389

378390
// If we have created a new debug value entry, close all preceding
@@ -466,9 +478,6 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF,
466478
for (const auto &MI : MBB) {
467479
if (MI.isDebugValue()) {
468480
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.
472481
const DILocalVariable *RawVar = MI.getDebugVariable();
473482
assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
474483
"Expected inlined-at fields to agree");
@@ -492,8 +501,7 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF,
492501
if (MI.isMetaInstruction())
493502
continue;
494503

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.
497505
for (const MachineOperand &MO : MI.operands()) {
498506
if (MO.isReg() && MO.isDef() && MO.getReg()) {
499507
// Ignore call instructions that claim to clobber SP. The AArch64

0 commit comments

Comments
 (0)