This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [Coroutines] Support noop_coroutine for GCC
ClosedPublic

Authored by ChuanqiXu on Dec 21 2021, 11:16 PM.

Details

Summary

We didn't support noop_coroutine for GCC in previous conforming patch. So that GCC couldn't use noop_coroutine() defined in <coroutine>. And after this patch, GCC should be able to compile the whole <coroutine> header.

Diff Detail

Event Timeline

ChuanqiXu requested review of this revision.Dec 21 2021, 11:16 PM
ChuanqiXu created this revision.
Herald added a reviewer: Restricted Project. · View Herald TranscriptDec 21 2021, 11:16 PM

The changes in <__coroutine/noop_coroutine_handle.h> might be correct, but I have no idea and assume I'll never have any idea. :)
Who knows enough about coroutine innards to review this?

libcxx/include/__coroutine/noop_coroutine_handle.h
78

The double-underscore here seems suspicious. Could you make it a single underscore? or is this specific identifier magic to GCC somehow?

libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp
23–24

At this point, I think you could just remove this #if and start using the usual annotations, e.g. // UNSUPPORTED: clang-13 or whatever.

80–81

Let's keep these consistent with lines 60–61. I have no preference on the order or whether they end with , "", but let's be consistent one way or the other.

ChuanqiXu updated this revision to Diff 395958.Dec 22 2021, 6:56 PM

Address comments

I added @iains who is the original author of libstdc++'s coroutine. I am not sure if Iain would take a look. But I believe the implementation might be correct since I looked at the implementation of libstdc++'s implementation.

libcxx/include/__coroutine/noop_coroutine_handle.h
78

I guess you are referring the double-underscore in the middle instead of the start, right? My bad. It is my typo.

libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp
23–24

I think the line // UNSUPPORTED: libcpp-no-coroutines would filter clang-13 out.

80–81

We can't do that. Since noop_coroutine_handle::done() is constexpr and std::coroutine_handle<>::done() isn't constexpr.

libcxx/include/__coroutine/noop_coroutine_handle.h
78

Yep, I meant the double-underscore in the middle.

Also, please remove the trailing underscore in __dummy_resume_destroy_func_. Nobody's 100% sure whether we use trailing-underscore for data members or private members ;) but __dummy_resume_destroy_func_ is neither private nor data, so it definitely shouldn't have one. Just make it __dummy_resume_destroy_func().

libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp
23–24

No problem. I was just trying to guess the name of some compiler that might fail the condition #if __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC).

80–81

Oops, I hadn't noticed that these were regular assert instead of static_assert. So they can't use , ""; but at least you can put them in the same order: i.e., please swap lines 69 and 70.

ChuanqiXu added inline comments.Dec 22 2021, 8:35 PM
libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp
80–81

Yeah, but is is weird to see assert(X.y() && X) since it would crash if X is null. How do you think about swap lines 58 and 59?

libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp
80–81

Sure, swap either pair, as long as it ends up consistent.

ChuanqiXu updated this revision to Diff 396129.Dec 23 2021, 6:06 PM

Address comments

ChuanqiXu updated this revision to Diff 396251.Dec 26 2021, 6:11 PM

Rename __dummy_resume_destroy_func_ to __dummy_resume_destroy_func

ChuanqiXu marked 2 inline comments as done.Dec 26 2021, 6:57 PM
Quuxplusone added inline comments.
libcxx/include/__coroutine/noop_coroutine_handle.h
23–25
76–77
ChuanqiXu updated this revision to Diff 396267.Dec 26 2021, 9:49 PM

Address comments

ChuanqiXu marked 2 inline comments as done.Dec 26 2021, 9:49 PM
This revision was not accepted when it landed; it landed in state Needs Review.Dec 26 2021, 9:54 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.