[llvm-commits] [llvm] r55351 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Dan Gohman gohman at apple.com
Mon Aug 25 18:44:34 PDT 2008


Author: djg
Date: Mon Aug 25 20:44:34 2008
New Revision: 55351

URL: http://llvm.org/viewvc/llvm-project?rev=55351&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=55351&r1=55350&r2=55351&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Aug 25 20:44:34 2008
@@ -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);
   }
 }
 





More information about the llvm-commits mailing list