[llvm] [LoopInfo] Derive Loop::contains(BlockT*) from the block-to-loop map (PR #207613)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 00:51:53 PDT 2026


================
@@ -770,8 +766,11 @@ void LoopInfoBase<BlockT, LoopT>::verify(
     });
     BlockT *BB = BBIt != L->Blocks.end() ? *BBIt : nullptr;
     assert(BB && "orphaned block");
+    // Check the map against the (independent) block lists: L is its innermost
+    // loop (not in a deeper loop). Using contains() here would derive from
+    // BBMap itself and check nothing.
     for (LoopT *ChildLoop : *L)
-      assert(!ChildLoop->contains(BB) &&
+      assert(!llvm::is_contained(ChildLoop->getBlocks(), BB) &&
----------------
nikic wrote:

I'm concerned about complexity of this check for verify(). This looks like it can easily degenerate quadratically in practice.

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


More information about the llvm-commits mailing list