diff options
author | Dan Gohman <gohman@apple.com> | 2009-01-19 22:39:36 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-01-19 22:39:36 +0000 |
commit | c53361294957b63a9c1e405256c6f0a81db1685c (patch) | |
tree | b5b61e884eb2c45d182538666836617682a06e2d /lib | |
parent | 549170206ecc31839723cb4b4de3d872a9402813 (diff) | |
download | external_llvm-c53361294957b63a9c1e405256c6f0a81db1685c.zip external_llvm-c53361294957b63a9c1e405256c6f0a81db1685c.tar.gz external_llvm-c53361294957b63a9c1e405256c6f0a81db1685c.tar.bz2 |
Remove SDNode's virtual destructor. This makes it impossible for
SDNode subclasses to keep state that requires non-trivial
destructors, however it was already effectively impossible,
since the destructor isn't actually ever called. There currently
aren't any SDNode subclasses affected by this, and in general
it's desireable to keep SDNode objects light-weight.
This eliminates the last virtual member function in the SDNode
class, so it eliminates the need for a vtable pointer, making
SDNode smaller.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62539 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 67 |
1 files changed, 14 insertions, 53 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index d8124e6..2a456dc 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -557,14 +557,7 @@ void SelectionDAG::RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes, DeadNodes.push_back(Operand); } - if (N->OperandsNeedDelete) - delete[] N->OperandList; - - N->OperandList = 0; - N->NumOperands = 0; - - // Finally, remove N itself. - NodeAllocator.Deallocate(AllNodes.remove(N)); + DeallocateNode(N); } } @@ -585,16 +578,23 @@ void SelectionDAG::DeleteNode(SDNode *N) { } void SelectionDAG::DeleteNodeNotInCSEMaps(SDNode *N) { + assert(N != AllNodes.begin()); + // Drop all of the operands and decrement used node's use counts. for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) I->getVal()->removeUser(std::distance(N->op_begin(), I), N); - if (N->OperandsNeedDelete) { + DeallocateNode(N); +} + +void SelectionDAG::DeallocateNode(SDNode *N) { + if (N->OperandsNeedDelete) delete[] N->OperandList; - N->OperandList = 0; - } - assert(N != AllNodes.begin()); + // Set the opcode to DELETED_NODE to help catch bugs when node + // memory is reallocated. + N->NodeType = ISD::DELETED_NODE; + NodeAllocator.Deallocate(AllNodes.remove(N)); } @@ -786,17 +786,8 @@ 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; - N->OperandList = 0; - } - - NodeAllocator.Deallocate(N); - } + while (!AllNodes.empty()) + DeallocateNode(AllNodes.begin()); } void SelectionDAG::clear() { @@ -4737,36 +4728,6 @@ unsigned SelectionDAG::AssignTopologicalOrder() { // SDNode Class //===----------------------------------------------------------------------===// -// Out-of-line virtual method to give class a home. -void SDNode::ANCHOR() {} -void UnarySDNode::ANCHOR() {} -void BinarySDNode::ANCHOR() {} -void TernarySDNode::ANCHOR() {} -void HandleSDNode::ANCHOR() {} -void ConstantSDNode::ANCHOR() {} -void ConstantFPSDNode::ANCHOR() {} -void GlobalAddressSDNode::ANCHOR() {} -void FrameIndexSDNode::ANCHOR() {} -void JumpTableSDNode::ANCHOR() {} -void ConstantPoolSDNode::ANCHOR() {} -void BasicBlockSDNode::ANCHOR() {} -void SrcValueSDNode::ANCHOR() {} -void MemOperandSDNode::ANCHOR() {} -void RegisterSDNode::ANCHOR() {} -void DbgStopPointSDNode::ANCHOR() {} -void LabelSDNode::ANCHOR() {} -void ExternalSymbolSDNode::ANCHOR() {} -void CondCodeSDNode::ANCHOR() {} -void ARG_FLAGSSDNode::ANCHOR() {} -void VTSDNode::ANCHOR() {} -void MemSDNode::ANCHOR() {} -void LoadSDNode::ANCHOR() {} -void StoreSDNode::ANCHOR() {} -void AtomicSDNode::ANCHOR() {} -void MemIntrinsicSDNode::ANCHOR() {} -void CallSDNode::ANCHOR() {} -void CvtRndSatSDNode::ANCHOR() {} - HandleSDNode::~HandleSDNode() { DropOperands(); } |