Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions llvm/lib/CodeGen/InlineSpiller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,12 @@ bool InlineSpiller::reMaterializeFor(LiveInterval &VirtReg, MachineInstr &MI) {
SmallVector<std::pair<MachineInstr *, unsigned>, 8> Ops;
VirtRegInfo RI = AnalyzeVirtRegInBundle(MI, VirtReg.reg(), &Ops);

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

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

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

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