From 1146728bfaeb471f675b805ceb27a08d28bbf468 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 26 Aug 2008 01:44:34 +0000 Subject: [PATCH] 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 --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 3d620359558..71a60fbff7e 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -523,7 +523,7 @@ void SelectionDAG::RemoveDeadNodes(SmallVectorImpl &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); } } -- 2.34.1