This is an archive of the discontinued LLVM Phabricator instance.

[Coroutines] Remove CoroElide from O0 pipeline
ClosedPublic

Authored by lxfind on Jun 28 2021, 4:12 PM.

Details

Summary

CoroElide pass works only when a post-split coroutine is inlined into another post-split coroutine.
In O0, there is no inlining after CoroSplit, and hence no CoroElide can happen.
It's useless to put CoroElide pass in the O0 pipeline and it will never be triggered (unless I miss anything).

Diff Detail

Event Timeline

lxfind created this revision.Jun 28 2021, 4:12 PM
lxfind requested review of this revision.Jun 28 2021, 4:12 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 28 2021, 4:12 PM
lxfind updated this revision to Diff 355073.Jun 28 2021, 5:05 PM

update tests

On O0, it is possible to inline if the user marked the function with always_inline.
Since CoroElide is kind of optimization, it should be OK to skip in O0.
Out of curiosity, what's the reason that you want to remove it?

On O0, it is possible to inline if the user marked the function with always_inline.
Since CoroElide is kind of optimization, it should be OK to skip in O0.
Out of curiosity, what's the reason that you want to remove it?

Coroutine functions cannot be inlined before splitting, even if it's marked "always_inline" (in fact, we should make it illegal to mark a coroutine "always_inline", because there is no guarantee that a coroutine can be fully inlined, GCC does that).

Coroutine functions cannot be inlined before splitting, even if it's marked "always_inline"

Yeah, but it may be inlined after splitting, which could trigger coro elide.

in fact, we should make it illegal to mark a coroutine "always_inline", because there is no guarantee that a coroutine can be fully inlined, GCC does that

To my understanding, it looks like that we shouldn't inline it since we couldn't inline all parts of the function. Is this what you want to say?
I think it may be a problem that we can't inline the full coroutine. But it's not the reason to forbid it.


Coro Elide is not defined in the standard (although it comes up in the proposal). So it should be a compiler optimization. In this way, it should be OK to remove it in O0.

Yeah, but it may be inlined after splitting, which could trigger coro elide.

In O0, there is no inliner pass (after CoroSplit), so inlining should never happen.

in fact, we should make it illegal to mark a coroutine "always_inline", because there is no guarantee that a coroutine can be fully inlined, GCC does that

To my understanding, it looks like that we shouldn't inline it since we couldn't inline all parts of the function. Is this what you want to say?
I think it may be a problem that we can't inline the full coroutine. But it's not the reason to forbid it.

That's a separate topic though. Let's agree on this diff first and then I can explain more about the always_inline issue.


Coro Elide is not defined in the standard (although it comes up in the proposal). So it should be a compiler optimization. In this way, it should be OK to remove it in O0.

ChuanqiXu accepted this revision.Jun 28 2021, 7:24 PM

That's a separate topic though. Let's agree on this diff first and then I can explain more about the always_inline issue.

Yeah, maybe we should discuss it on the llvm-dev thread.

This revision is now accepted and ready to land.Jun 28 2021, 7:24 PM
This revision was automatically updated to reflect the committed changes.