[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
Mon Oct 2 10:52:36 PDT 2017


GorNishanov updated this revision to Diff 117390.
GorNishanov added a comment.

Moved the promotion to CoroEarly to make sure no optimization passes can intervene.

@hfinkel, I looked at your suggestion, but, I think it is difficult to make it work in the general case and the transformation should be done before coroutine is split.
Consider a case of a fire and forget coroutine (no final suspend point, so it cleans itself when it runs to completion.
Now, if we keep destination slot in the coroutine frame and try to patch up the load, similar to your suggestion, in the initial function, there is no safe place to place the load, since the coroutine frame can be destroyed by a different thread that resumed the coroutine and it managed to run to the completion before the initiating function finished. The approach in this patch is simple, uses existing algorithm and takes care of this case by making sure that cleanup slot is never stored in memory.


https://reviews.llvm.org/D37093

Files:
  lib/Transforms/Coroutines/CoroEarly.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37093.117390.patch
Type: text/x-patch
Size: 4333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171002/dc69aca8/attachment.bin>


More information about the llvm-commits mailing list