* Clear more useless flags
@ 2018-11-07 14:17 Jan Hubicka
2018-11-07 14:47 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Jan Hubicka @ 2018-11-07 14:17 UTC (permalink / raw)
To: gcc-patches, rguenther
Hi,
this patch enables bit more merging by clearing more flags that are
unnecesary and differ in practice across different copies of same ODR
types.
lto-bootstrapped/regtested x86_64-linux, OK?
* tree.c (fld_incomplete_type_of): Clear TREE_ADDRESSABLE flag.
(free_lang_data_in_decl): Set TREE_ADDRESSABLE for public functions
and variables; clear DECL_EXTERNAL, TYPE_DECL_SUPPRESS_DEBUG and
DECL_MODE on TYPE_DECLs.
Index: tree.c
===================================================================
--- tree.c (revision 265875)
+++ tree.c (working copy)
@@ -5197,6 +5197,7 @@ fld_incomplete_type_of (tree t, struct f
TYPE_SIZE_UNIT (copy) = NULL;
TYPE_CANONICAL (copy) = TYPE_CANONICAL (t);
TYPE_TYPELESS_STORAGE (copy) = 0;
+ TREE_ADDRESSABLE (copy) = 0;
if (AGGREGATE_TYPE_P (t))
{
TYPE_FIELDS (copy) = NULL;
@@ -5496,6 +5497,17 @@ free_lang_data_in_decl (tree decl, struc
if (TREE_CODE (decl) == FUNCTION_DECL)
{
struct cgraph_node *node;
+ /* Frontends do not set TREE_ADDRESSABLE on public variables even though
+ the address may be taken in other unit, so this flag has no practical
+ use for middle-end.
+
+ It would make more sense if frontends set TREE_ADDRESSABLE to 0 only
+ for public objects that indeed can not be adressed, but it is not
+ the case. Set the flag to true so we do not get merge failures for
+ i.e. virtual tables between units that take address of it and
+ units that don't. */
+ if (TREE_PUBLIC (decl))
+ TREE_ADDRESSABLE (decl) = true;
TREE_TYPE (decl) = fld_simplified_type (TREE_TYPE (decl), fld);
if (!(node = cgraph_node::get (decl))
|| (!node->definition && !node->clones))
@@ -5551,6 +5563,9 @@ free_lang_data_in_decl (tree decl, struc
}
else if (VAR_P (decl))
{
+ /* See comment above why we set the flag for functions. */
+ if (TREE_PUBLIC (decl))
+ TREE_ADDRESSABLE (decl) = true;
if ((DECL_EXTERNAL (decl)
&& (!TREE_STATIC (decl) || !TREE_READONLY (decl)))
|| (decl_function_context (decl) && !TREE_STATIC (decl)))
@@ -5560,8 +5575,12 @@ free_lang_data_in_decl (tree decl, struc
{
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
DECL_VISIBILITY_SPECIFIED (decl) = 0;
+ /* TREE_PUBLIC is used to tell if type is anonymous. */
+ DECL_EXTERNAL (decl) = 0;
+ TYPE_DECL_SUPPRESS_DEBUG (decl) = 0;
DECL_INITIAL (decl) = NULL_TREE;
DECL_ORIGINAL_TYPE (decl) = NULL_TREE;
+ DECL_MODE (decl) = VOIDmode;
TREE_TYPE (decl) = void_type_node;
SET_DECL_ALIGN (decl, 0);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Clear more useless flags
2018-11-07 14:17 Clear more useless flags Jan Hubicka
@ 2018-11-07 14:47 ` Richard Biener
2018-11-07 15:08 ` Jan Hubicka
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2018-11-07 14:47 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
On Wed, 7 Nov 2018, Jan Hubicka wrote:
> Hi,
> this patch enables bit more merging by clearing more flags that are
> unnecesary and differ in practice across different copies of same ODR
> types.
>
> lto-bootstrapped/regtested x86_64-linux, OK?
> * tree.c (fld_incomplete_type_of): Clear TREE_ADDRESSABLE flag.
> (free_lang_data_in_decl): Set TREE_ADDRESSABLE for public functions
> and variables; clear DECL_EXTERNAL, TYPE_DECL_SUPPRESS_DEBUG and
> DECL_MODE on TYPE_DECLs.
> Index: tree.c
> ===================================================================
> --- tree.c (revision 265875)
> +++ tree.c (working copy)
> @@ -5197,6 +5197,7 @@ fld_incomplete_type_of (tree t, struct f
> TYPE_SIZE_UNIT (copy) = NULL;
> TYPE_CANONICAL (copy) = TYPE_CANONICAL (t);
> TYPE_TYPELESS_STORAGE (copy) = 0;
> + TREE_ADDRESSABLE (copy) = 0;
> if (AGGREGATE_TYPE_P (t))
> {
> TYPE_FIELDS (copy) = NULL;
> @@ -5496,6 +5497,17 @@ free_lang_data_in_decl (tree decl, struc
> if (TREE_CODE (decl) == FUNCTION_DECL)
> {
> struct cgraph_node *node;
> + /* Frontends do not set TREE_ADDRESSABLE on public variables even though
> + the address may be taken in other unit, so this flag has no practical
> + use for middle-end.
> +
> + It would make more sense if frontends set TREE_ADDRESSABLE to 0 only
> + for public objects that indeed can not be adressed, but it is not
> + the case. Set the flag to true so we do not get merge failures for
> + i.e. virtual tables between units that take address of it and
> + units that don't. */
> + if (TREE_PUBLIC (decl))
> + TREE_ADDRESSABLE (decl) = true;
> TREE_TYPE (decl) = fld_simplified_type (TREE_TYPE (decl), fld);
> if (!(node = cgraph_node::get (decl))
> || (!node->definition && !node->clones))
> @@ -5551,6 +5563,9 @@ free_lang_data_in_decl (tree decl, struc
> }
> else if (VAR_P (decl))
> {
> + /* See comment above why we set the flag for functions. */
> + if (TREE_PUBLIC (decl))
> + TREE_ADDRESSABLE (decl) = true;
> if ((DECL_EXTERNAL (decl)
> && (!TREE_STATIC (decl) || !TREE_READONLY (decl)))
> || (decl_function_context (decl) && !TREE_STATIC (decl)))
> @@ -5560,8 +5575,12 @@ free_lang_data_in_decl (tree decl, struc
> {
> DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
> DECL_VISIBILITY_SPECIFIED (decl) = 0;
> + /* TREE_PUBLIC is used to tell if type is anonymous. */
> + DECL_EXTERNAL (decl) = 0;
> + TYPE_DECL_SUPPRESS_DEBUG (decl) = 0;
DECL_EXTERNAL and TYPE_DECL_SUPPRESS_DEBUG map to the same decl_flag_1 ...
so I'd say you should use TYPE_DECL_SUPPRESS_DEBUG only here.
> DECL_INITIAL (decl) = NULL_TREE;
> DECL_ORIGINAL_TYPE (decl) = NULL_TREE;
> + DECL_MODE (decl) = VOIDmode;
> TREE_TYPE (decl) = void_type_node;
> SET_DECL_ALIGN (decl, 0);
> }
OK with that change.
Thanks,
Richard.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Clear more useless flags
2018-11-07 14:47 ` Richard Biener
@ 2018-11-07 15:08 ` Jan Hubicka
2018-11-07 15:14 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Jan Hubicka @ 2018-11-07 15:08 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
> > + /* TREE_PUBLIC is used to tell if type is anonymous. */
> > + DECL_EXTERNAL (decl) = 0;
> > + TYPE_DECL_SUPPRESS_DEBUG (decl) = 0;
>
> DECL_EXTERNAL and TYPE_DECL_SUPPRESS_DEBUG map to the same decl_flag_1 ...
> so I'd say you should use TYPE_DECL_SUPPRESS_DEBUG only here.
I see, print_tree prints both that is how I added both. Probably
something to fix :)
thanks!
Honza
>
> > DECL_INITIAL (decl) = NULL_TREE;
> > DECL_ORIGINAL_TYPE (decl) = NULL_TREE;
> > + DECL_MODE (decl) = VOIDmode;
> > TREE_TYPE (decl) = void_type_node;
> > SET_DECL_ALIGN (decl, 0);
> > }
>
> OK with that change.
>
> Thanks,
> Richard.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Clear more useless flags
2018-11-07 15:08 ` Jan Hubicka
@ 2018-11-07 15:14 ` Richard Biener
0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2018-11-07 15:14 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
On Wed, 7 Nov 2018, Jan Hubicka wrote:
> > > + /* TREE_PUBLIC is used to tell if type is anonymous. */
> > > + DECL_EXTERNAL (decl) = 0;
> > > + TYPE_DECL_SUPPRESS_DEBUG (decl) = 0;
> >
> > DECL_EXTERNAL and TYPE_DECL_SUPPRESS_DEBUG map to the same decl_flag_1 ...
> > so I'd say you should use TYPE_DECL_SUPPRESS_DEBUG only here.
>
> I see, print_tree prints both that is how I added both. Probably
> something to fix :)
Yeah ;)
> thanks!
> Honza
> >
> > > DECL_INITIAL (decl) = NULL_TREE;
> > > DECL_ORIGINAL_TYPE (decl) = NULL_TREE;
> > > + DECL_MODE (decl) = VOIDmode;
> > > TREE_TYPE (decl) = void_type_node;
> > > SET_DECL_ALIGN (decl, 0);
> > > }
> >
> > OK with that change.
> >
> > Thanks,
> > Richard.
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-11-07 15:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07 14:17 Clear more useless flags Jan Hubicka
2018-11-07 14:47 ` Richard Biener
2018-11-07 15:08 ` Jan Hubicka
2018-11-07 15:14 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).