mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
Avoid exponential growth of a table. It feels like
there should be a better way to do this. PR 8679. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120457 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -481,6 +481,23 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// InsertInOverdefinedPHIs - Insert an entry in the UsersOfOverdefinedPHIS
|
||||||
|
/// map for I and PN, but if one is there already, do not create another.
|
||||||
|
/// (Duplicate entries do not break anything directly, but can lead to
|
||||||
|
/// exponential growth of the table in rare cases.)
|
||||||
|
void InsertInOverdefinedPHIs(Instruction *I, PHINode *PN) {
|
||||||
|
std::multimap<PHINode*, Instruction*>::iterator J, E;
|
||||||
|
bool found = false;
|
||||||
|
tie(J, E) = UsersOfOverdefinedPHIs.equal_range(PN);
|
||||||
|
for (; J != E; ++J)
|
||||||
|
if (J->second == I) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
UsersOfOverdefinedPHIs.insert(std::make_pair(PN, I));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class InstVisitor<SCCPSolver>;
|
friend class InstVisitor<SCCPSolver>;
|
||||||
|
|
||||||
@ -973,9 +990,9 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
|
|||||||
if (Result.isConstant()) {
|
if (Result.isConstant()) {
|
||||||
markConstant(IV, &I, Result.getConstant());
|
markConstant(IV, &I, Result.getConstant());
|
||||||
// Remember that this instruction is virtually using the PHI node
|
// Remember that this instruction is virtually using the PHI node
|
||||||
// operands.
|
// operands.
|
||||||
UsersOfOverdefinedPHIs.insert(std::make_pair(PN1, &I));
|
InsertInOverdefinedPHIs(&I, PN1);
|
||||||
UsersOfOverdefinedPHIs.insert(std::make_pair(PN2, &I));
|
InsertInOverdefinedPHIs(&I, PN2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1056,8 +1073,8 @@ void SCCPSolver::visitCmpInst(CmpInst &I) {
|
|||||||
markConstant(&I, Result.getConstant());
|
markConstant(&I, Result.getConstant());
|
||||||
// Remember that this instruction is virtually using the PHI node
|
// Remember that this instruction is virtually using the PHI node
|
||||||
// operands.
|
// operands.
|
||||||
UsersOfOverdefinedPHIs.insert(std::make_pair(PN1, &I));
|
InsertInOverdefinedPHIs(&I, PN1);
|
||||||
UsersOfOverdefinedPHIs.insert(std::make_pair(PN2, &I));
|
InsertInOverdefinedPHIs(&I, PN2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user