mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-13 09:33:50 +00:00
Delete nodes more efficiently
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5463 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5e7d0e2691
commit
d4400c8297
@ -1090,19 +1090,17 @@ void DSGraph::removeDeadNodes(unsigned Flags) {
|
||||
ScalarMap.erase(GlobalNodes[i].first);
|
||||
|
||||
// Loop over all unreachable nodes, dropping their references...
|
||||
std::vector<DSNode*> DeadNodes;
|
||||
DeadNodes.reserve(Nodes.size()); // Only one allocation is allowed.
|
||||
for (unsigned i = 0; i != Nodes.size(); ++i)
|
||||
if (!Alive.count(Nodes[i])) {
|
||||
DSNode *N = Nodes[i];
|
||||
std::swap(Nodes[i--], Nodes.back()); // move node to end of vector
|
||||
Nodes.pop_back(); // Erase node from alive list.
|
||||
DeadNodes.push_back(N); // Add node to our list of dead nodes
|
||||
N->dropAllReferences(); // Drop all outgoing edges
|
||||
|
||||
while (!N->getReferrers().empty())
|
||||
N->getReferrers().back()->setNode(0);
|
||||
delete N;
|
||||
}
|
||||
|
||||
// Delete all dead nodes...
|
||||
std::for_each(DeadNodes.begin(), DeadNodes.end(), deleter<DSNode>);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user