Ranges ranges; // the ranges in which this register is live
/// ValueNumberInfo - If the value number definition is undefined (e.g. phi
- /// merge point), it contains ~0,x,x. If the value number is not in use, it
- /// contains ~1,x,x to indicate that the value # is not used. The first
- /// entry is the instruction # of the definition, the second is the kill #.
- /// If the third value is non-zero, then the val# is defined by a copy and
- /// it represents the register number it is copied from.
+ /// merge point), it contains ~0u,x. If the value number is not in use, it
+ /// contains ~1u,x to indicate that the value # is not used.
struct VNInfo {
- unsigned def;
- unsigned kill;
- unsigned reg;
- VNInfo() : def(~1U), kill(~0U), reg(0) {};
- VNInfo(unsigned d, unsigned k, unsigned r) : def(d), kill(k), reg(r) {};
+ unsigned def; // instruction # of the definition
+ unsigned reg; // src reg: non-zero iff val# is defined by a copy
+ SmallVector<unsigned, 4> kills; // instruction #s of the kills
+ VNInfo() : def(~1U), reg(0) {};
+ VNInfo(unsigned d, unsigned r) : def(d), reg(r) {};
};
private:
SmallVector<VNInfo, 4> ValueNumberInfo;
/// getNextValue - Create a new value number and return it. MIIdx specifies
/// the instruction that defines the value number.
unsigned getNextValue(unsigned MIIdx, unsigned SrcReg) {
- ValueNumberInfo.push_back(VNInfo(MIIdx, ~0U, SrcReg));
+ ValueNumberInfo.push_back(VNInfo(MIIdx, SrcReg));
return ValueNumberInfo.size()-1;
}
return ValueNumberInfo[ValNo].def;
}
- /// getKillForValNum - Return the machine instruction index that kills the
- /// specified value number.
- unsigned getKillForValNum(unsigned ValNo) const {
+ unsigned getSrcRegForValNum(unsigned ValNo) const {
//assert(ValNo < ValueNumberInfo.size());
- return ValueNumberInfo[ValNo].kill;
+ return ValueNumberInfo[ValNo].reg;
}
- unsigned getSrcRegForValNum(unsigned ValNo) const {
+ /// getKillsForValNum - Return the kill instruction indexes of the specified
+ /// value number.
+ SmallVector<unsigned, 4> getKillsForValNum(unsigned ValNo) const {
//assert(ValNo < ValueNumberInfo.size());
- return ValueNumberInfo[ValNo].reg;
+ return ValueNumberInfo[ValNo].kills;
+ }
+
+ /// addKillForValNum - Add a kill instruction index to the specified value
+ /// number.
+ void addKillForValNum(unsigned ValNo, unsigned KillIdx) {
+ ValueNumberInfo[ValNo].kills.push_back(KillIdx);
}
VNInfo getValNumInfo(unsigned ValNo) const {
void setValueNumberInfo(unsigned ValNo, const VNInfo &I) {
ValueNumberInfo[ValNo] = I;
}
-
+
/// MergeValueNumberInto - This method is called when two value nubmers
/// are found to be equivalent. This eliminates V1, replacing all
/// LiveRanges with the V1 value number with the V2 value number. This can
// we want to avoid the interval scan if not.
bool MustMapCurValNos = false;
for (unsigned i = 0, e = getNumValNums(); i != e; ++i) {
- if (ValueNumberInfo[i].def == ~1U) continue; // tombstone value #
+ //if (ValueNumberInfo[i].def == ~1U) continue; // tombstone value #
if (i != (unsigned)LHSValNoAssignments[i]) {
MustMapCurValNos = true;
break;
OS << i << "@";
if (ValueNumberInfo[i].def == ~0U) {
OS << "?";
+ } else if (ValueNumberInfo[i].def == ~1U) {
+ OS << "x";
} else {
OS << ValueNumberInfo[i].def;
}
- if (ValueNumberInfo[i].kill == ~0U) {
- OS << ",?";
- } else {
- OS << "," << ValueNumberInfo[i].kill;
- }
}
}
}
// Get the Idx of the defining instructions.
unsigned defIndex = getDefIndex(MIIdx);
-
unsigned ValNum;
unsigned SrcReg, DstReg;
if (!tii_->isMoveInstr(*mi, SrcReg, DstReg))
LiveRange LR(defIndex, killIdx, ValNum);
interval.addRange(LR);
DOUT << " +" << LR << "\n";
+ interval.addKillForValNum(ValNum, killIdx);
return;
}
}
// block to the 'use' slot of the killing instruction.
for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) {
MachineInstr *Kill = vi.Kills[i];
+ unsigned killIdx = getUseIndex(getInstructionIndex(Kill))+1;
LiveRange LR(getMBBStartIdx(Kill->getParent()),
- getUseIndex(getInstructionIndex(Kill))+1,
- ValNum);
+ killIdx, ValNum);
interval.addRange(LR);
+ interval.addKillForValNum(ValNum, killIdx);
DOUT << " +" << LR;
}
interval.setValueNumberInfo(1, interval.getValNumInfo(0));
// Value#0 is now defined by the 2-addr instruction.
- interval.setValueNumberInfo(0, LiveInterval::VNInfo(DefIndex, ~0U, 0U));
+ interval.setValueNumberInfo(0, LiveInterval::VNInfo(DefIndex, 0U));
// Add the new live interval which replaces the range for the input copy.
LiveRange LR(DefIndex, RedefIndex, ValNo);
// We are about to delete CopyMI, so need to remove it as the 'instruction
// that defines this value #'. Update the the valnum with the new defining
// instruction #.
- IntB.setValueNumberInfo(BValNo, LiveInterval::VNInfo(FillerStart, ~0U, 0));
+ IntB.setValueNumberInfo(BValNo, LiveInterval::VNInfo(FillerStart, 0));
// Okay, we can merge them. We need to insert a new liverange:
// [ValLR.end, BLR.begin) of either value number, then we merge the
// Otherwise, use the specified value #.
LHSValNoAssignments[VN] = RHSValID;
if (VN != (unsigned)RHSValID)
- ValueNumberInfo[VN].def = ~1U;
+ ValueNumberInfo[VN].def = RHSValNoInfo.def;
else
ValueNumberInfo[VN] = RHSValNoInfo;
}