Actually recycle SDNode allocations. SelectionDAG is using
RecyclingAllocator, but this change is needed for the nodes
to actually be recycled. This cuts SelectionDAG's memory
usage high-water-mark in half in some cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55351 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 3d62035..71a60fb 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -523,7 +523,7 @@
N->NumOperands = 0;
// Finally, remove N itself.
- AllNodes.remove(N);
+ NodeAllocator.Deallocate(AllNodes.remove(N));
}
}
@@ -551,7 +551,8 @@
if (N->OperandsNeedDelete)
delete[] N->OperandList;
- AllNodes.remove(N);
+ assert(N != AllNodes.begin());
+ NodeAllocator.Deallocate(AllNodes.remove(N));
}
/// RemoveNodeFromCSEMaps - Take the specified node out of the CSE map that
@@ -777,11 +778,14 @@
}
void SelectionDAG::allnodes_clear() {
+ assert(&*AllNodes.begin() == &EntryNode);
+ AllNodes.remove(AllNodes.begin());
while (!AllNodes.empty()) {
SDNode *N = AllNodes.remove(AllNodes.begin());
N->SetNextInBucket(0);
if (N->OperandsNeedDelete)
delete [] N->OperandList;
+ NodeAllocator.Deallocate(N);
}
}