This is an archive of the discontinued LLVM Phabricator instance.

[Coroutines] Part14: Handle coroutines with no suspend points.
ClosedPublic

Authored by GorNishanov on Sep 9 2016, 10:17 AM.
Tokens
"Yellow Medal" token, awarded by GorNishanov.

Details

Summary

If coroutine has no suspend points, remove heap allocation and turn a coroutine into a normal function.

Also, if a pattern is detected that coroutine resumes or destroys itself prior to coro.suspend call, turn the suspend point into a simple jump to resume or cleanup label. This pattern occurs when coroutines are used to propagate errors in functions that return expected<T>.

Diff Detail

Repository
rL LLVM

Event Timeline

GorNishanov retitled this revision from to [Coroutines] Part14: Handle coroutines with no suspend points..
GorNishanov updated this object.
GorNishanov added a reviewer: majnemer.
GorNishanov added a subscriber: llvm-commits.
majnemer added inline comments.Sep 25 2016, 5:42 PM
lib/Transforms/Coroutines/CoroSplit.cpp
374 ↗(On Diff #70858)

vFrame does not matching our coding style.

378–379 ↗(On Diff #70858)

Please consistently brace.

425–426 ↗(On Diff #70858)

I think we should strip pointer casts before isa<Function>.

Implemented review feedback

GorNishanov marked 3 inline comments as done.Sep 25 2016, 8:50 PM
majnemer added inline comments.Sep 25 2016, 11:47 PM
lib/Transforms/Coroutines/CoroSplit.cpp
422–423 ↗(On Diff #72437)

Do we need this check? It seems redundant with the dyn_cast check which follows after.

Remove redundant isa<Function> test.

GorNishanov marked an inline comment as done.Sep 26 2016, 7:27 AM
majnemer accepted this revision.Sep 26 2016, 8:44 AM
majnemer edited edge metadata.

LGTM

This revision is now accepted and ready to land.Sep 26 2016, 8:44 AM
This revision was automatically updated to reflect the committed changes.