diff options
-rw-r--r-- | include/llvm/CodeGen/LiveInterval.h | 39 | ||||
-rw-r--r-- | lib/CodeGen/LiveInterval.cpp | 9 | ||||
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 9 | ||||
-rw-r--r-- | lib/CodeGen/SimpleRegisterCoalescing.cpp | 4 |
4 files changed, 31 insertions, 30 deletions
diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index d24aec4eb8..508a8b0c25 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -87,17 +87,14 @@ namespace llvm { 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; @@ -143,7 +140,7 @@ namespace llvm { /// 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; } @@ -154,16 +151,22 @@ namespace llvm { 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 { @@ -176,7 +179,7 @@ namespace llvm { 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 diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp index a11a8f5e44..580cf44383 100644 --- a/lib/CodeGen/LiveInterval.cpp +++ b/lib/CodeGen/LiveInterval.cpp @@ -300,7 +300,7 @@ void LiveInterval::join(LiveInterval &Other, int *LHSValNoAssignments, // 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; @@ -508,14 +508,11 @@ void LiveInterval::print(std::ostream &OS, const MRegisterInfo *MRI) const { 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; - } } } } diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index c17f2ac90b..c286a1a09d 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -347,7 +347,6 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb, // Get the Idx of the defining instructions. unsigned defIndex = getDefIndex(MIIdx); - unsigned ValNum; unsigned SrcReg, DstReg; if (!tii_->isMoveInstr(*mi, SrcReg, DstReg)) @@ -378,6 +377,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb, LiveRange LR(defIndex, killIdx, ValNum); interval.addRange(LR); DOUT << " +" << LR << "\n"; + interval.addKillForValNum(ValNum, killIdx); return; } } @@ -412,10 +412,11 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb, // 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; } @@ -450,7 +451,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb, 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); diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp index a37a00545f..cead5e5240 100644 --- a/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -132,7 +132,7 @@ bool SimpleRegisterCoalescing::AdjustCopiesBackFrom(LiveInterval &IntA, LiveInte // 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 @@ -645,7 +645,7 @@ bool SimpleRegisterCoalescing::JoinIntervals(LiveInterval &LHS, LiveInterval &RH // 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; } |