[C++ coroutines 0/7] Implement C++ coroutines.

Iain Sandoe iain@sandoe.co.uk
Thu Jan 9 12:36:00 GMT 2020


Nathan Sidwell <nathan@acm.org> wrote:

> On 11/17/19 5:23 AM, Iain Sandoe wrote:
>> This patch series is an initial implementation of a coroutine feature,
>> expected to be standardised in C++20.

This is the updated set after fixing review comments (both from folks on-list and
some private communications) and a few bugs.

NOTE: the coroutine implementation remains behind “-fcoroutines” it is not yet
enabled automatically for -std=c++2a (although that would be trivial to arrange).

The commits relevant to each patch are listed in the amended email header.

See below for the reason that there are now 7 patches instead of 6.

>> ABI
>> ---
> 
>> There is not need to add any new mangling, since the components of this are
>> regular functions with manipulation of the coroutine via a type-erased handle.
> 
> Ahem:
>> --- a/gcc/cp/operators.def
>> +++ b/gcc/cp/operators.def
>> @@ -87,6 +87,7 @@ DEF_OPERATOR ("++", PREINCREMENT_EXPR, "pp", OVL_OP_FLAG_UNARY)
>> DEF_OPERATOR ("--", PREDECREMENT_EXPR, "mm", OVL_OP_FLAG_UNARY)
>> DEF_OPERATOR ("->", COMPONENT_REF, "pt", OVL_OP_FLAG_UNARY)
>> DEF_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", OVL_OP_FLAG_UNARY)
>> +DEF_OPERATOR ("co_await", CO_AWAIT_EXPR, "aw", OVL_OP_FLAG_UNARY)
> 
> That looks mangly to me.  But perhaps such manglings are unreachable.

No, it is reachable and does matter.
To my surprise, this was never discussed in any of the ABI meetings (I guess to the other attendees it was “old news”).

In fact the mangling is in use in clang and EDG-based compilers “in the wild” and was first requested on the C++ABI list in 2015.  MSVC has a different mangling, but the binaries from that do not intersect with the other compilers.

It is now https://github.com/itanium-cxx-abi/cxx-abi/pull/87

I have implemented this in libiberty and tested with a build of binutils that c++filt DTRT.
There is now a patch #7 for that (in fact, it could be considered stand-alone, in that it allows c++filt to consume clang and EDG-based binaries).

Iain



More information about the Gcc-patches mailing list