https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110827
--- Comment #12 from Michael Duggan <mwd at md5i dot com> ---
I finally got around to this experiment today, after more than a year. I
changed this line in `coro_build_actor_or_destory_function` from:
DECL_ARTIFICIAL (fn) = true;
to
DECL_ARTIFICIAL (fn) = !actor_p;
After this change, I do get output for the lines of the actor function. Here's
the output:
-: 0:Source:bug.cc
-: 0:Graph:bug-bug-preproc.gcno
-: 0:Data:bug-bug-preproc.gcda
-: 0:Runs:1
-: 1:#include <coroutine>
-: 2:#include <exception>
-: 3:
-: 4:void empty() __attribute__((noinline));
-: 5:
6: 6:void empty()
-: 7:{
6: 8: asm("");
6: 9:}
-: 10:
1: 11:void foo()
-: 12:{
1: 13: empty();
1: 14: empty();
1: 15: empty();
1: 16:}
-: 17:
-: 18:struct task {
-: 19: struct promise {
-: 20: using handle_t = std::coroutine_handle<promise>;
1: 21: task get_return_object() {
1: 22: return task{handle_t::from_promise(*this)};
-: 23: }
1: 24: std::suspend_never initial_suspend() noexcept { return {};
}
1: 25: std::suspend_always final_suspend() noexcept { return {}; }
-: 26: void unhandled_exception() { std::terminate(); }
1: 27: void return_void() noexcept {}
-: 28: friend task;
-: 29: };
-: 30: using promise_type = promise;
1: 31: task(promise_type::handle_t handle) : handle_{handle} {}
1: 32: ~task() {
1: 33: if (handle_) {
1: 34: handle_.destroy();
-: 35: }
1: 36: }
-: 37: private:
-: 38: promise_type::handle_t handle_;
-: 39:};
-: 40:
4*: 41:task bar() {
1: 42: empty();
1: 43: empty();
1: 44: empty();
1: 45: co_return;
4*: 46:}
------------------
_Z3barP13_Z3barv.Frame.actor:
3*: 41:task bar() {
1: 42: empty();
1: 43: empty();
1: 44: empty();
1: 45: co_return;
4*: 46:}
------------------
_Z3barv:
1: 41:task bar() {
-: 42: empty();
-: 43: empty();
-: 44: empty();
-: 45: co_return;
-: 46:}
------------------
-: 47:
-: 48:
1: 49:int main()
-: 50:{
1: 51: foo();
1: 52: bar();
1: 53:}
Not ideal, since the code appears twice, but at least it is counts the lines
properly in the actor function. I don't know if this change might cause
problems in other placed, though.