This is an archive of the discontinued LLVM Phabricator instance.

[coroutines] Add support for symmetric control transfer (musttail on coro.resumes followed by a suspend)
ClosedPublic

Authored by GorNishanov on Aug 24 2017, 3:59 PM.

Details

Summary

Add musttail to any resume instructions that is immediately followed by a
suspend (i.e. ret). We do this even in -O0 to support guaranteed tail call
for symmetrical coroutine control transfer (C++ Coroutines TS extension).
This transformation is done only in the resume part of the coroutine that has
identical signature and calling convention as the coro.resume call.

Diff Detail

Event Timeline

GorNishanov created this revision.Aug 24 2017, 3:59 PM
GorNishanov planned changes to this revision.Aug 24 2017, 5:21 PM
GorNishanov edited edge metadata.

Need to handle PHI nodes as well on the way to SwitchInst representing the suspend.

On the way to ret instruction track the incoming values of PHINodes and select correct case branch for SwitchInst which is used to implement a suspend point

This revision is now accepted and ready to land.Aug 24 2017, 7:23 PM
This revision was automatically updated to reflect the committed changes.