Skip to content

Commit 67aaf45

Browse files
preamesmahesh-attarde
authored andcommitted
[RegAlloc] Add additional tracing in InlineSpiller::rematerializeFor (llvm#160761)
We didn't have trace logging for two cases in this routine which makes it sometimes hard to tell what is going on. In addition to debug trace statements, add comments to explain the logic behind the early exits which don't mark the virtual register live. Suggestions on how to word these more precisely very welcome; I'm not clear I understand all the intrinicies of this code myself.
1 parent 4e4f3f1 commit 67aaf45

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

llvm/lib/CodeGen/InlineSpiller.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,12 @@ bool InlineSpiller::reMaterializeFor(LiveInterval &VirtReg, MachineInstr &MI) {
642642
SmallVector<std::pair<MachineInstr *, unsigned>, 8> Ops;
643643
VirtRegInfo RI = AnalyzeVirtRegInBundle(MI, VirtReg.reg(), &Ops);
644644

645-
if (!RI.Reads)
645+
// Defs without reads will be deleted if unused after remat is
646+
// completed for other users of the virtual register.
647+
if (!RI.Reads) {
648+
LLVM_DEBUG(dbgs() << "\tskipping remat of def " << MI);
646649
return false;
650+
}
647651

648652
SlotIndex UseIdx = LIS.getInstructionIndex(MI).getRegSlot(true);
649653
VNInfo *ParentVNI = VirtReg.getVNInfoAt(UseIdx.getBaseIndex());
@@ -657,8 +661,13 @@ bool InlineSpiller::reMaterializeFor(LiveInterval &VirtReg, MachineInstr &MI) {
657661
return true;
658662
}
659663

660-
if (SnippetCopies.count(&MI))
664+
// Snippets copies are ignored for remat, and will be deleted if they
665+
// don't feed a live user after rematerialization completes.
666+
if (SnippetCopies.count(&MI)) {
667+
LLVM_DEBUG(dbgs() << "\tskipping remat snippet copy for " << UseIdx << '\t'
668+
<< MI);
661669
return false;
670+
}
662671

663672
LiveInterval &OrigLI = LIS.getInterval(Original);
664673
VNInfo *OrigVNI = OrigLI.getVNInfoAt(UseIdx);

0 commit comments

Comments
 (0)