mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Special cases are needed in renumbering when dealing with renumbering after a PHI has been removed. The interval previously defined
by the PHI needs to be extended to the beginning of its basic block, and the intervals that were inputs need to be trimmed to the end of their basic blocks. llvm-svn: 54070
This commit is contained in:
parent
9e3ea5a60c
commit
9408721750
@ -126,6 +126,7 @@ void LiveIntervals::computeNumbering() {
|
|||||||
MBB2IdxMap[MBB->getNumber()] = std::make_pair(StartIdx, MIIndex - 1);
|
MBB2IdxMap[MBB->getNumber()] = std::make_pair(StartIdx, MIIndex - 1);
|
||||||
Idx2MBBMap.push_back(std::make_pair(StartIdx, MBB));
|
Idx2MBBMap.push_back(std::make_pair(StartIdx, MBB));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(Idx2MBBMap.begin(), Idx2MBBMap.end(), Idx2MBBCompare());
|
std::sort(Idx2MBBMap.begin(), Idx2MBBMap.end(), Idx2MBBCompare());
|
||||||
|
|
||||||
if (!OldI2MI.empty())
|
if (!OldI2MI.empty())
|
||||||
@ -139,7 +140,7 @@ void LiveIntervals::computeNumbering() {
|
|||||||
// instruction or its predecessor.
|
// instruction or its predecessor.
|
||||||
unsigned index = LI->start / InstrSlots::NUM;
|
unsigned index = LI->start / InstrSlots::NUM;
|
||||||
unsigned offset = LI->start % InstrSlots::NUM;
|
unsigned offset = LI->start % InstrSlots::NUM;
|
||||||
if (offset == InstrSlots::LOAD) {
|
if (offset == InstrSlots::LOAD || LI->valno->def == ~0U) {
|
||||||
std::vector<IdxMBBPair>::const_iterator I =
|
std::vector<IdxMBBPair>::const_iterator I =
|
||||||
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), LI->start);
|
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), LI->start);
|
||||||
// Take the pair containing the index
|
// Take the pair containing the index
|
||||||
@ -157,7 +158,30 @@ void LiveIntervals::computeNumbering() {
|
|||||||
// following instruction.
|
// following instruction.
|
||||||
index = (LI->end - 1) / InstrSlots::NUM;
|
index = (LI->end - 1) / InstrSlots::NUM;
|
||||||
offset = LI->end % InstrSlots::NUM;
|
offset = LI->end % InstrSlots::NUM;
|
||||||
if (offset == InstrSlots::USE) {
|
if (LI->valno->hasPHIKill && !OldI2MI[index]) {
|
||||||
|
// Special handling for when this was previously killed by a PHI, but
|
||||||
|
// the PHI has now been removed. We need to trim the live interval
|
||||||
|
// to die at the end of the preceding block.
|
||||||
|
std::vector<IdxMBBPair>::const_iterator I =
|
||||||
|
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), LI->end);
|
||||||
|
// Take the pair containing the index
|
||||||
|
std::vector<IdxMBBPair>::const_iterator J =
|
||||||
|
((I != OldI2MBB.end() && I->first > index) ||
|
||||||
|
(I == OldI2MBB.end() && OldI2MBB.size()>0)) ? (I-1): I;
|
||||||
|
|
||||||
|
MachineBasicBlock* StartMBB = J->second;
|
||||||
|
MachineBasicBlock* CurrMBB = J->second;
|
||||||
|
|
||||||
|
while (CurrMBB == StartMBB) {
|
||||||
|
while (index > 0 && !OldI2MI[index]) --index;
|
||||||
|
CurrMBB = OldI2MI[index]->getParent();
|
||||||
|
if (!StartMBB) StartMBB = CurrMBB;
|
||||||
|
|
||||||
|
--index;
|
||||||
|
}
|
||||||
|
|
||||||
|
LI->end = getMBBEndIdx(CurrMBB) + 1;
|
||||||
|
} else if (offset == InstrSlots::USE) {
|
||||||
std::vector<IdxMBBPair>::const_iterator I =
|
std::vector<IdxMBBPair>::const_iterator I =
|
||||||
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), LI->end);
|
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), LI->end);
|
||||||
// Take the pair containing the index
|
// Take the pair containing the index
|
||||||
@ -179,11 +203,13 @@ void LiveIntervals::computeNumbering() {
|
|||||||
// Remap the VNInfo def index, which works the same as the
|
// Remap the VNInfo def index, which works the same as the
|
||||||
// start indices above.
|
// start indices above.
|
||||||
VNInfo* vni = LI->valno;
|
VNInfo* vni = LI->valno;
|
||||||
|
if (vni->def != ~0U) {
|
||||||
index = vni->def / InstrSlots::NUM;
|
index = vni->def / InstrSlots::NUM;
|
||||||
offset = vni->def % InstrSlots::NUM;
|
offset = vni->def % InstrSlots::NUM;
|
||||||
if (offset == InstrSlots::LOAD) {
|
if (offset == InstrSlots::LOAD) {
|
||||||
std::vector<IdxMBBPair>::const_iterator I =
|
std::vector<IdxMBBPair>::const_iterator I =
|
||||||
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), vni->def);
|
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(),
|
||||||
|
vni->def);
|
||||||
// Take the pair containing the index
|
// Take the pair containing the index
|
||||||
std::vector<IdxMBBPair>::const_iterator J =
|
std::vector<IdxMBBPair>::const_iterator J =
|
||||||
((I != OldI2MBB.end() && I->first > index) ||
|
((I != OldI2MBB.end() && I->first > index) ||
|
||||||
@ -194,13 +220,38 @@ void LiveIntervals::computeNumbering() {
|
|||||||
} else {
|
} else {
|
||||||
vni->def = mi2iMap_[OldI2MI[index]] + offset;
|
vni->def = mi2iMap_[OldI2MI[index]] + offset;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remap the VNInfo kill indices, which works the same as
|
// Remap the VNInfo kill indices, which works the same as
|
||||||
// the end indices above.
|
// the end indices above.
|
||||||
for (size_t i = 0; i < vni->kills.size(); ++i) {
|
for (size_t i = 0; i < vni->kills.size(); ++i) {
|
||||||
index = (vni->kills[i]-1) / InstrSlots::NUM;
|
index = (vni->kills[i]-1) / InstrSlots::NUM;
|
||||||
offset = vni->kills[i] % InstrSlots::NUM;
|
offset = vni->kills[i] % InstrSlots::NUM;
|
||||||
if (offset == InstrSlots::USE) {
|
|
||||||
|
if (LI->valno->hasPHIKill && !OldI2MI[index]) {
|
||||||
|
// Special handling for when this was previously killed by a PHI,
|
||||||
|
// but the PHI has now been removed. We need to trim the live
|
||||||
|
// interval to die at the end of the preceding block.
|
||||||
|
std::vector<IdxMBBPair>::const_iterator I =
|
||||||
|
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), LI->end);
|
||||||
|
// Take the pair containing the index
|
||||||
|
std::vector<IdxMBBPair>::const_iterator J =
|
||||||
|
((I != OldI2MBB.end() && I->first > index) ||
|
||||||
|
(I == OldI2MBB.end() && OldI2MBB.size()>0)) ? (I-1): I;
|
||||||
|
|
||||||
|
MachineBasicBlock* StartMBB = J->second;
|
||||||
|
MachineBasicBlock* CurrMBB = J->second;
|
||||||
|
|
||||||
|
while (CurrMBB == StartMBB) {
|
||||||
|
while (index > 0 && !OldI2MI[index]) --index;
|
||||||
|
CurrMBB = OldI2MI[index]->getParent();
|
||||||
|
if (!StartMBB) StartMBB = CurrMBB;
|
||||||
|
|
||||||
|
--index;
|
||||||
|
}
|
||||||
|
|
||||||
|
vni->kills[i] = getMBBEndIdx(CurrMBB) + 1;
|
||||||
|
} else if (offset == InstrSlots::USE) {
|
||||||
std::vector<IdxMBBPair>::const_iterator I =
|
std::vector<IdxMBBPair>::const_iterator I =
|
||||||
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), vni->kills[i]);
|
std::lower_bound(OldI2MBB.begin(), OldI2MBB.end(), vni->kills[i]);
|
||||||
// Take the pair containing the index
|
// Take the pair containing the index
|
||||||
|
Loading…
Reference in New Issue
Block a user