[llvm] [SelectionDAG] Add support to dump DAGs with sorted nodes (PR #161097)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 2 14:04:42 PDT 2025
================
@@ -1061,13 +1061,23 @@ static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) {
N->dump(G);
}
-LLVM_DUMP_METHOD void SelectionDAG::dump() const {
+LLVM_DUMP_METHOD void SelectionDAG::dump(bool Sorted) const {
dbgs() << "SelectionDAG has " << AllNodes.size() << " nodes:\n";
- for (const SDNode &N : allnodes()) {
+ auto dumpEachNode = [this](const SDNode &N) {
if (!N.hasOneUse() && &N != getRoot().getNode() &&
(!shouldPrintInline(N, this) || N.use_empty()))
DumpNodes(&N, 2, this);
+ };
+
+ if (Sorted) {
+ SmallVector<const SDNode *> SortedNodes(AllNodes.size());
----------------
mshockwave wrote:
Good point. It's updated now.
https://github.com/llvm/llvm-project/pull/161097
More information about the llvm-commits
mailing list