* Do not stream TYPE_STUB_DECL
@ 2018-08-23 12:27 Jan Hubicka
2018-09-05 8:34 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jan Hubicka @ 2018-08-23 12:27 UTC (permalink / raw)
To: gcc-patches
Hi,
this patch removes streaming of TYPE_STUB_DECL. The sanity checking part depends
on the coverage change but I may just drop it (though I think it is useful as
a sanity check that things are consistend within the middle-end).
lto-bootstrapped/regtested x86_64-linux, OK?
Honza
* ipa-utils.h (polymorphic_type_binfo_p,
type_in_anonymous_namespace_p): Expect free lang data to remove
TYPE_STUB_DECL after producing mangled names for types with linkage.
* lto-stramer-out.c (DFS::DFS_write_tree_body, hash_tree):
Do not walk TYPE_STUB_DECL; sanity check it is NULL.
* tree-streamer-in.c (lto_input_ts_type_common_tree_pointers):
Do not stream TYPE_STUB_DECL.
* tree-streamer-out.c (write_ts_type_common_tree_pointers): Likewise.
* tree.c (free_lang_data_in_type): Always clear TYPE_STUB_DECL.
Index: ipa-utils.h
===================================================================
--- ipa-utils.h (revision 263696)
+++ ipa-utils.h (working copy)
@@ -179,22 +179,24 @@ polymorphic_type_binfo_p (const_tree bin
inline bool
type_with_linkage_p (const_tree t)
{
- if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL
- || !TYPE_STUB_DECL (t))
+ if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL)
+ return false;
+
+ /* To support -fno-lto-odr-type-merigng recognize types with vtables
+ to have linkage. */
+ if (RECORD_OR_UNION_TYPE_P (t)
+ && TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
+ return true;
+
+ /* After free_lang_data was run and -flto-odr-type-merging we can recongize
+ types with linkage by presence of mangled name. */
+ if (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
+ return true;
+
+ /* If free lang data was not run check if indeed the type looks like C++
+ type with linkage. */
+ if (in_lto_p || !TYPE_STUB_DECL (t))
return false;
- /* In LTO do not get confused by non-C++ produced types or types built
- with -fno-lto-odr-type-merigng. */
- if (in_lto_p)
- {
- /* To support -fno-lto-odr-type-merigng recognize types with vtables
- to have linkage. */
- if (RECORD_OR_UNION_TYPE_P (t)
- && TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
- return true;
- /* With -flto-odr-type-merging C++ FE specify mangled names
- for all types with the linkage. */
- return DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t));
- }
if (!RECORD_OR_UNION_TYPE_P (t) && TREE_CODE (t) != ENUMERAL_TYPE)
return false;
@@ -214,18 +216,16 @@ type_in_anonymous_namespace_p (const_tre
{
gcc_checking_assert (type_with_linkage_p (t));
- if (!TREE_PUBLIC (TYPE_STUB_DECL (t)))
- {
- /* C++ FE uses magic <anon> as assembler names of anonymous types.
- verify that this match with type_in_anonymous_namespace_p. */
- gcc_checking_assert (!in_lto_p
- || !DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))
- || !strcmp ("<anon>",
- IDENTIFIER_POINTER
- (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
- return true;
- }
- return false;
+ /* free_lang_data clears TYPE_STUB_DECL but sets assembler name to
+ "<anon>" */
+ if (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
+ return !strcmp ("<anon>",
+ IDENTIFIER_POINTER
+ (DECL_ASSEMBLER_NAME (TYPE_NAME (t))));
+ else if (!TYPE_STUB_DECL (t))
+ return false;
+ else
+ return !TREE_PUBLIC (TYPE_STUB_DECL (t));
}
/* Return true of T is type with One Definition Rule info attached.
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c (revision 263696)
+++ lto-streamer-out.c (working copy)
@@ -857,7 +857,7 @@ DFS::DFS_write_tree_body (struct output_
DFS_follow_tree_edge (TYPE_CONTEXT (expr));
/* TYPE_CANONICAL is re-computed during type merging, so no need
to follow it here. */
- DFS_follow_tree_edge (TYPE_STUB_DECL (expr));
+ gcc_checking_assert (TYPE_STUB_DECL (expr) == NULL);
}
if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
@@ -1270,7 +1270,6 @@ hash_tree (struct streamer_tree_cache_d
;
else
visit (TYPE_CONTEXT (t));
- visit (TYPE_STUB_DECL (t));
}
if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
Index: tree-streamer-in.c
===================================================================
--- tree-streamer-in.c (revision 263696)
+++ tree-streamer-in.c (working copy)
@@ -820,7 +820,6 @@ lto_input_ts_type_common_tree_pointers (
TYPE_CONTEXT (expr) = stream_read_tree (ib, data_in);
/* TYPE_CANONICAL gets re-computed during type merging. */
TYPE_CANONICAL (expr) = NULL_TREE;
- TYPE_STUB_DECL (expr) = stream_read_tree (ib, data_in);
}
/* Read all pointer fields in the TS_TYPE_NON_COMMON structure of EXPR
Index: tree-streamer-out.c
===================================================================
--- tree-streamer-out.c (revision 263696)
+++ tree-streamer-out.c (working copy)
@@ -687,7 +687,7 @@ write_ts_type_common_tree_pointers (stru
stream_write_tree (ob, TYPE_CONTEXT (expr), ref_p);
/* TYPE_CANONICAL is re-computed during type merging, so no need
to stream it here. */
- stream_write_tree (ob, TYPE_STUB_DECL (expr), ref_p);
+ gcc_checking_assert (TYPE_STUB_DECL (expr) == NULL);
}
/* Write all pointer fields in the TS_TYPE_NON_COMMON structure of EXPR
Index: tree.c
===================================================================
--- tree.c (revision 263699)
+++ tree.c (working copy)
@@ -5177,8 +5177,8 @@ free_lang_data_in_type (tree type)
if (! type_with_linkage_p (type))
{
TYPE_NAME (type) = TYPE_IDENTIFIER (type);
- TYPE_STUB_DECL (type) = NULL;
}
+ TYPE_STUB_DECL (type) = NULL;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Do not stream TYPE_STUB_DECL
2018-08-23 12:27 Do not stream TYPE_STUB_DECL Jan Hubicka
@ 2018-09-05 8:34 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2018-09-05 8:34 UTC (permalink / raw)
To: Jan Hubicka; +Cc: GCC Patches
On Thu, Aug 23, 2018 at 2:28 PM Jan Hubicka <hubicka@ucw.cz> wrote:
>
> Hi,
> this patch removes streaming of TYPE_STUB_DECL. The sanity checking part depends
> on the coverage change but I may just drop it (though I think it is useful as
> a sanity check that things are consistend within the middle-end).
>
> lto-bootstrapped/regtested x86_64-linux, OK?
OK.
> Honza
>
> * ipa-utils.h (polymorphic_type_binfo_p,
> type_in_anonymous_namespace_p): Expect free lang data to remove
> TYPE_STUB_DECL after producing mangled names for types with linkage.
> * lto-stramer-out.c (DFS::DFS_write_tree_body, hash_tree):
> Do not walk TYPE_STUB_DECL; sanity check it is NULL.
> * tree-streamer-in.c (lto_input_ts_type_common_tree_pointers):
> Do not stream TYPE_STUB_DECL.
> * tree-streamer-out.c (write_ts_type_common_tree_pointers): Likewise.
> * tree.c (free_lang_data_in_type): Always clear TYPE_STUB_DECL.
> Index: ipa-utils.h
> ===================================================================
> --- ipa-utils.h (revision 263696)
> +++ ipa-utils.h (working copy)
> @@ -179,22 +179,24 @@ polymorphic_type_binfo_p (const_tree bin
> inline bool
> type_with_linkage_p (const_tree t)
> {
> - if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL
> - || !TYPE_STUB_DECL (t))
> + if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL)
> + return false;
> +
> + /* To support -fno-lto-odr-type-merigng recognize types with vtables
> + to have linkage. */
> + if (RECORD_OR_UNION_TYPE_P (t)
> + && TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
> + return true;
> +
> + /* After free_lang_data was run and -flto-odr-type-merging we can recongize
> + types with linkage by presence of mangled name. */
> + if (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
> + return true;
> +
> + /* If free lang data was not run check if indeed the type looks like C++
> + type with linkage. */
> + if (in_lto_p || !TYPE_STUB_DECL (t))
> return false;
> - /* In LTO do not get confused by non-C++ produced types or types built
> - with -fno-lto-odr-type-merigng. */
> - if (in_lto_p)
> - {
> - /* To support -fno-lto-odr-type-merigng recognize types with vtables
> - to have linkage. */
> - if (RECORD_OR_UNION_TYPE_P (t)
> - && TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
> - return true;
> - /* With -flto-odr-type-merging C++ FE specify mangled names
> - for all types with the linkage. */
> - return DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t));
> - }
>
> if (!RECORD_OR_UNION_TYPE_P (t) && TREE_CODE (t) != ENUMERAL_TYPE)
> return false;
> @@ -214,18 +216,16 @@ type_in_anonymous_namespace_p (const_tre
> {
> gcc_checking_assert (type_with_linkage_p (t));
>
> - if (!TREE_PUBLIC (TYPE_STUB_DECL (t)))
> - {
> - /* C++ FE uses magic <anon> as assembler names of anonymous types.
> - verify that this match with type_in_anonymous_namespace_p. */
> - gcc_checking_assert (!in_lto_p
> - || !DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))
> - || !strcmp ("<anon>",
> - IDENTIFIER_POINTER
> - (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
> - return true;
> - }
> - return false;
> + /* free_lang_data clears TYPE_STUB_DECL but sets assembler name to
> + "<anon>" */
> + if (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
> + return !strcmp ("<anon>",
> + IDENTIFIER_POINTER
> + (DECL_ASSEMBLER_NAME (TYPE_NAME (t))));
> + else if (!TYPE_STUB_DECL (t))
> + return false;
> + else
> + return !TREE_PUBLIC (TYPE_STUB_DECL (t));
> }
>
> /* Return true of T is type with One Definition Rule info attached.
> Index: lto-streamer-out.c
> ===================================================================
> --- lto-streamer-out.c (revision 263696)
> +++ lto-streamer-out.c (working copy)
> @@ -857,7 +857,7 @@ DFS::DFS_write_tree_body (struct output_
> DFS_follow_tree_edge (TYPE_CONTEXT (expr));
> /* TYPE_CANONICAL is re-computed during type merging, so no need
> to follow it here. */
> - DFS_follow_tree_edge (TYPE_STUB_DECL (expr));
> + gcc_checking_assert (TYPE_STUB_DECL (expr) == NULL);
> }
>
> if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
> @@ -1270,7 +1270,6 @@ hash_tree (struct streamer_tree_cache_d
> ;
> else
> visit (TYPE_CONTEXT (t));
> - visit (TYPE_STUB_DECL (t));
> }
>
> if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
> Index: tree-streamer-in.c
> ===================================================================
> --- tree-streamer-in.c (revision 263696)
> +++ tree-streamer-in.c (working copy)
> @@ -820,7 +820,6 @@ lto_input_ts_type_common_tree_pointers (
> TYPE_CONTEXT (expr) = stream_read_tree (ib, data_in);
> /* TYPE_CANONICAL gets re-computed during type merging. */
> TYPE_CANONICAL (expr) = NULL_TREE;
> - TYPE_STUB_DECL (expr) = stream_read_tree (ib, data_in);
> }
>
> /* Read all pointer fields in the TS_TYPE_NON_COMMON structure of EXPR
> Index: tree-streamer-out.c
> ===================================================================
> --- tree-streamer-out.c (revision 263696)
> +++ tree-streamer-out.c (working copy)
> @@ -687,7 +687,7 @@ write_ts_type_common_tree_pointers (stru
> stream_write_tree (ob, TYPE_CONTEXT (expr), ref_p);
> /* TYPE_CANONICAL is re-computed during type merging, so no need
> to stream it here. */
> - stream_write_tree (ob, TYPE_STUB_DECL (expr), ref_p);
> + gcc_checking_assert (TYPE_STUB_DECL (expr) == NULL);
> }
>
> /* Write all pointer fields in the TS_TYPE_NON_COMMON structure of EXPR
> Index: tree.c
> ===================================================================
> --- tree.c (revision 263699)
> +++ tree.c (working copy)
> @@ -5177,8 +5177,8 @@ free_lang_data_in_type (tree type)
> if (! type_with_linkage_p (type))
> {
> TYPE_NAME (type) = TYPE_IDENTIFIER (type);
> - TYPE_STUB_DECL (type) = NULL;
> }
> + TYPE_STUB_DECL (type) = NULL;
> }
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-05 8:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-23 12:27 Do not stream TYPE_STUB_DECL Jan Hubicka
2018-09-05 8:34 ` 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).