[PATCH] Come up with constructors of symtab_node, cgraph_node and varpool_node.

Richard Biener richard.guenther@gmail.com
Thu Dec 5 13:00:00 GMT 2019


On Thu, Dec 5, 2019 at 1:50 PM Martin Liška <mliska@suse.cz> wrote:
>
> Hi.
>
> As mentioned in the PR, there are classes in cgraph.h that are
> not PODs and are initialized with ggc_alloc_cleared. So that I'm suggesting
> to use proper constructors. I added ggc_new function that can be used
> at different locations as well.

Isn't there ggc_alloc <T> for this?  Also ggc_alloc_no_dtor<T> in case you
want to handle finalization yourself.

> I'm attaching optimized dump file with how ctor expansion looks like.
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> 2019-12-05  Martin Liska  <mliska@suse.cz>
>
>         PR ipa/92737
>         * cgraph.c (symbol_table_test::symbol_table_test):
>         Use new ggc_new.
>         * cgraph.h (symtab_node::symtab_node): New constructor.
>         (cgraph_node::cgraph_node): Likewise.
>         (varpool_node::varpool_node): Likewise.
>         (symbol_table::allocate_cgraph_symbol): Use newly
>         created constructor.
>         * cgraphunit.c (symtab_terminator): Likewise.
>         * ggc.h (ggc_new): New.
>         * toplev.c (general_init): Use new ggc_new.
>         * varpool.c (varpool_node::create_empty): Use newly
>         created constructor.
>
> gcc/c-family/ChangeLog:
>
> 2019-12-05  Martin Liska  <mliska@suse.cz>
>
>         PR ipa/92737
>         * c-opts.c (c_common_init_options): Use new ggc_new.
> ---
>   gcc/c-family/c-opts.c |  4 +---
>   gcc/cgraph.c          |  2 +-
>   gcc/cgraph.h          | 50 ++++++++++++++++++++++++++++++++++++-------
>   gcc/cgraphunit.c      |  2 +-
>   gcc/ggc.h             |  9 ++++++++
>   gcc/toplev.c          |  2 +-
>   gcc/varpool.c         |  5 ++---
>   7 files changed, 57 insertions(+), 17 deletions(-)
>
>



More information about the Gcc-patches mailing list