[llvm] Reapply "[coro][CoroSplit] Use `llvm.lifetime.end` to compute putting objects on the frame vs the stack (#90265) (PR #91372)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue May 7 19:40:37 PDT 2024
================
@@ -204,6 +204,91 @@ bool llvm::isPotentiallyReachableFromMany(
return false;
}
+bool llvm::isManyPotentiallyReachableFromMany(
+ SmallVectorImpl<BasicBlock *> &Worklist,
+ const SmallPtrSetImpl<const BasicBlock *> &StopSet,
+ const SmallPtrSetImpl<BasicBlock *> *ExclusionSet, const DominatorTree *DT,
+ const LoopInfo *LI) {
+ // When a stop block is unreachable, it's dominated from everywhere,
+ // regardless of whether there's a path between the two blocks.
+ SmallPtrSet<const BasicBlock *, 32> StopBBReachable;
+ for (auto *BB : StopSet) {
+ if (DT && DT->isReachableFromEntry(BB))
+ StopBBReachable.insert(BB);
+ }
+
+ // We can't skip directly from a block that dominates the stop block if the
+ // exclusion block is potentially in between.
+ if (ExclusionSet && !ExclusionSet->empty())
+ DT = nullptr;
+
+ // Normally any block in a loop is reachable from any other block in a loop,
+ // however excluded blocks might partition the body of a loop to make that
+ // untrue.
+ SmallPtrSet<const Loop *, 8> LoopsWithHoles;
+ if (LI && ExclusionSet) {
+ for (auto *BB : *ExclusionSet) {
+ if (const Loop *L = getOutermostLoop(LI, BB))
+ LoopsWithHoles.insert(L);
+ }
+ }
+
+ llvm::DenseMap<const BasicBlock *, const Loop *> StopLoops;
+ for (auto *StopBB : StopSet)
+ StopLoops[StopBB] = LI ? getOutermostLoop(LI, StopBB) : nullptr;
----------------
nikic wrote:
Why do we need this to be a map? Shouldn't this also be a set of StopLoops and then just check contains below?
https://github.com/llvm/llvm-project/pull/91372
More information about the llvm-commits
mailing list