Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAG.cpp updated: 1.348 -> 1.349 --- Log message: Add RemoveDeadNode to remove a dead node and its (potentially) dead operands. --- Diffs of the changes: (+33 -0) SelectionDAG.cpp | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.348 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.349 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.348 Wed Oct 11 02:09:31 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Oct 12 15:34:05 2006 @@ -300,6 +300,39 @@ setRoot(Dummy.getValue()); } +void SelectionDAG::RemoveDeadNode(SDNode *N, std::vector<SDNode*> &Deleted) { + SmallVector<SDNode*, 16> DeadNodes; + DeadNodes.push_back(N); + + // Process the worklist, deleting the nodes and adding their uses to the + // worklist. + while (!DeadNodes.empty()) { + SDNode *N = DeadNodes.back(); + DeadNodes.pop_back(); + + // Take the node out of the appropriate CSE map. + RemoveNodeFromCSEMaps(N); + + // Next, brutally remove the operand list. This is safe to do, as there are + // no cycles in the graph. + for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) { + SDNode *Operand = I->Val; + Operand->removeUser(N); + + // Now that we removed this operand, see if there are no uses of it left. + if (Operand->use_empty()) + DeadNodes.push_back(Operand); + } + delete[] N->OperandList; + N->OperandList = 0; + N->NumOperands = 0; + + // Finally, remove N itself. + Deleted.push_back(N); + AllNodes.erase(N); + } +} + void SelectionDAG::DeleteNode(SDNode *N) { assert(N->use_empty() && "Cannot delete a node that is not dead!"); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits