Factor out the code for deleting a formula from an LSRUse into

a helper function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104079 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-05-18 22:39:15 +00:00
parent 6458ff9230
commit d69d62833a

View File

@ -942,6 +942,7 @@ public:
AllFixupsOutsideLoop(true) {} AllFixupsOutsideLoop(true) {}
bool InsertFormula(const Formula &F); bool InsertFormula(const Formula &F);
void DeleteFormula(Formula &F);
void check() const; void check() const;
@ -979,6 +980,12 @@ bool LSRUse::InsertFormula(const Formula &F) {
return true; return true;
} }
/// DeleteFormula - Remove the given formula from this use's list.
void LSRUse::DeleteFormula(Formula &F) {
std::swap(F, Formulae.back());
Formulae.pop_back();
}
void LSRUse::print(raw_ostream &OS) const { void LSRUse::print(raw_ostream &OS) const {
OS << "LSR Use: Kind="; OS << "LSR Use: Kind=";
switch (Kind) { switch (Kind) {
@ -2631,8 +2638,7 @@ void LSRInstance::FilterOutUndesirableDedicatedRegisters() {
#ifndef NDEBUG #ifndef NDEBUG
Changed = true; Changed = true;
#endif #endif
std::swap(F, LU.Formulae.back()); LU.DeleteFormula(F);
LU.Formulae.pop_back();
--FIdx; --FIdx;
--NumForms; --NumForms;
continue; continue;
@ -2728,8 +2734,7 @@ void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
Formula &F = LU.Formulae[i]; Formula &F = LU.Formulae[i];
if (!F.referencesReg(Best)) { if (!F.referencesReg(Best)) {
DEBUG(dbgs() << " Deleting "; F.print(dbgs()); dbgs() << '\n'); DEBUG(dbgs() << " Deleting "; F.print(dbgs()); dbgs() << '\n');
std::swap(LU.Formulae.back(), F); LU.DeleteFormula(F);
LU.Formulae.pop_back();
--e; --e;
--i; --i;
assert(e != 0 && "Use has no formulae left! Is Regs inconsistent?"); assert(e != 0 && "Use has no formulae left! Is Regs inconsistent?");