mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-02 16:56:50 +00:00
If a MI's def is remat as well as spilled, and the store is later deemed dead, mark the def operand as isDead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41083 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a6a8663894
commit
c91f0b8068
@ -433,12 +433,39 @@ void AvailableSpills::ModifyStackSlotOrReMat(int SlotOrReMat) {
|
||||
/// InvalidateKills - MI is going to be deleted. If any of its operands are
|
||||
/// marked kill, then invalidate the information.
|
||||
static void InvalidateKills(MachineInstr &MI, BitVector &RegKills,
|
||||
std::vector<MachineOperand*> &KillOps) {
|
||||
std::vector<MachineOperand*> &KillOps,
|
||||
MachineInstr *NewDef = NULL) {
|
||||
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
|
||||
MachineOperand &MO = MI.getOperand(i);
|
||||
if (!MO.isReg() || !MO.isUse() || !MO.isKill())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (NewDef) {
|
||||
// Due to remat, it's possible this reg isn't being reused. That is,
|
||||
// the def of this reg (by prev MI) is now dead.
|
||||
bool FoundUse = false, Done = false;
|
||||
MachineBasicBlock::iterator I = MI, E = NewDef;
|
||||
++I; ++E;
|
||||
for (; !Done && I != E; ++I) {
|
||||
MachineInstr *NMI = I;
|
||||
for (unsigned j = 0, ee = NMI->getNumOperands(); j != ee; ++j) {
|
||||
MachineOperand &MO = NMI->getOperand(j);
|
||||
if (!MO.isReg() || MO.getReg() != Reg)
|
||||
continue;
|
||||
if (MO.isUse())
|
||||
FoundUse = true;
|
||||
Done = true; // Stop after scanning all the operands of this MI.
|
||||
}
|
||||
}
|
||||
if (!FoundUse) {
|
||||
// Def is dead!
|
||||
MachineBasicBlock::iterator MII = MI;
|
||||
MachineInstr *DefMI = prior(MII);
|
||||
MachineOperand *DefOp = DefMI->findRegisterDefOperand(Reg);
|
||||
assert(DefOp && "Missing def?");
|
||||
DefOp->setIsDead();
|
||||
}
|
||||
}
|
||||
if (KillOps[Reg] == &MO) {
|
||||
RegKills.reset(Reg);
|
||||
KillOps[Reg] = NULL;
|
||||
@ -1081,7 +1108,7 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
|
||||
if (LastStore) {
|
||||
DOUT << "Removed dead store:\t" << *LastStore;
|
||||
++NumDSE;
|
||||
InvalidateKills(*LastStore, RegKills, KillOps);
|
||||
InvalidateKills(*LastStore, RegKills, KillOps, &MI);
|
||||
MBB.erase(LastStore);
|
||||
VRM.RemoveFromFoldedVirtMap(LastStore);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user