forked from OSchip/llvm-project
Remove the last remat-related code from LiveIntervalAnalysis.
Rematerialization is handled by LiveRangeEdit now. llvm-svn: 157974
This commit is contained in:
parent
9e27e2621a
commit
345528944c
|
@ -361,26 +361,6 @@ namespace llvm {
|
|||
SlotIndex MIIdx,
|
||||
LiveInterval &interval);
|
||||
|
||||
/// getReMatImplicitUse - If the remat definition MI has one (for now, we
|
||||
/// only allow one) virtual register operand, then its uses are implicitly
|
||||
/// using the register. Returns the virtual register.
|
||||
unsigned getReMatImplicitUse(const LiveInterval &li,
|
||||
MachineInstr *MI) const;
|
||||
|
||||
/// isValNoAvailableAt - Return true if the val# of the specified interval
|
||||
/// which reaches the given instruction also reaches the specified use
|
||||
/// index.
|
||||
bool isValNoAvailableAt(const LiveInterval &li, MachineInstr *MI,
|
||||
SlotIndex UseIdx) const;
|
||||
|
||||
/// isReMaterializable - Returns true if the definition MI of the specified
|
||||
/// val# of the specified interval is re-materializable. Also returns true
|
||||
/// by reference if the def is a load.
|
||||
bool isReMaterializable(const LiveInterval &li, const VNInfo *ValNo,
|
||||
MachineInstr *MI,
|
||||
const SmallVectorImpl<LiveInterval*> *SpillIs,
|
||||
bool &isLoad);
|
||||
|
||||
static LiveInterval* createInterval(unsigned Reg);
|
||||
|
||||
void printInstrs(raw_ostream &O) const;
|
||||
|
|
|
@ -785,101 +785,6 @@ void LiveIntervals::addKillFlags() {
|
|||
}
|
||||
}
|
||||
|
||||
/// getReMatImplicitUse - If the remat definition MI has one (for now, we only
|
||||
/// allow one) virtual register operand, then its uses are implicitly using
|
||||
/// the register. Returns the virtual register.
|
||||
unsigned LiveIntervals::getReMatImplicitUse(const LiveInterval &li,
|
||||
MachineInstr *MI) const {
|
||||
unsigned RegOp = 0;
|
||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||
MachineOperand &MO = MI->getOperand(i);
|
||||
if (!MO.isReg() || !MO.isUse())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (Reg == 0 || Reg == li.reg)
|
||||
continue;
|
||||
|
||||
if (TargetRegisterInfo::isPhysicalRegister(Reg) && !isAllocatable(Reg))
|
||||
continue;
|
||||
RegOp = MO.getReg();
|
||||
break; // Found vreg operand - leave the loop.
|
||||
}
|
||||
return RegOp;
|
||||
}
|
||||
|
||||
/// isValNoAvailableAt - Return true if the val# of the specified interval
|
||||
/// which reaches the given instruction also reaches the specified use index.
|
||||
bool LiveIntervals::isValNoAvailableAt(const LiveInterval &li, MachineInstr *MI,
|
||||
SlotIndex UseIdx) const {
|
||||
VNInfo *UValNo = li.getVNInfoAt(UseIdx);
|
||||
return UValNo && UValNo == li.getVNInfoAt(getInstructionIndex(MI));
|
||||
}
|
||||
|
||||
/// isReMaterializable - Returns true if the definition MI of the specified
|
||||
/// val# of the specified interval is re-materializable.
|
||||
bool
|
||||
LiveIntervals::isReMaterializable(const LiveInterval &li,
|
||||
const VNInfo *ValNo, MachineInstr *MI,
|
||||
const SmallVectorImpl<LiveInterval*> *SpillIs,
|
||||
bool &isLoad) {
|
||||
if (DisableReMat)
|
||||
return false;
|
||||
|
||||
if (!TII->isTriviallyReMaterializable(MI, AA))
|
||||
return false;
|
||||
|
||||
// Target-specific code can mark an instruction as being rematerializable
|
||||
// if it has one virtual reg use, though it had better be something like
|
||||
// a PIC base register which is likely to be live everywhere.
|
||||
unsigned ImpUse = getReMatImplicitUse(li, MI);
|
||||
if (ImpUse) {
|
||||
const LiveInterval &ImpLi = getInterval(ImpUse);
|
||||
for (MachineRegisterInfo::use_nodbg_iterator
|
||||
ri = MRI->use_nodbg_begin(li.reg), re = MRI->use_nodbg_end();
|
||||
ri != re; ++ri) {
|
||||
MachineInstr *UseMI = &*ri;
|
||||
SlotIndex UseIdx = getInstructionIndex(UseMI);
|
||||
if (li.getVNInfoAt(UseIdx) != ValNo)
|
||||
continue;
|
||||
if (!isValNoAvailableAt(ImpLi, MI, UseIdx))
|
||||
return false;
|
||||
}
|
||||
|
||||
// If a register operand of the re-materialized instruction is going to
|
||||
// be spilled next, then it's not legal to re-materialize this instruction.
|
||||
if (SpillIs)
|
||||
for (unsigned i = 0, e = SpillIs->size(); i != e; ++i)
|
||||
if (ImpUse == (*SpillIs)[i]->reg)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// isReMaterializable - Returns true if every definition of MI of every
|
||||
/// val# of the specified interval is re-materializable.
|
||||
bool
|
||||
LiveIntervals::isReMaterializable(const LiveInterval &li,
|
||||
const SmallVectorImpl<LiveInterval*> *SpillIs,
|
||||
bool &isLoad) {
|
||||
isLoad = false;
|
||||
for (LiveInterval::const_vni_iterator i = li.vni_begin(), e = li.vni_end();
|
||||
i != e; ++i) {
|
||||
const VNInfo *VNI = *i;
|
||||
if (VNI->isUnused())
|
||||
continue; // Dead val#.
|
||||
// Is the def for the val# rematerializable?
|
||||
MachineInstr *ReMatDefMI = getInstructionFromIndex(VNI->def);
|
||||
if (!ReMatDefMI)
|
||||
return false;
|
||||
bool DefIsLoad = false;
|
||||
if (!ReMatDefMI ||
|
||||
!isReMaterializable(li, VNI, ReMatDefMI, SpillIs, DefIsLoad))
|
||||
return false;
|
||||
isLoad |= DefIsLoad;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
MachineBasicBlock*
|
||||
LiveIntervals::intervalIsInOneMBB(const LiveInterval &LI) const {
|
||||
// A local live range must be fully contained inside the block, meaning it is
|
||||
|
|
Loading…
Reference in New Issue