[all-commits] [llvm/llvm-project] 06c1aa: [CoroEarly][IR] Clarify semantic of llvm.coro.end ...

Weibo He via All-commits all-commits at lists.llvm.org
Tue Apr 14 02:31:38 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 06c1aa3ca74cf73df07d1ef3fff9b476e5aedaab
      https://github.com/llvm/llvm-project/commit/06c1aa3ca74cf73df07d1ef3fff9b476e5aedaab
  Author: Weibo He <NewSigma at 163.com>
  Date:   2026-04-14 (Tue, 14 Apr 2026)

  Changed paths:
    M llvm/docs/Coroutines.rst
    M llvm/include/llvm/Transforms/Coroutines/CoroShape.h
    M llvm/lib/Transforms/Coroutines/CoroEarly.cpp
    M llvm/lib/Transforms/Coroutines/Coroutines.cpp
    M llvm/test/Transforms/Coroutines/coro-debug.ll
    R llvm/test/Transforms/Coroutines/gh105595.ll

  Log Message:
  -----------
  [CoroEarly][IR] Clarify semantic of llvm.coro.end (#191752)

We introduced a workaround for the following pattern in #139243:
``` LLVM
define void @fn() presplitcoroutine {
  %__promise = alloca ptr, align 8
  ...

coro.ret:
  call void @llvm.coro.end(ptr null, i1 false, token none)
  store ptr null, ptr %__promise, align 8
  ret void
}
```
where DSE considers `__promise` dead after the return and eliminates the
store, leading to a miscompilation.

However, after #151067, the problematic pattern is gone. And it
currently looks like:
``` LLVM
gro.conv:
  store ptr null, ptr %__promise, align 8
  br label %after.gro.conv

after.gro.conv:
  br i1 %body.done, label %coro.cleanup, label %coro.ret

coro.ret:
  call void @llvm.coro.end(ptr null, i1 false, token none)
  ret void
```
DSE cannot eliminate the store because `__promise` escapes through
`coro.id`, and `coro.end` post-dominates the store. It turns out that
accessing the coroutine frame after `coro.end` is not safe. This patch
proposes clarifying the semantics of `coro.end` and reverting the
workaround, as it confuses alias analyses. I have scanned the tests and
updated the uses of the coroutine frame after `coro.end`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list