[PATCH] D37093: [coroutines] Promote cleanup.dest.slot-like allocas to registers to avoid storing them in the coroutine frame

Gor Nishanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 3 21:16:22 PDT 2017


GorNishanov added a comment.

In https://reviews.llvm.org/D37093#859380, @hfinkel wrote:

> In https://reviews.llvm.org/D37093#858860, @majnemer wrote:
>
> > Seems fragile. What if we run optimizations and transform the IR to another, different, version of the IR but the alloca is not promotable anymore? On occasion, the compiler can pessimize a code sequence and coroutine lowering should be resilient to such things.
>
>
> I agree. If we take a step back, what's necessary to make the current algorithm sound in general?


Most of the data in the coroutine folds neatly into two categories:

- Data that can be used after resume (all of the variables, temporaries and parameter copies in the user authored body.
- Data used only during coroutine creation when it is first invoked, such as parameters and coroutine return value, such as generator<int>, task<void>, etc.

Cleanup destination slot breaks this pattern. It is used both before coroutine state is created, during coroutine body execution and after coroutine state is destroyed.

I was thinking for awhile and was not able to come up with a simple algorithm to deal with it apart from the one offered in this patch.


https://reviews.llvm.org/D37093





More information about the llvm-commits mailing list