restore some code I removed in r85788, refactor it into

a shared place instead of duplicating it 4 times.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85792 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-11-02 06:28:16 +00:00
parent 574fa9e83c
commit e01985c95f

View File

@ -386,6 +386,20 @@ private:
if (BBExecutable.count(I.getParent())) // Inst is executable?
visit(I);
}
/// RemoveFromOverdefinedPHIs - If I has any entries in the
/// UsersOfOverdefinedPHIs map for PN, remove them now.
void RemoveFromOverdefinedPHIs(Instruction *I, PHINode *PN) {
if (UsersOfOverdefinedPHIs.empty()) return;
std::multimap<PHINode*, Instruction*>::iterator It, E;
tie(It, E) = UsersOfOverdefinedPHIs.equal_range(PN);
while (It != E) {
if (It->second == I)
UsersOfOverdefinedPHIs.erase(It++);
else
++It;
}
}
private:
friend class InstVisitor<SCCPSolver>;
@ -904,8 +918,8 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
// added ourselves to the UsersOfOverdefinedPHIs list for the PHIs,
// make sure to clean out any entries that we put there, for
// efficiency.
UsersOfOverdefinedPHIs.erase(PN1);
UsersOfOverdefinedPHIs.erase(PN2);
RemoveFromOverdefinedPHIs(&I, PN1);
RemoveFromOverdefinedPHIs(&I, PN2);
}
markOverdefined(&I);
@ -986,8 +1000,8 @@ void SCCPSolver::visitCmpInst(CmpInst &I) {
// added ourselves to the UsersOfOverdefinedPHIs list for the PHIs,
// make sure to clean out any entries that we put there, for
// efficiency.
UsersOfOverdefinedPHIs.erase(PN1);
UsersOfOverdefinedPHIs.erase(PN2);
RemoveFromOverdefinedPHIs(&I, PN1);
RemoveFromOverdefinedPHIs(&I, PN2);
}
markOverdefined(&I);