[llvm] [CoroEarly] Hide promise alloca for later passes (PR #139243)

Weibo He via llvm-commits llvm-commits at lists.llvm.org
Tue May 13 07:05:44 PDT 2025


NewSigma wrote:

> But why do we hack in CoroEarly pass? Can't we generate yet another intrinsic in the frontend?

The intrinsic cannot be `coro.promise` because we should not assume the frontend won't emit other `coro.promise` calls to the coroutine body. This would make later replacements infeasible.

We can certainly generate another intrinsic in the frontend. However, there have been too many coroutine-related intrinsics. I would personally prefer to avoid introducing new intrinsic unless necessary. `coro.promise` shall do it work well.

> why promise is different from other allocas in the purpose (avoid mis-optimization)?

Only the promise alloca is visible to the caller, whereas other allocas remain internal. This visibility difference accounts for the observed mis-optimization effect.

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


More information about the llvm-commits mailing list