1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

GVNSink: Make ModelledPHIs constructor linear (and avoid edge case it worries about) by avoiding getIncomingValueForBlock

llvm-svn: 313702
This commit is contained in:
Daniel Berlin 2017-09-20 00:07:27 +00:00
parent 4f04848c69
commit cb1e4ba6da

View File

@ -206,14 +206,15 @@ class ModelledPHI {
public:
ModelledPHI() {}
ModelledPHI(const PHINode *PN) {
// BasicBlock comes first so we sort by basic block pointer order, then by value pointer order.
SmallVector<std::pair<BasicBlock *, Value *>, 4> Ops;
for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I)
Blocks.push_back(PN->getIncomingBlock(I));
std::sort(Blocks.begin(), Blocks.end());
// This assumes the PHI is already well-formed and there aren't conflicting
// incoming values for the same block.
for (auto *B : Blocks)
Values.push_back(PN->getIncomingValueForBlock(B));
Ops.push_back({PN->getIncomingBlock(I), PN->getIncomingValue(I)});
std::sort(Ops.begin(), Ops.end());
for (auto &P : Ops) {
Blocks.push_back(P.first);
Values.push_back(P.second);
}
}
/// Create a dummy ModelledPHI that will compare unequal to any other ModelledPHI
/// without the same ID.