[llvm] Reapply "[coro][CoroSplit] Use `llvm.lifetime.end` to compute putting objects on the frame vs the stack (#90265) (PR #91372)

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 20:39:08 PDT 2024


ChuanqiXu9 wrote:

> > The code duplication is slightly not good. Can we try to mitigate such problems by some template techniques?
> > For example, (may be):
> > ```
> > if constexpr (isMany) {
> >     if (StopSet.contains(BB))
> >       return true;
> > } else {
> >     if (BB == StopBB) // or BB == *StopSet.begin()
> >       return true;
> > }
> > ```
> 
> Hmm...would making `StopBB`/`StopSet` a `std::variant<const BasicBlock *, const SmallPtrSetImpl<const BasicBlock *> *>` work?
> 
> EDIT: changed the second `std::variant` template parameter to a pointer as its template parameters can't be reference types.

Maybe it can be slightly better to  have a isReachableImpl template function, where the type of `stop` can be a template, then we can judge the type directly in the `Impl` function. WDYT?

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


More information about the llvm-commits mailing list