InlineSpiller: Remove quadratic behavior.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181149 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2013-05-05 11:29:14 +00:00
parent 46abfcf418
commit e210df20d3

View File

@ -955,18 +955,21 @@ void InlineSpiller::reMaterializeAll() {
Edit->eliminateDeadDefs(DeadDefs, RegsToSpill); Edit->eliminateDeadDefs(DeadDefs, RegsToSpill);
// Get rid of deleted and empty intervals. // Get rid of deleted and empty intervals.
for (unsigned i = RegsToSpill.size(); i != 0; --i) { unsigned ResultPos = 0;
unsigned Reg = RegsToSpill[i-1]; for (unsigned i = 0, e = RegsToSpill.size(); i != e; ++i) {
if (!LIS.hasInterval(Reg)) { unsigned Reg = RegsToSpill[i];
RegsToSpill.erase(RegsToSpill.begin() + (i - 1)); if (!LIS.hasInterval(Reg))
continue; continue;
}
LiveInterval &LI = LIS.getInterval(Reg); LiveInterval &LI = LIS.getInterval(Reg);
if (!LI.empty()) if (LI.empty()) {
continue;
Edit->eraseVirtReg(Reg); Edit->eraseVirtReg(Reg);
RegsToSpill.erase(RegsToSpill.begin() + (i - 1)); continue;
} }
RegsToSpill[ResultPos++] = Reg;
}
RegsToSpill.erase(RegsToSpill.begin() + ResultPos, RegsToSpill.end());
DEBUG(dbgs() << RegsToSpill.size() << " registers to spill after remat.\n"); DEBUG(dbgs() << RegsToSpill.size() << " registers to spill after remat.\n");
} }