[Mlir-commits] [llvm] [mlir] [LoopInfo] Store blocks using Euler tour representation (PR #211485)
Alexis Engelke
llvmlistbot at llvm.org
Fri Jul 24 00:39:24 PDT 2026
================
@@ -636,6 +648,49 @@ template <class BlockT, class LoopT> class LoopInfoBase {
return Number < BBMap.size() ? BBMap[Number] : nullptr;
}
+ /// AllocateLoop for analyze(): stash \p Header (see pendingHeader).
+ /// getHeader() only works once the layout carve has replaced the stash with
+ /// the loop's block list.
+ LoopT *allocateLoop(BlockT *Header) {
+ LoopT *L = AllocateLoop();
+ L->BlockData = reinterpret_cast<BlockT **>(Header);
+ return L;
+ }
+
+ /// The header of a loop under construction, stashed in BlockData until the
+ /// layout carve builds the block list.
+ static BlockT *pendingHeader(const LoopT *L) {
+ return reinterpret_cast<BlockT *>(L->BlockData);
+ }
+
+ void discoverAndMapSubloop(LoopT *L, BlockT *Header,
+ ArrayRef<BlockT *> Backedges,
+ const DominatorTreeBase<BlockT, false> &DomTree);
+
+ /// True if \p L's block list is a borrowed slice of BlockLayout rather than
+ /// a private allocation.
+ bool hasBorrowedBlocks(const LoopT &L) const {
+ return L.BlockData >= BlockLayout.get() &&
+ L.BlockData < BlockLayout.get() + BlockLayoutLen;
----------------
aengelke wrote:
This comparison is UB if not borrowed?
https://github.com/llvm/llvm-project/pull/211485
More information about the Mlir-commits
mailing list