[llvm] [CycleInfo] Represent cycles by an opaque handle. NFC (PR #210117)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 23:19:07 PDT 2026


================
@@ -1022,59 +1012,58 @@ const CycleT *getExtDivCycle(const CycleInfoT &CI, const CycleT *Cycle,
 ///
 /// This checks the "diverged entry" criterion defined in the
 /// docs/ConvergenceAnalysis.html.
-template <typename ContextT, typename CycleInfoT, typename CycleT,
+template <typename ContextT, typename CycleInfoT, typename CycleRef,
           typename BlockT, typename DominatorTreeT>
-const CycleT *getIntDivCycle(const CycleInfoT &CI, const CycleT *Cycle,
-                             const BlockT *DivTermBlock,
-                             const BlockT *JoinBlock, const DominatorTreeT &DT,
-                             ContextT &Context) {
+CycleRef getIntDivCycle(const CycleInfoT &CI, CycleRef Cycle,
+                        const BlockT *DivTermBlock, const BlockT *JoinBlock,
+                        const DominatorTreeT &DT, ContextT &Context) {
   LLVM_DEBUG(dbgs() << "examine join " << Context.print(JoinBlock)
                     << " for internal branch " << Context.print(DivTermBlock)
                     << "\n");
   if (DT.properlyDominates(DivTermBlock, JoinBlock))
-    return nullptr;
+    return CycleRef();
 
   // Find the smallest common cycle, if one exists.
-  assert(Cycle && CI.contains(*Cycle, JoinBlock));
-  while (Cycle && !CI.contains(*Cycle, DivTermBlock)) {
-    Cycle = CI.getParentCycle(*Cycle);
+  assert(Cycle && CI.contains(Cycle, JoinBlock));
+  while (Cycle && !CI.contains(Cycle, DivTermBlock)) {
+    Cycle = CI.getParentCycle(Cycle);
   }
-  if (!Cycle || CI.isReducible(*Cycle))
-    return nullptr;
+  if (!Cycle || CI.isReducible(Cycle))
+    return CycleRef();
 
-  if (DT.properlyDominates(CI.getHeader(*Cycle), JoinBlock))
-    return nullptr;
+  if (DT.properlyDominates(CI.getHeader(Cycle), JoinBlock))
+    return CycleRef();
 
-  LLVM_DEBUG(dbgs() << "  header " << Context.print(CI.getHeader(*Cycle))
+  LLVM_DEBUG(dbgs() << "  header " << Context.print(CI.getHeader(Cycle))
                     << " does not dominate join\n");
 
-  const auto *Parent = CI.getParentCycle(*Cycle);
-  while (Parent && !DT.properlyDominates(CI.getHeader(*Parent), JoinBlock)) {
-    LLVM_DEBUG(dbgs() << "  header " << Context.print(CI.getHeader(*Parent))
+  CycleRef Parent = CI.getParentCycle(Cycle);
+  while (Parent && !DT.properlyDominates(CI.getHeader(Parent), JoinBlock)) {
+    LLVM_DEBUG(dbgs() << "  header " << Context.print(CI.getHeader(Parent))
                       << " does not dominate join\n");
     Cycle = Parent;
-    Parent = CI.getParentCycle(*Parent);
+    Parent = CI.getParentCycle(Parent);
   }
 
   LLVM_DEBUG(dbgs() << "  cycle made divergent by internal branch\n");
   return Cycle;
 }
 
-template <typename ContextT, typename CycleInfoT, typename CycleT,
+template <typename ContextT, typename CycleInfoT, typename CycleRef,
----------------
aengelke wrote:

No need for typename CycleRef? (Also on other occasions.)

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


More information about the llvm-commits mailing list