lewissbaker / cppcoro

A library of C++ coroutine abstractions for the coroutines TS
MIT License
3.43k stars 472 forks source link

Merge generic_ops branch into master #51

Closed lewissbaker closed 6 years ago

lewissbaker commented 7 years ago

This updates many of the operations to work on arbitrary awaitable types rather than only on task and shared_task.

lewissbaker commented 7 years ago

Note that changes in the branch are currently causing test failures under Clang optimised builds.

Seems to be hitting a compiler bug in code-generation of when_all_ready() body where it elides the allocation of one of the make_when_all_task coroutines and allocates the coroutine-frame on the stack-frame of when_all_ready() even though the lifetime of the coroutine extends beyond the when_all_ready() stack-frame.

ericniebler commented 7 years ago

Have you filed a compiler but yet?

lewissbaker commented 7 years ago

I have notified Gor via Slack but haven't filed to LLVM bug tracker yet. I was working on trying to reduce the 2000 line test-case to something a bit smaller first...

lewissbaker commented 7 years ago

Logged as https://bugs.llvm.org/show_bug.cgi?id=34897

lewissbaker commented 7 years ago

A workaround for this issue seems to be to declare when_all_ready() as __attribute__((always_inline)). I'll test it more rigorously tonight and commit/merge if it passes all tests.

lewissbaker commented 7 years ago

Ok, so marking when_all_ready as forced-inline seems to fix the when_all_ready issue under Clang (See commit 18d2b4d5aa7850a234a6125f6d03e192bc52dd30)

However, now I'm seeing a whole bunch of the shared_task tests failing under clang optimised. Needs further investigation...

lewissbaker commented 7 years ago

I think the shared_task tests may be failing due to this clang bug: https://bugs.llvm.org/show_bug.cgi?id=35068

I may be able to modify the await_suspend() method for shared_task_promise::final_suspend() object slightly to work around the issue. I'll try this out and report back.

lewissbaker commented 7 years ago

Added some work arounds for Clang atomic ref-counting issue but still seeing some tests fail.

Further investigation required.

lewissbaker commented 7 years ago

This branch is now also running into troubles with bad codegen for when_all under MSVC x64 optimised builds with VS 15.5 preview 3.

I've disabled the broken tests for MSVC for this compiler version for now.