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

2019-12-09 Thread Martin Liška
On 12/5/19 5:25 PM, Martin Sebor wrote: On 12/5/19 8:13 AM, Martin Liška wrote: On 12/5/19 2:03 PM, Jan Hubicka 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 ad

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

2019-12-09 Thread Martin Liška
On 12/7/19 12:49 AM, Bernhard Reutner-Fischer wrote: On 5 December 2019 16:24:53 CET, "Martin Liška" wrote: -/* Allocate new callgraph node. */ - -inline cgraph_node * -symbol_table::allocate_cgraph_symbol (void) -{ - cgraph_node *node; - - node = ggc_cleared_alloc (); - node->type = SYMTAB

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

2019-12-06 Thread Bernhard Reutner-Fischer
On 5 December 2019 16:24:53 CET, "Martin Liška" wrote: -/* Allocate new callgraph node. */ - -inline cgraph_node * -symbol_table::allocate_cgraph_symbol (void) -{ - cgraph_node *node; - - node = ggc_cleared_alloc (); - node->type = SYMTAB_FUNCTION; - node->m_summary_id = -1; - node->m_uid =

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

2019-12-06 Thread Michael Matz
Hi, On Thu, 5 Dec 2019, Richard Biener wrote: > >> Indeed - please adjust that as well. > > > >Explicit ctors are a c++11+ feature. > > Surely not. Whoops, I was conflating ctors and conversion functions, the latter can be explicit only in c++11+. Ciao, Michael.

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

2019-12-05 Thread Richard Biener
On December 5, 2019 5:31:59 PM GMT+01:00, Michael Matz wrote: >Hi, > >On Thu, 5 Dec 2019, Richard Biener wrote: > >> On December 5, 2019 3:35:17 PM GMT+01:00, Tom Tromey >wrote: >> >> "Martin" == Martin Liška writes: >> > >> >Martin> + /* Default constructor. */ >> >Martin> + symtab_node

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

2019-12-05 Thread Michael Matz
Hi, On Thu, 5 Dec 2019, Richard Biener wrote: > On December 5, 2019 3:35:17 PM GMT+01:00, Tom Tromey wrote: > >> "Martin" == Martin Liška writes: > > > >Martin> + /* Default constructor. */ > >Martin> + symtab_node (symtab_type t) > > > >FWIW, in gdb, we normally make single-argument con

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

2019-12-05 Thread Martin Sebor
On 12/5/19 8:13 AM, Martin Liška wrote: On 12/5/19 2:03 PM, Jan Hubicka 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 a

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

2019-12-05 Thread Martin Liška
On 12/5/19 4:17 PM, Martin Liška wrote: On 12/5/19 4:12 PM, Richard Biener wrote: Isn't there std::default_constructible? Also after your patch it's far from obvious which api to use. Will it work with: struct Foo {   Foo(int) {} }; ... if (std::default_constructible ())    ptr = new ptr

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

2019-12-05 Thread Martin Liška
On 12/5/19 4:12 PM, Richard Biener wrote: Isn't there std::default_constructible? Also after your patch it's far from obvious which api to use. Will it work with: struct Foo { Foo(int) {} }; ... if (std::default_constructible ()) ptr = new ptr T (); ? Wouldn't we end up with a compila

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

2019-12-05 Thread Richard Biener
On December 5, 2019 3:35:17 PM GMT+01:00, Tom Tromey wrote: >> "Martin" == Martin Liška writes: > >Martin> + /* Default constructor. */ >Martin> + symtab_node (symtab_type t) > >FWIW, in gdb, we normally make single-argument constructors "explicit". >This helps avoid surprises with implici

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

2019-12-05 Thread Martin Liška
On 12/5/19 2:03 PM, Jan Hubicka 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. I'm attachi

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

2019-12-05 Thread Richard Biener
On December 5, 2019 3:09:40 PM GMT+01:00, "Martin Liška" wrote: >On 12/5/19 2:53 PM, Richard Biener wrote: >> On December 5, 2019 2:03:58 PM GMT+01:00, "Martin Liška" > wrote: >>> On 12/5/19 1:59 PM, Richard Biener wrote: Isn't there ggc_alloc for this? Also ggc_alloc_no_dtor in >>> case yo

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

2019-12-05 Thread Tom Tromey
> "Martin" == Martin Liška writes: Martin> + /* Default constructor. */ Martin> + symtab_node (symtab_type t) FWIW, in gdb, we normally make single-argument constructors "explicit". This helps avoid surprises with implicit conversions. Tom

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

2019-12-05 Thread Martin Liška
On 12/5/19 2:53 PM, Richard Biener wrote: On December 5, 2019 2:03:58 PM GMT+01:00, "Martin Liška" wrote: On 12/5/19 1:59 PM, Richard Biener wrote: Isn't there ggc_alloc for this? Also ggc_alloc_no_dtor in case you want to handle finalization yourself. No, if I see correctly it only call

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

2019-12-05 Thread Jan Hubicka
> On December 5, 2019 2:03:58 PM GMT+01:00, "Martin Liška" > wrote: > >On 12/5/19 1:59 PM, Richard Biener wrote: > >> Isn't there ggc_alloc for this? Also ggc_alloc_no_dtor in > >case you > >> want to handle finalization yourself. > > > >No, if I see correctly it only calls Dtor: > > But its o

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

2019-12-05 Thread Richard Biener
On December 5, 2019 2:03:58 PM GMT+01:00, "Martin Liška" wrote: >On 12/5/19 1:59 PM, Richard Biener wrote: >> Isn't there ggc_alloc for this? Also ggc_alloc_no_dtor in >case you >> want to handle finalization yourself. > >No, if I see correctly it only calls Dtor: But its odd to handle finaliza

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

2019-12-05 Thread Martin Liška
On 12/5/19 1:59 PM, Richard Biener wrote: Isn't there ggc_alloc for this? Also ggc_alloc_no_dtor in case you want to handle finalization yourself. No, if I see correctly it only calls Dtor: template inline T * ggc_alloc (ALONE_CXX_MEM_STAT_INFO) { if (need_finalization_p ()) return sta

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

2019-12-05 Thread Jan Hubicka
> 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. > > I'm attaching optimized dump file wi

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

2019-12-05 Thread Richard Biener
On Thu, Dec 5, 2019 at 1:50 PM Martin Liška 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 locatio