[flang-commits] [flang] [flang][cuda] Keep delayed descriptor allocs out of CFG loops (PR #232992)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Sat Oct 17 20:28:55 PDT 2026


================
@@ -108,6 +110,17 @@ findDelayTarget(fir::DeclareOp declareOp, mlir::Block *entryBlock,
       return nullptr;
   }
 
+  // A block on a CFG cycle (e.g. the header of a DO loop that lowered to
+  // branches because it contains a RETURN) executes once per trip, and the
+  // alloc would replace the descriptor each time. Climb the dominator tree to
+  // the nearest block that is not on a cycle. Reachability covers irreducible
+  // cycles too, and the entry block has no predecessors, so it always ends.
+  while (common->isReachable(common)) {
+    mlir::DominanceInfoNode *idom = domInfo.getNode(common)->getIDom();
+    assert(idom && "entry block cannot be on a cycle");
----------------
clementval wrote:

Is this enough in a release build? What if somehow idiom is null. Should we check and return nullptr in that case? 

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


More information about the flang-commits mailing list