[llvm] [MachineBasicBlock] Don't split loop header successor if the terminator is unanalyzable (PR #170146)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 2 14:19:54 PST 2025


================
@@ -1425,14 +1425,13 @@ bool MachineBasicBlock::canSplitCriticalEdge(const MachineBasicBlock *Succ,
   // where both sides of the branches are always executed.
 
   if (MF->getTarget().requiresStructuredCFG()) {
+    if (!MLI)
+      return false;
+    const MachineLoop *L = MLI->getLoopFor(Succ);
     // If `Succ` is a loop header, splitting the critical edge will not
     // break structured CFG.
-    if (MLI) {
-      const MachineLoop *L = MLI->getLoopFor(Succ);
-      return L && L->getHeader() == Succ;
-    }
-
-    return false;
+    if (!L || L->getHeader() != Succ)
----------------
Artem-B wrote:

It would be useful to add a comment why we now fall through to the subsequent processing, instead of returning true.

Otherwise it's hard to tell whether the fall-through is intentional, and if it is, what's special about that case.

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


More information about the llvm-commits mailing list