Actually recycle SDNode allocations. SelectionDAG is using
authorDan Gohman <gohman@apple.com>
Tue, 26 Aug 2008 01:44:34 +0000 (01:44 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 26 Aug 2008 01:44:34 +0000 (01:44 +0000)
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

lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index 3d620359558bd84490432d284afb747cf9e090ef..71a60fbff7e8d490cddf575edc74090654192caf 100644 (file)
@@ -523,7 +523,7 @@ void SelectionDAG::RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes,
     N->NumOperands = 0;
     
     // Finally, remove N itself.
-    AllNodes.remove(N);
+    NodeAllocator.Deallocate(AllNodes.remove(N));
   }
 }
 
@@ -551,7 +551,8 @@ void SelectionDAG::DeleteNodeNotInCSEMaps(SDNode *N) {
   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 @@ SelectionDAG::~SelectionDAG() {
 }
 
 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);
   }
 }