[llvm] [coro][CoroSplit] Use `llvm.lifetime.end` to compute putting objects on the frame vs the stack (PR #90265)
Alan Zhao via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 15:11:26 PDT 2024
================
@@ -1614,6 +1621,24 @@ struct AllocaUseVisitor : PtrUseVisitor<AllocaUseVisitor> {
// suspend point between lifetime markers. This should also cover the
// case of a single lifetime.start intrinsic in a loop with suspend point.
if (PI.isEscaped()) {
+ // If there is no explicit lifetime.end, then assume the address can
+ // cross suspension points.
+ if (LifetimeEndBBs.empty())
+ return true;
+
+ // If there is a path from a lifetime.start to a suspend without a
+ // corresponding lifetime.end, then the alloca's lifetime persists
+ // beyond that suspension point and the alloca must go on the frame.
+ for (AnyCoroSuspendInst *SuspendInst : CoroShape.CoroSuspends) {
+ SmallVector<BasicBlock *> LifetimeStartsBB;
+ for (IntrinsicInst *II : LifetimeStarts)
+ LifetimeStartsBB.push_back(II->getParent());
+ if (isPotentiallyReachableFromMany(LifetimeStartsBB,
----------------
alanzhao1 wrote:
Any solution to the problem would require answering the question "Is there a path from `BasicBlock` A to `BasicBlock` B **without** going through `BasicBlock`s { C, D, E, ...}. The current logic caches whether a path _may_ go through a suspend point - it doesn't answer the reverse question and I'm not sure if that's even cacheable since we have to provide a new set of `BasicBlock`s for each `alloca` (since each `alloca` has its own set of `llvm.coro.end`s)
https://github.com/llvm/llvm-project/pull/90265
More information about the llvm-commits
mailing list