diff options
author | Chris Lattner <sabre@nondot.org> | 2005-08-29 21:59:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-08-29 21:59:31 +0000 |
commit | c738d000d56331f798f743977d57c236333df649 (patch) | |
tree | d66937acdc79c695236b463a597a6e147f2345ed /llvm/lib/CodeGen | |
parent | 835cbb364dfcdcd3f2ff9348040f59e9edb14151 (diff) | |
download | bcm5719-llvm-c738d000d56331f798f743977d57c236333df649.tar.gz bcm5719-llvm-c738d000d56331f798f743977d57c236333df649.zip |
Add a new API for Nate
llvm-svn: 23131
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index b47002f1165..dab757ef8a2 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -228,6 +228,33 @@ void SelectionDAG::DeleteNodeIfDead(SDNode *N, void *NodeSet) { delete N; } +void SelectionDAG::DeleteNode(SDNode *N) { + assert(N->use_empty() && "Cannot delete a node that is not dead!"); + + // First take this out of the appropriate CSE map. + RemoveNodeFromCSEMaps(N); + + // Remove it from the AllNodes list. + for (std::vector<SDNode*>::iterator I = AllNodes.begin(); ; ++I) { + assert(I != AllNodes.end() && "Node not in AllNodes list??"); + if (*I == N) { + // Erase from the vector, which is not ordered. + std::swap(*I, AllNodes.back()); + AllNodes.pop_back(); + break; + } + } + + // Drop all of the operands and decrement used nodes use counts. + while (!N->Operands.empty()) { + SDNode *O = N->Operands.back().Val; + N->Operands.pop_back(); + O->removeUser(N); + } + + delete N; +} + /// RemoveNodeFromCSEMaps - Take the specified node out of the CSE map that /// correspond to it. This is useful when we're about to delete or repurpose /// the node. We don't want future request for structurally identical nodes |