[llvm] Require GraphHasNodeNumbers in llvm::LoopInfoBase; drop the DenseMap fallback (PR #207905)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 00:36:21 PDT 2026


================
@@ -684,22 +682,14 @@ template <class BlockT, class LoopT> class LoopInfoBase {
   /// This should be used by transformations that restructure the loop hierarchy
   /// tree.
   void changeLoopFor(const BlockT *BB, LoopT *L) {
-    if constexpr (GraphHasNodeNumbers<const BlockT *>) {
-      verifyBlockNumberEpoch(BB->getParent());
-      unsigned Number = GraphTraits<const BlockT *>::getNumber(BB);
-      if (Number >= BBMap.size()) {
-        unsigned Max = GraphTraits<decltype(BB->getParent())>::getMaxNumber(
-            BB->getParent());
-        BBMap.resize(Number >= Max ? Number + 1 : Max);
-      }
-      BBMap[Number] = L;
-    } else {
-      if (!L) {
-        BBMap.erase(BB);
-        return;
-      }
-      BBMap[BB] = L;
+    verifyBlockNumberEpoch(BB->getParent());
+    unsigned Number = GraphTraits<const BlockT *>::getNumber(BB);
+    if (Number >= BBMap.size()) {
+      unsigned Max =
+          GraphTraits<decltype(BB->getParent())>::getMaxNumber(BB->getParent());
+      BBMap.resize(Number >= Max ? Number + 1 : Max);
----------------
MaskRay wrote:

Done. Added assert.

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


More information about the llvm-commits mailing list