Count inserted spills and reloads more accurately.

Adjust counters when removing spill and reload instructions.

We still don't account for reloads being removed by eliminateDeadDefs().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139806 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2011-09-15 17:54:28 +00:00
parent 34f864fd38
commit 79c40a011b

View File

@ -34,16 +34,16 @@
using namespace llvm; using namespace llvm;
STATISTIC(NumSpilledRanges, "Number of spilled live ranges"); STATISTIC(NumSpilledRanges, "Number of spilled live ranges");
STATISTIC(NumSnippets, "Number of snippets included in spills"); STATISTIC(NumSnippets, "Number of spilled snippets");
STATISTIC(NumSpills, "Number of spills inserted"); STATISTIC(NumSpills, "Number of spills inserted");
STATISTIC(NumSpillsRemoved, "Number of spills removed");
STATISTIC(NumReloads, "Number of reloads inserted"); STATISTIC(NumReloads, "Number of reloads inserted");
STATISTIC(NumReloadsRemoved, "Number of reloads removed");
STATISTIC(NumFolded, "Number of folded stack accesses"); STATISTIC(NumFolded, "Number of folded stack accesses");
STATISTIC(NumFoldedLoads, "Number of folded loads"); STATISTIC(NumFoldedLoads, "Number of folded loads");
STATISTIC(NumRemats, "Number of rematerialized defs for spilling"); STATISTIC(NumRemats, "Number of rematerialized defs for spilling");
STATISTIC(NumOmitReloadSpill, "Number of omitted spills after reloads"); STATISTIC(NumOmitReloadSpill, "Number of omitted spills of reloads");
STATISTIC(NumHoistLocal, "Number of locally hoisted spills"); STATISTIC(NumHoists, "Number of hoisted spills");
STATISTIC(NumHoistGlobal, "Number of globally hoisted spills");
STATISTIC(NumRedundantSpills, "Number of redundant spills identified");
namespace { namespace {
class InlineSpiller : public Spiller { class InlineSpiller : public Spiller {
@ -715,10 +715,8 @@ bool InlineSpiller::hoistSpill(LiveInterval &SpillLI, MachineInstr *CopyMI) {
VRM.addSpillSlotUse(StackSlot, MII); VRM.addSpillSlotUse(StackSlot, MII);
DEBUG(dbgs() << "\thoisted: " << SVI.SpillVNI->def << '\t' << *MII); DEBUG(dbgs() << "\thoisted: " << SVI.SpillVNI->def << '\t' << *MII);
if (MBB == CopyMI->getParent()) ++NumSpills;
++NumHoistLocal; ++NumHoists;
else
++NumHoistGlobal;
return true; return true;
} }
@ -773,7 +771,8 @@ void InlineSpiller::eliminateRedundantSpills(LiveInterval &SLI, VNInfo *VNI) {
// eliminateDeadDefs won't normally remove stores, so switch opcode. // eliminateDeadDefs won't normally remove stores, so switch opcode.
MI->setDesc(TII.get(TargetOpcode::KILL)); MI->setDesc(TII.get(TargetOpcode::KILL));
DeadDefs.push_back(MI); DeadDefs.push_back(MI);
++NumRedundantSpills; ++NumSpillsRemoved;
--NumSpills;
} }
} }
} while (!WorkList.empty()); } while (!WorkList.empty());
@ -971,10 +970,10 @@ void InlineSpiller::reMaterializeAll() {
/// If MI is a load or store of StackSlot, it can be removed. /// If MI is a load or store of StackSlot, it can be removed.
bool InlineSpiller::coalesceStackAccess(MachineInstr *MI, unsigned Reg) { bool InlineSpiller::coalesceStackAccess(MachineInstr *MI, unsigned Reg) {
int FI = 0; int FI = 0;
unsigned InstrReg; unsigned InstrReg = TII.isLoadFromStackSlot(MI, FI);
if (!(InstrReg = TII.isLoadFromStackSlot(MI, FI)) && bool IsLoad = InstrReg;
!(InstrReg = TII.isStoreToStackSlot(MI, FI))) if (!IsLoad)
return false; InstrReg = TII.isStoreToStackSlot(MI, FI);
// We have a stack access. Is it the right register and slot? // We have a stack access. Is it the right register and slot?
if (InstrReg != Reg || FI != StackSlot) if (InstrReg != Reg || FI != StackSlot)
@ -983,6 +982,15 @@ bool InlineSpiller::coalesceStackAccess(MachineInstr *MI, unsigned Reg) {
DEBUG(dbgs() << "Coalescing stack access: " << *MI); DEBUG(dbgs() << "Coalescing stack access: " << *MI);
LIS.RemoveMachineInstrFromMaps(MI); LIS.RemoveMachineInstrFromMaps(MI);
MI->eraseFromParent(); MI->eraseFromParent();
if (IsLoad) {
++NumReloadsRemoved;
--NumReloads;
} else {
++NumSpillsRemoved;
--NumSpills;
}
return true; return true;
} }