Re: Use ODR for canonical types construction in LTO

2019-07-23 Thread Martin Liška
Hi. Honza can you please fix this: gcc/ipa-devirt.c:1616:12: warning: implicit conversion of NULL constant to 'bool' [-Wnull-conversion] Thanks, Martin

RE: Use ODR for canonical types construction in LTO

2019-07-01 Thread JiangNing OS
atc...@gcc.gnu.org>; Richard Biener ; d...@dcepelik.cz; > Martin Liška > Subject: Re: Use ODR for canonical types construction in LTO > > Hi, > this patch fixes the ICE. Problem is that va_arg type is pre-streamed and thus > at stream-in time we have main variant constructe

Re: Use ODR for canonical types construction in LTO

2019-07-01 Thread Jan Hubicka
Hi, this patch fixes the ICE. Problem is that va_arg type is pre-streamed and thus at stream-in time we have main variant constructed by LTO FE which is !CXX_ODR_P while vairants are ones comming from C++ FE which are ODR. It is safe to drop the flags here since we only care about main variants an

Re: Use ODR for canonical types construction in LTO

2019-06-27 Thread Jason Merrill
On Mon, Jun 24, 2019 at 1:46 PM Jan Hubicka wrote: > > > > I thought I remembered someone's recent-ish work to treat specially > > types containing a char array, but I'm not finding it now. > > > > > For dynamically allocated memory as well as for stack space after stack > > > slot sharing done in

RE: Use ODR for canonical types construction in LTO

2019-06-27 Thread JiangNing OS
e- > From: Jan Hubicka > Sent: Thursday, June 27, 2019 2:29 PM > To: JiangNing OS > Cc: Eric Botcazou ; Christophe Lyon > ; gcc Patches ; > Richard Biener ; d...@dcepelik.cz; Martin Liška > > Subject: Re: Use ODR for canonical types construction in LTO > > > Hi,

Re: Use ODR for canonical types construction in LTO

2019-06-27 Thread Jan Hubicka
> On Thu, 27 Jun 2019, Jan Hubicka wrote: > > > Hi, > > here is update patch I am re-testing. Ok if it suceeds? > > + if (!type_in_anonymous_namespace_p (t)) > + hash = htab_hash_string (IDENTIFIER_POINTER > + (DECL_ASSEMBLER_NAME > +

Re: Use ODR for canonical types construction in LTO

2019-06-27 Thread Richard Biener
On Thu, 27 Jun 2019, Jan Hubicka wrote: > Hi, > here is update patch I am re-testing. Ok if it suceeds? + if (!type_in_anonymous_namespace_p (t)) + hash = htab_hash_string (IDENTIFIER_POINTER + (DECL_ASSEMBLER_NAME +

Re: Use ODR for canonical types construction in LTO

2019-06-27 Thread Jan Hubicka
Hi, here is update patch I am re-testing. Ok if it suceeds? Orace quary stats finished in meantime. Alias oracle query stats: refs_may_alias_p: 39232255 disambiguations, 47436580 queries ref_maybe_used_by_call_p: 59801 disambiguations, 39811399 queries call_may_clobber_ref_p: 5967 disambigu

Re: Use ODR for canonical types construction in LTO

2019-06-27 Thread Jan Hubicka
> > Actually this was intended to be prevail in both cases, but it is > > harmless. The difference here is that anonymous types have > > DECL_ASSEMBLED_NAME , so if we inserted them to the hash > > table based on names they will all conflict. > > > > Anonymous namespace types never have duplicate

Re: Use ODR for canonical types construction in LTO

2019-06-27 Thread Richard Biener
On Thu, 27 Jun 2019, Jan Hubicka wrote: > > > + if (RECORD_OR_UNION_TYPE_P (t) > > > + && odr_type_p (t) && !odr_type_violation_reported_p (t)) > > > +{ > > > + /* Here we rely on fact that all non-ODR types was inserted into > > > + canonical type hash and thus we can safely detec

Re: Use ODR for canonical types construction in LTO

2019-06-27 Thread Jan Hubicka
> > + if (RECORD_OR_UNION_TYPE_P (t) > > + && odr_type_p (t) && !odr_type_violation_reported_p (t)) > > +{ > > + /* Here we rely on fact that all non-ODR types was inserted into > > +canonical type hash and thus we can safely detect conflicts between > > +ODR types and intero

Re: Use ODR for canonical types construction in LTO

2019-06-27 Thread Richard Biener
On Thu, 27 Jun 2019, Jan Hubicka wrote: > Hi, > this is updated patch for ODR based canonical type calculation. It makes use > of TYPE_CXX_ODR_P instead of doing the guesswork and while thinking how to get > rid of the quadratic behaviour of the hash I noticed that all the logic fits > quite natu

Re: Use ODR for canonical types construction in LTO

2019-06-27 Thread Jan Hubicka
Hi, this is updated patch for ODR based canonical type calculation. It makes use of TYPE_CXX_ODR_P instead of doing the guesswork and while thinking how to get rid of the quadratic behaviour of the hash I noticed that all the logic fits quite naturally into gimple_register_canonical_type_1. We on

Re: Use ODR for canonical types construction in LTO

2019-06-26 Thread Jan Hubicka
ror: lto-wrapper failed > collect2: error: ld returned 1 exit status > > Thanks, > -Jiangning > > > -Original Message- > > From: gcc-patches-ow...@gcc.gnu.org > > On Behalf Of Christophe Lyon > > Sent: Tuesday, June 25, 2019 8:30 PM > > To: Jan Hubicka

RE: Use ODR for canonical types construction in LTO

2019-06-26 Thread JiangNing OS
urned 1 exit status Thanks, -Jiangning > -Original Message- > From: gcc-patches-ow...@gcc.gnu.org > On Behalf Of Christophe Lyon > Sent: Tuesday, June 25, 2019 8:30 PM > To: Jan Hubicka > Cc: Eric Botcazou ; gcc Patches patc...@gcc.gnu.org>; Richard Biener ;

Re: Use ODR for canonical types construction in LTO

2019-06-25 Thread Christophe Lyon
Hi, On Tue, 25 Jun 2019 at 10:20, Jan Hubicka wrote: > > > > * gcc-interface/decl.c (gnat_to_gnu_entity): Check that > > > type is array or integer prior checking string flag. > > > > The test for array is superfluous here. > > > > > * gcc-interface/gigi.h (gnat_signed_type_for, > >

Re: Use ODR for canonical types construction in LTO

2019-06-25 Thread Jan Hubicka
> > * gcc-interface/decl.c (gnat_to_gnu_entity): Check that > > type is array or integer prior checking string flag. > > The test for array is superfluous here. > > > * gcc-interface/gigi.h (gnat_signed_type_for, > > maybe_character_value): Likewise. > > Wrong ChangeLog, the firs

Re: Use ODR for canonical types construction in LTO

2019-06-25 Thread Eric Botcazou
> * gcc-interface/decl.c (gnat_to_gnu_entity): Check that > type is array or integer prior checking string flag. The test for array is superfluous here. > * gcc-interface/gigi.h (gnat_signed_type_for, > maybe_character_value): Likewise. Wrong ChangeLog, the first modified

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Jan Hubicka
Hi, > > I thought I remembered someone's recent-ish work to treat specially > types containing a char array, but I'm not finding it now. > > > For dynamically allocated memory as well as for stack space after stack > > slot sharing done in cfgexpand I see this is necessary since we do not > > pre

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Jason Merrill
On Mon, Jun 24, 2019 at 1:23 PM Richard Biener wrote: > On Mon, 24 Jun 2019, Jason Merrill wrote: > > > On Mon, Jun 24, 2019 at 12:40 PM Jason Merrill wrote: > > > On Mon, Jun 24, 2019 at 11:57 AM Jan Hubicka wrote: > > > > > > > > > > > As > > > > > > > > > > > > > > class a var; > > > > > >

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Richard Biener
On Mon, 24 Jun 2019, Jason Merrill wrote: > On Mon, Jun 24, 2019 at 12:40 PM Jason Merrill wrote: > > On Mon, Jun 24, 2019 at 11:57 AM Jan Hubicka wrote: > > > > > > > > > As > > > > > > > > > > > > class a var; > > > > > > class b:a {} *bptr; > > > > > > > > > > > > var.foo; > > > > > > >

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Jason Merrill
On Mon, Jun 24, 2019 at 12:40 PM Jason Merrill wrote: > On Mon, Jun 24, 2019 at 11:57 AM Jan Hubicka wrote: > > > > > > > As > > > > > > > > > > class a var; > > > > > class b:a {} *bptr; > > > > > > > > > > var.foo; > > > > > > > > > > Expanding this as var.as_base_a.foo would make access

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Jason Merrill
On Mon, Jun 24, 2019 at 11:57 AM Jan Hubicka wrote: > > Hi, > thanks for comitting the patch! > > > > As > > > > > > > > class a var; > > > > class b:a {} *bptr; > > > > > > > > var.foo; > > > > > > > > Expanding this as var.as_base_a.foo would make access path oracle to > > > > disambiguate

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Jan Hubicka
Hi, thanks for comitting the patch! > > > As > > > > > > class a var; > > > class b:a {} *bptr; > > > > > > var.foo; > > > > > > Expanding this as var.as_base_a.foo would make access path oracle to > > > disambiguate it from bptr->as_base_b->as_base_a.foo which is wrong with > > > gimple memo

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Jason Merrill
On Mon, Jun 24, 2019 at 7:28 AM Richard Biener wrote: > On Mon, 24 Jun 2019, Jan Hubicka wrote: > > > > > This simple (untested) patch doesn't avoid creating the unnecessary > > > > as-base types, but it should avoid using them in a way that causes > > > > them to be streamed, and should let them

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Richard Biener
On Mon, 24 Jun 2019, Jan Hubicka wrote: > > Hi, > > here is patch that adds TYPE_ODR_P to determine type that comply C++ > > ODR rules (i.e. ODR types themselves or structures/unions derived > > from them). > > I have decided to use STRING_FLAG which have meaning only for integers > > and arrays w

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Jan Hubicka
> On Mon, 24 Jun 2019, Jan Hubicka wrote: > > > > > This simple (untested) patch doesn't avoid creating the unnecessary > > > > as-base types, but it should avoid using them in a way that causes > > > > them to be streamed, and should let them be discarded by GC. > > > > Thoughts? > > > > > > Loo

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Richard Biener
On Mon, 24 Jun 2019, Jan Hubicka wrote: > > > This simple (untested) patch doesn't avoid creating the unnecessary > > > as-base types, but it should avoid using them in a way that causes > > > them to be streamed, and should let them be discarded by GC. > > > Thoughts? > > > > Looks better than H

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Jan Hubicka
> > This simple (untested) patch doesn't avoid creating the unnecessary > > as-base types, but it should avoid using them in a way that causes > > them to be streamed, and should let them be discarded by GC. > > Thoughts? > > Looks better than Honzas patch fixing a single place. I wonder if we ca

Re: Use ODR for canonical types construction in LTO

2019-06-24 Thread Jan Hubicka
> Hi, > here is patch that adds TYPE_ODR_P to determine type that comply C++ > ODR rules (i.e. ODR types themselves or structures/unions derived > from them). > I have decided to use STRING_FLAG which have meaning only for integers > and arrays which forced me to add type checks on places where > w

Re: Use ODR for canonical types construction in LTO

2019-06-20 Thread Nathan Sidwell
On 6/20/19 11:49 AM, Richard Biener wrote: On June 20, 2019 4:06:58 PM GMT+02:00, Nathan Sidwell wrote: On 6/20/19 9:37 AM, Richard Biener wrote: I've spent some thoughts on this and I wonder whether we can re-implement classtype-as-base with fake inheritance (which would also solve the TBAA

Re: Use ODR for canonical types construction in LTO

2019-06-20 Thread Richard Biener
On June 20, 2019 4:06:58 PM GMT+02:00, Nathan Sidwell wrote: >On 6/20/19 9:37 AM, Richard Biener wrote: > >> I've spent some thoughts on this and I wonder whether we can >> re-implement classtype-as-base with fake inheritance (which would >> also solve the TBAA alias set issue in a natural way).

Re: Use ODR for canonical types construction in LTO

2019-06-20 Thread Nathan Sidwell
On 6/20/19 9:37 AM, Richard Biener wrote: I've spent some thoughts on this and I wonder whether we can re-implement classtype-as-base with fake inheritance (which would also solve the TBAA alias set issue in a natural way). That is, we'd lay out structs as-base and make instances of it use a c

Re: Use ODR for canonical types construction in LTO

2019-06-20 Thread Jan Hubicka
> > This simple (untested) patch doesn't avoid creating the unnecessary > > as-base types, but it should avoid using them in a way that causes > > them to be streamed, and should let them be discarded by GC. > > Thoughts? > > Looks better than Honzas patch fixing a single place. Indeed, I think i

Re: Use ODR for canonical types construction in LTO

2019-06-20 Thread Richard Biener
On Thu, 20 Jun 2019, Jason Merrill wrote: > On Wed, Jun 19, 2019 at 2:47 PM Nathan Sidwell wrote: > > > > On 6/19/19 1:53 PM, Jan Hubicka wrote: > > -ctype = CLASSTYPE_AS_BASE (ctype); > > +{ > > + if (!tree_int_cst_equal (TYPE_SIZE (ctype), > > +

Re: Use ODR for canonical types construction in LTO

2019-06-20 Thread Jan Hubicka
> On 6/19/19 1:53 PM, Jan Hubicka wrote: > > > > > -ctype = CLASSTYPE_AS_BASE (ctype); > > > > > +{ > > > > > + if (!tree_int_cst_equal (TYPE_SIZE (ctype), > > > > > +TYPE_SIZE (CLASSTYPE_AS_BASE (ctype > > > > > +ctype = CLASSTYPE_AS_BASE (ctype

Re: Use ODR for canonical types construction in LTO

2019-06-20 Thread Nathan Sidwell
On 6/20/19 12:34 AM, Jason Merrill wrote: On Wed, Jun 19, 2019 at 2:47 PM Nathan Sidwell wrote: This simple (untested) patch doesn't avoid creating the unnecessary as-base types, but it should avoid using them in a way that causes them to be streamed, and should let them be discarded by GC. T

Re: Use ODR for canonical types construction in LTO

2019-06-19 Thread Jason Merrill
On Wed, Jun 19, 2019 at 2:47 PM Nathan Sidwell wrote: > > On 6/19/19 1:53 PM, Jan Hubicka wrote: > -ctype = CLASSTYPE_AS_BASE (ctype); > +{ > + if (!tree_int_cst_equal (TYPE_SIZE (ctype), > + TYPE_SIZE (CLASSTYPE_AS_BASE (ctype > +

Re: Use ODR for canonical types construction in LTO

2019-06-19 Thread Nathan Sidwell
On 6/19/19 1:53 PM, Jan Hubicka wrote: -ctype = CLASSTYPE_AS_BASE (ctype); +{ + if (!tree_int_cst_equal (TYPE_SIZE (ctype), + TYPE_SIZE (CLASSTYPE_AS_BASE (ctype +ctype = CLASSTYPE_AS_BASE (ctype); +} tree clobber = build_clobber (cty

Re: Use ODR for canonical types construction in LTO

2019-06-19 Thread Jan Hubicka
> > > -ctype = CLASSTYPE_AS_BASE (ctype); > > > +{ > > > + if (!tree_int_cst_equal (TYPE_SIZE (ctype), > > > +TYPE_SIZE (CLASSTYPE_AS_BASE (ctype > > > +ctype = CLASSTYPE_AS_BASE (ctype); > > > +} > > > tree clobber = build_clobber (ctype); >

Re: Use ODR for canonical types construction in LTO

2019-06-19 Thread Nathan Sidwell
On 6/19/19 9:28 AM, Jan Hubicka wrote: Jason, I also wonder if something like this would make sense: * decl.c (build_clobber_this): Use original basetype if they match. Index: decl.c === --- decl.c (revision 27

Re: Use ODR for canonical types construction in LTO

2019-06-19 Thread Jan Hubicka
> Jason, > I also wonder if something like this would make sense: > > * decl.c (build_clobber_this): Use original basetype if they > match. > > Index: decl.c > === > --- decl.c(revision 272381) > +++ decl.c(workin

Re: Use ODR for canonical types construction in LTO

2019-06-19 Thread Jan Hubicka
Jason, I also wonder if something like this would make sense: * decl.c (build_clobber_this): Use original basetype if they match. Index: decl.c === --- decl.c (revision 272381) +++ decl.c (working copy) @@ -

Re: Use ODR for canonical types construction in LTO

2019-06-19 Thread Jan Hubicka
Hi, Jason, this is about C++ frontend producing two copies of same type with different TYPE_CANONICAL but same get_alias_set. Since the types are structurally different, this does not go well with LTO which no longer sees they are same. They are created in if (CLASSTYPE_NON_LAYOUT_POD_P (t) ||

Re: Use ODR for canonical types construction in LTO

2019-06-18 Thread Jan Hubicka
> > ICK. Can you please solve the C++ issue differently? The patch > also seems to do many other things ... If you refer to the fact that C++ seem to create non-ODR types that are structurally equivalent to ODR types, i tracked it down. Testcase is testsuite/g++.dg/lto/20080904_0.C compiled wi

Re: Use ODR for canonical types construction in LTO

2019-06-16 Thread Jan Hubicka
Hi, here is patch that adds TYPE_ODR_P to determine type that comply C++ ODR rules (i.e. ODR types themselves or structures/unions derived from them). I have decided to use STRING_FLAG which have meaning only for integers and arrays which forced me to add type checks on places where we check STRING

Re: Use ODR for canonical types construction in LTO

2019-06-14 Thread Jan Hubicka
> > Step 2 remain same. > > Additional step 3 registers all odr derived types into canonical type hash. > > This requires canonical type hash to play well with ODR types (i.e. not > > consider them equivalent based on structural equivalety). > > > > The decision on whether given type has ODR based

Re: Use ODR for canonical types construction in LTO

2019-06-14 Thread Richard Biener
On Mon, 3 Jun 2019, Jan Hubicka wrote: > Hi, > this patch makes LTO to use ODR names when building canonical types. > Theoretically this is easy task because every ODR type is unique and > it is enough to fill in the hash with the ODR names and compare them. > > In reality we want to be more care

Re: Use ODR for canonical types construction in LTO

2019-06-14 Thread Jan Hubicka
> * alias.c (record_component_aliases): Honor odr_based_tbaa_p. > * ipa-devirt.c (odr_type_d): Add tbaa_enabled field. > (get_odr_type): Return NULL when odr_type_hash is NULL. > (enable_odr_based_tbaa): New function. > (odr_based_tbaa_p): New function. > (set_ty

Use ODR for canonical types construction in LTO

2019-06-03 Thread Jan Hubicka
Hi, this patch makes LTO to use ODR names when building canonical types. Theoretically this is easy task because every ODR type is unique and it is enough to fill in the hash with the ODR names and compare them. In reality we want to be more careful and detect situation when non-ODR type is struct