[llvm] [SPIR-V] Fix block sorting with irreducible CFG (PR #116996)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 21 08:47:39 PST 2024


================
@@ -525,6 +525,12 @@ size_t PartialOrderingVisitor::GetNodeRank(BasicBlock *BB) const {
       continue;
 
     auto Iterator = BlockToOrder.end();
+    // This block hasn't been ranked yet. Ignoring.
+    // This doesn't happen often, but when dealing with irreducible CFG, we have
+    // to rank nodes without knowing the rank of all their predecessors.
+    if (Iterator == BlockToOrder.end())
----------------
Keenuts wrote:

All right, extended the test to also verify the rank value (used in the partial traversal function), and fixed the code. Thanks!

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


More information about the llvm-commits mailing list