[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:02:25 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
----------------
alanzhao1 wrote:

This algorithm as described would not work.

The problem is that checking for `lifetime.start` -> `coro.suspend` -> `lifetime.end` doesn't cover the case where `lifetime.end` is missing, which is the original bug.

Even if we modify the algorithm to check for `lifetime.end`, `unreachable`, and `return`, we would still need to make sure there is no `lifetime.end` between the `lifetime.start` and `coro.suspend` (since that would mean the object can live on the stack). The simpler algorithm therefore is to just check for `lifetime.start` -> (no `lifetime.end`) -> `coro.suspend`.

https://github.com/llvm/llvm-project/pull/90265


More information about the llvm-commits mailing list