restore some code I removed in r85788, refactor it into

a shared place instead of duplicating it 4 times.

llvm-svn: 85792
This commit is contained in:
Chris Lattner 2009-11-02 06:28:16 +00:00
parent 4910b656b2
commit 5503328332
1 changed files with 18 additions and 4 deletions

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);