[llvm] [SelectionDAG] Add support to dump DAGs with sorted nodes (PR #161097)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 1 14:20:43 PDT 2025


================
@@ -12610,87 +12610,56 @@ void SelectionDAG::ReplaceAllUsesOfValuesWith(const SDValue *From,
 /// based on their topological order. It returns the maximum id and a vector
 /// of the SDNodes* in assigned order by reference.
 unsigned SelectionDAG::AssignTopologicalOrder() {
-  unsigned DAGSize = 0;
-
-  // SortedPos tracks the progress of the algorithm. Nodes before it are
-  // sorted, nodes after it are unsorted. When the algorithm completes
-  // it is at the end of the list.
-  allnodes_iterator SortedPos = allnodes_begin();
-
-  // Visit all the nodes. Move nodes with no operands to the front of
-  // the list immediately. Annotate nodes that do have operands with their
-  // operand count. Before we do this, the Node Id fields of the nodes
-  // may contain arbitrary values. After, the Node Id fields for nodes
-  // before SortedPos will contain the topological sort index, and the
-  // Node Id fields for nodes At SortedPos and after will contain the
-  // count of outstanding operands.
-  for (SDNode &N : llvm::make_early_inc_range(allnodes())) {
+  SmallVector<const SDNode *> SortedNodes(AllNodes.size());
----------------
mshockwave wrote:

Alright, I've reverted the code of AssignTopologicalOrder to its original one.

https://github.com/llvm/llvm-project/pull/161097


More information about the llvm-commits mailing list