[llvm] [BasicBlockUtils] Fixed LoopInfo update in UpdateAnalysisInformation() (PR #177147)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 05:33:24 PST 2026
================
@@ -1054,6 +1054,28 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, BasicBlock::iterator SplitPt,
return SplitBlockImpl(Old, SplitPt, DTU, /*DT=*/nullptr, LI, MSSAU, BBName);
}
+static bool hasReachableLoopEntry(const Loop &L, const DominatorTree &DT) {
+ for (const auto Pred : inverse_children<const BasicBlock *>(L.getHeader()))
+ if (!L.contains(Pred) && DT.isReachableFromEntry(Pred))
+ return true;
+
+ return false;
+}
+
+// Destroy the loop.
+static void Destroy(Loop *L, LoopInfo &LI) {
+ auto *ParentL = L->getParentLoop();
+ for (auto *BB : L->getBlocks())
+ LI.changeLoopFor(BB, ParentL);
----------------
ro-i wrote:
What's with sub-loops? Wouldn't they get corrupted by changing all the blocks to `ParentL` unconditionally?
Maybe have a look at:
https://github.com/llvm/llvm-project/blob/1eeb2eccf8b2397c49aaeefde61257c5be6fc905/llvm/lib/Transforms/Utils/FixIrreducible.cpp#L196-L211
https://github.com/llvm/llvm-project/pull/177147
More information about the llvm-commits
mailing list