[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
Tue Nov 7 15:57:56 PST 2017


GorNishanov added a comment.

In https://reviews.llvm.org/D37093#910964, @rjmccall wrote:

> In https://reviews.llvm.org/D37093#910951, @rjmccall wrote:
>
> > In https://reviews.llvm.org/D37093#910909, @GorNishanov wrote:
> >
> > > @rjmccall suggested to do the cleanup dest slot elimination wholesale for all functions in clang. (Not specific for coroutines).
> > >  That is a sweeping change :-), so, I don't mind still having this here to unblock Facebook and when the clang change lands, remove this part from llvm.
> >
> >
> > Well, I said that I wouldn't be opposed to cleaning up the cleanup dest slot unconditionally.  I expressed no opinion about whether that was a reasonable way to fix this problem in your representation.  (This doesn't affect my lowering as coro.end is always a terminator.)
>
>
> I think you probably do need to solve this problem more generally, as it sounds like any use of an alloca in the post-coro.end section of the function will lead to miscompiles.  It sounds like you have some control of the post-coro.end generated code, so maybe allocas don't normally affect you there — but from the fact that you have uses of the cleanup dest, I assume you're branching through cleanups, which means you have calls, which means you can have arbitrary code there if the callee is marked always_inline.


coro-early pass is run as early pass during "cleanup after a frontend" phase of the optimizer. Thus, arbitrarly inlined code cannot happen. I also put out for review an alternative fix that eliminates cleanup.dest.slot for coroutines in the CodeGenFunction::FinishFunction: https://reviews.llvm.org/D39768


https://reviews.llvm.org/D37093





More information about the llvm-commits mailing list