This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ coroutines 4/6] Middle end expanders and transforms.
- From: Iain Sandoe <iain at sandoe dot co dot uk>
- To: "Bin.Cheng" <amker dot cheng at gmail dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 16 Jan 2020 08:06:43 +0000
- Subject: Re: [C++ coroutines 4/6] Middle end expanders and transforms.
- References: <F5F88589-1A8E-4311-AFC8-79E75C1C14C8@sandoe.co.uk> <285E6AA6-17E6-4E7F-9F37-852707896DA1@sandoe.co.uk> <B9BF0CEA-C9A7-4F63-91AC-24F87538177D@sandoe.co.uk> <EC0A5CB6-61E5-4F68-AB6C-CF8BACC7FFD7@sandoe.co.uk> <DDCE9FBF-F32D-43D0-AB4B-BC3FB72052BF@sandoe.co.uk> <CAFiYyc2UBgeezSzvv8FMO80NrhQYjkoDhheASiys-rW1nMNhwg@mail.gmail.com> <CAHFci2-Dkq2KMNprw8zd+z06S3SKYhA8mrGY5jJpS89wuytLMA@mail.gmail.com>
Bin.Cheng <amker.cheng@gmail.com> wrote:
>>> + gassign *get_res = gimple_build_assign (lhs, done);
>>> + gsi_replace (gsi, get_res, true);
>>> + *handled_ops_p = true;
>>> + }
>>> + break;
>>> + }
>>> + }
>>> + return NULL_TREE;
>>> +}
>>> +
>>> +/* Main entry point for lowering coroutine FE builtins. */
>>> +
>>> +static unsigned int
>>> +execute_lower_coro_builtins (void)
>>> +{
>>> + struct walk_stmt_info wi;
>>> + gimple_seq body;
>>> +
>>> + body = gimple_body (current_function_decl);
>>> + memset (&wi, 0, sizeof (wi));
>>> + walk_gimple_seq_mod (&body, lower_coro_builtin, NULL, &wi);
>>> + gimple_set_body (current_function_decl, body);
>>
>> it would be nice to elide the function walk for functions not
>> containing any CO* stuff (you noted that below for other parts).
>> We can spend a bit in struct function noting functions with
>> coroutine code inside and set the bit from frontends or from
>> the gimplifier for example. Since it's behind the flag_coroutines
>> paywall this can be addressed as followup.
>
> Yes, this bit flag is necessary for following optimization passes, I
> wonder which bit you would suggest?
it’s implemented in the patches (that should be merged soon, just retesing
after the git transition).
Uses a flag bit in the function struct.
see:
https://gcc.gnu.org/ml/gcc-patches/2020-01/msg00435.html
diff --git a/gcc/function.h b/gcc/function.h
index 496d3f728c..1ee8ed3de5 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -418,6 +418,9 @@ struct GTY(()) function {
/* Set when the function was compiled with generation of debug
(begin stmt, inline entry, ...) markers enabled. */
unsigned int debug_nonbind_markers : 1;
+
+ /* Set if this is a coroutine-related function. */
+ unsigned int coroutine_component : 1;
};