[Mlir-commits] [llvm] [mlir] [LoopInfo] Store blocks using Euler tour representation (PR #211485)
Alexis Engelke
llvmlistbot at llvm.org
Fri Jul 24 08:44:23 PDT 2026
================
@@ -600,14 +546,63 @@ void LoopInfoBase<BlockT, LoopT>::analyze(const DomTreeBase<BlockT> &DomTree) {
}
// Perform a backward CFG traversal to discover and map blocks in this loop.
if (!Backedges.empty()) {
- LoopT *L = AllocateLoop(Header);
- discoverAndMapSubloop(L, ArrayRef<BlockT *>(Backedges), this, DomTree);
+ HasLoops = true;
+ LoopT *L = allocateLoop(Header);
+ discoverAndMapSubloop(L, Header, Backedges, DomTree);
+ }
+ }
+ // Most functions have no loops; skip the layout construction.
+ if (!HasLoops)
+ return;
+
+ // Record each in-loop block with its innermost loop in forward CFG postorder,
+ // and build the loop list in PO.
+ SmallVector<std::pair<BlockT *, LoopT *>, 32> PO;
+ SmallVector<LoopT *, 4> LoopsPO;
+ PO.reserve(BBMap.size());
+ for (BlockT *BB : post_order(DomRoot->getBlock())) {
----------------
aengelke wrote:
Make ParentT a non const-derived pointer? (Not too important, but I personally hate that we have post_order<BasicBlock *>, post_order<const BasicBlock *>, post_order<Function *>, and post_order<const Function *> -- ending up in the binary doing 99.9% the same thing.)
https://github.com/llvm/llvm-project/pull/211485
More information about the Mlir-commits
mailing list