forked from OSchip/llvm-project
Skip DBG_VALUE many places in live intervals and
register coalescing. This fixes many crashes and places where debug info affects codegen (when dbg.value is lowered to machine instructions, which it isn't yet in TOT). llvm-svn: 95739
This commit is contained in:
parent
74e6852510
commit
f8f9f55468
|
@ -512,6 +512,8 @@ void LiveIntervals::handlePhysicalRegisterDef(MachineBasicBlock *MBB,
|
|||
baseIndex = baseIndex.getNextIndex();
|
||||
while (++mi != MBB->end()) {
|
||||
|
||||
if (mi->isDebugValue())
|
||||
continue;
|
||||
if (getInstructionFromIndex(baseIndex) == 0)
|
||||
baseIndex = indexes_->getNextNonNullIndex(baseIndex);
|
||||
|
||||
|
@ -527,8 +529,8 @@ void LiveIntervals::handlePhysicalRegisterDef(MachineBasicBlock *MBB,
|
|||
end = baseIndex.getDefIndex();
|
||||
} else {
|
||||
// Another instruction redefines the register before it is ever read.
|
||||
// Then the register is essentially dead at the instruction that defines
|
||||
// it. Hence its interval is:
|
||||
// Then the register is essentially dead at the instruction that
|
||||
// defines it. Hence its interval is:
|
||||
// [defSlot(def), defSlot(def)+1)
|
||||
DEBUG(dbgs() << " dead");
|
||||
end = start.getStoreIndex();
|
||||
|
@ -607,25 +609,27 @@ void LiveIntervals::handleLiveInRegister(MachineBasicBlock *MBB,
|
|||
SlotIndex end = baseIndex;
|
||||
bool SeenDefUse = false;
|
||||
|
||||
while (mi != MBB->end()) {
|
||||
if (mi->killsRegister(interval.reg, tri_)) {
|
||||
DEBUG(dbgs() << " killed");
|
||||
end = baseIndex.getDefIndex();
|
||||
SeenDefUse = true;
|
||||
break;
|
||||
} else if (mi->modifiesRegister(interval.reg, tri_)) {
|
||||
// Another instruction redefines the register before it is ever read.
|
||||
// Then the register is essentially dead at the instruction that defines
|
||||
// it. Hence its interval is:
|
||||
// [defSlot(def), defSlot(def)+1)
|
||||
DEBUG(dbgs() << " dead");
|
||||
end = start.getStoreIndex();
|
||||
SeenDefUse = true;
|
||||
break;
|
||||
MachineBasicBlock::iterator E = MBB->end();
|
||||
while (mi != E) {
|
||||
if (!mi->isDebugValue()) {
|
||||
if (mi->killsRegister(interval.reg, tri_)) {
|
||||
DEBUG(dbgs() << " killed");
|
||||
end = baseIndex.getDefIndex();
|
||||
SeenDefUse = true;
|
||||
break;
|
||||
} else if (mi->modifiesRegister(interval.reg, tri_)) {
|
||||
// Another instruction redefines the register before it is ever read.
|
||||
// Then the register is essentially dead at the instruction that defines
|
||||
// it. Hence its interval is:
|
||||
// [defSlot(def), defSlot(def)+1)
|
||||
DEBUG(dbgs() << " dead");
|
||||
end = start.getStoreIndex();
|
||||
SeenDefUse = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
++mi;
|
||||
if (mi != MBB->end()) {
|
||||
if (mi != E && !mi->isDebugValue()) {
|
||||
baseIndex = indexes_->getNextNonNullIndex(baseIndex);
|
||||
}
|
||||
}
|
||||
|
@ -1056,7 +1060,7 @@ rewriteInstructionForSpills(const LiveInterval &li, const VNInfo *VNI,
|
|||
// If this is the rematerializable definition MI itself and
|
||||
// all of its uses are rematerialized, simply delete it.
|
||||
if (MI == ReMatOrigDefMI && CanDelete) {
|
||||
DEBUG(dbgs() << "\t\t\t\tErasing re-materlizable def: "
|
||||
DEBUG(dbgs() << "\t\t\t\tErasing re-materializable def: "
|
||||
<< MI << '\n');
|
||||
RemoveMachineInstrFromMaps(MI);
|
||||
vrm.RemoveMachineInstrFromMaps(MI);
|
||||
|
@ -1299,6 +1303,12 @@ rewriteInstructionsForSpills(const LiveInterval &li, bool TrySplit,
|
|||
MachineInstr *MI = &*ri;
|
||||
MachineOperand &O = ri.getOperand();
|
||||
++ri;
|
||||
if (MI->isDebugValue()) {
|
||||
// Remove debug info for now.
|
||||
O.setReg(0U);
|
||||
DEBUG(dbgs() << "Removing debug info due to spill:" << "\t" << *MI);
|
||||
continue;
|
||||
}
|
||||
assert(!O.isImplicit() && "Spilling register that's used as implicit use?");
|
||||
SlotIndex index = getInstructionIndex(MI);
|
||||
if (index < start || index >= end)
|
||||
|
|
|
@ -375,8 +375,9 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA,
|
|||
|
||||
// If some of the uses of IntA.reg is already coalesced away, return false.
|
||||
// It's not possible to determine whether it's safe to perform the coalescing.
|
||||
for (MachineRegisterInfo::use_iterator UI = mri_->use_begin(IntA.reg),
|
||||
UE = mri_->use_end(); UI != UE; ++UI) {
|
||||
for (MachineRegisterInfo::use_nodbg_iterator UI =
|
||||
mri_->use_nodbg_begin(IntA.reg),
|
||||
UE = mri_->use_nodbg_end(); UI != UE; ++UI) {
|
||||
MachineInstr *UseMI = &*UI;
|
||||
SlotIndex UseIdx = li_->getInstructionIndex(UseMI);
|
||||
LiveInterval::iterator ULR = IntA.FindLiveRangeContaining(UseIdx);
|
||||
|
@ -430,6 +431,12 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA,
|
|||
++UI;
|
||||
if (JoinedCopies.count(UseMI))
|
||||
continue;
|
||||
if (UseMI->isDebugValue()) {
|
||||
// FIXME These don't have an instruction index. Not clear we have enough
|
||||
// info to decide whether to do this replacement or not. For now do it.
|
||||
UseMO.setReg(NewReg);
|
||||
continue;
|
||||
}
|
||||
SlotIndex UseIdx = li_->getInstructionIndex(UseMI).getUseIndex();
|
||||
LiveInterval::iterator ULR = IntA.FindLiveRangeContaining(UseIdx);
|
||||
if (ULR == IntA.end() || ULR->valno != AValNo)
|
||||
|
@ -1029,8 +1036,9 @@ SimpleRegisterCoalescing::isWinToJoinVRWithSrcPhysReg(MachineInstr *CopyMI,
|
|||
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
|
||||
unsigned Length = li_->getApproximateInstructionCount(DstInt);
|
||||
if (Length > Threshold &&
|
||||
(((float)std::distance(mri_->use_begin(DstInt.reg),
|
||||
mri_->use_end()) / Length) < (1.0 / Threshold)))
|
||||
(((float)std::distance(mri_->use_nodbg_begin(DstInt.reg),
|
||||
mri_->use_nodbg_end()) / Length) <
|
||||
(1.0 / Threshold)))
|
||||
return false;
|
||||
|
||||
// If the virtual register live interval extends into a loop, turn down
|
||||
|
@ -1079,15 +1087,16 @@ SimpleRegisterCoalescing::isWinToJoinVRWithDstPhysReg(MachineInstr *CopyMI,
|
|||
MachineBasicBlock *CopyMBB,
|
||||
LiveInterval &DstInt,
|
||||
LiveInterval &SrcInt) {
|
||||
// If the virtual register live interval is long but it has low use desity,
|
||||
// If the virtual register live interval is long but it has low use density,
|
||||
// do not join them, instead mark the physical register as its allocation
|
||||
// preference.
|
||||
const TargetRegisterClass *RC = mri_->getRegClass(SrcInt.reg);
|
||||
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
|
||||
unsigned Length = li_->getApproximateInstructionCount(SrcInt);
|
||||
if (Length > Threshold &&
|
||||
(((float)std::distance(mri_->use_begin(SrcInt.reg),
|
||||
mri_->use_end()) / Length) < (1.0 / Threshold)))
|
||||
(((float)std::distance(mri_->use_nodbg_begin(SrcInt.reg),
|
||||
mri_->use_nodbg_end()) / Length) <
|
||||
(1.0 / Threshold)))
|
||||
return false;
|
||||
|
||||
if (SrcInt.empty())
|
||||
|
@ -1140,10 +1149,10 @@ SimpleRegisterCoalescing::isWinToJoinCrossClass(unsigned LargeReg,
|
|||
unsigned LargeSize = li_->getApproximateInstructionCount(LargeInt);
|
||||
unsigned SmallSize = li_->getApproximateInstructionCount(SmallInt);
|
||||
if (SmallSize > Threshold || LargeSize > Threshold)
|
||||
if ((float)std::distance(mri_->use_begin(SmallReg),
|
||||
mri_->use_end()) / SmallSize <
|
||||
(float)std::distance(mri_->use_begin(LargeReg),
|
||||
mri_->use_end()) / LargeSize)
|
||||
if ((float)std::distance(mri_->use_nodbg_begin(SmallReg),
|
||||
mri_->use_nodbg_end()) / SmallSize <
|
||||
(float)std::distance(mri_->use_nodbg_begin(LargeReg),
|
||||
mri_->use_nodbg_end()) / LargeSize)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -1630,8 +1639,8 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
|
|||
unsigned Length = li_->getApproximateInstructionCount(JoinVInt);
|
||||
float Ratio = 1.0 / Threshold;
|
||||
if (Length > Threshold &&
|
||||
(((float)std::distance(mri_->use_begin(JoinVReg),
|
||||
mri_->use_end()) / Length) < Ratio)) {
|
||||
(((float)std::distance(mri_->use_nodbg_begin(JoinVReg),
|
||||
mri_->use_nodbg_end()) / Length) < Ratio)) {
|
||||
mri_->setRegAllocationHint(JoinVInt.reg, 0, JoinPReg);
|
||||
++numAborts;
|
||||
DEBUG(dbgs() << "\tMay tie down a physical register, abort!\n");
|
||||
|
@ -2564,8 +2573,8 @@ SimpleRegisterCoalescing::differingRegisterClasses(unsigned RegA,
|
|||
return !RegClassA->contains(RegB);
|
||||
}
|
||||
|
||||
/// lastRegisterUse - Returns the last use of the specific register between
|
||||
/// cycles Start and End or NULL if there are no uses.
|
||||
/// lastRegisterUse - Returns the last (non-debug) use of the specific register
|
||||
/// between cycles Start and End or NULL if there are no uses.
|
||||
MachineOperand *
|
||||
SimpleRegisterCoalescing::lastRegisterUse(SlotIndex Start,
|
||||
SlotIndex End,
|
||||
|
@ -2574,8 +2583,8 @@ SimpleRegisterCoalescing::lastRegisterUse(SlotIndex Start,
|
|||
UseIdx = SlotIndex();
|
||||
if (TargetRegisterInfo::isVirtualRegister(Reg)) {
|
||||
MachineOperand *LastUse = NULL;
|
||||
for (MachineRegisterInfo::use_iterator I = mri_->use_begin(Reg),
|
||||
E = mri_->use_end(); I != E; ++I) {
|
||||
for (MachineRegisterInfo::use_nodbg_iterator I = mri_->use_nodbg_begin(Reg),
|
||||
E = mri_->use_nodbg_end(); I != E; ++I) {
|
||||
MachineOperand &Use = I.getOperand();
|
||||
MachineInstr *UseMI = Use.getParent();
|
||||
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
||||
|
|
Loading…
Reference in New Issue