From 7e601a1d3ef4bf1467bc85d01f641bdbbf3e7fd8 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 15 Oct 2019 18:30:15 +0000 Subject: [PATCH] lto-streamer-out.c (lto_variably_modified_type_p): New. 2019-10-15 Richard Biener * lto-streamer-out.c (lto_variably_modified_type_p): New. (tree_is_indexable): Use it. * tree-streamer-out.c (pack_ts_type_common_value_fields): Stream variably_modified_type_p as TYPE_LANG_FLAG_0. * tree-streamer-in.c (unpack_ts_type_common_value_fields): Likewise. From-SVN: r277005 --- gcc/ChangeLog | 8 ++++++++ gcc/lto-streamer-out.c | 17 ++++++++++++++--- gcc/tree-streamer-in.c | 1 + gcc/tree-streamer-out.c | 6 ++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ba6121f8ca6..023b8f2524c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-10-15 Richard Biener + + * lto-streamer-out.c (lto_variably_modified_type_p): New. + (tree_is_indexable): Use it. + * tree-streamer-out.c (pack_ts_type_common_value_fields): + Stream variably_modified_type_p as TYPE_LANG_FLAG_0. + * tree-streamer-in.c (unpack_ts_type_common_value_fields): Likewise. + 2019-10-15 Jozef Lawrynowicz * config/msp430/msp430.md (zero_extendqipsi2): New. diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 285c010abdf..87c9e92f3af 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -120,6 +120,17 @@ output_type_ref (struct output_block *ob, tree node) lto_output_type_ref_index (ob->decl_state, ob->main_stream, node); } +/* Wrapper around variably_modified_type_p avoiding type modification + during WPA streaming. */ + +static bool +lto_variably_modified_type_p (tree type) +{ + return (in_lto_p + ? TYPE_LANG_FLAG_0 (TYPE_MAIN_VARIANT (type)) + : variably_modified_type_p (type, NULL_TREE)); +} + /* Return true if tree node T is written to various tables. For these nodes, we sometimes want to write their phyiscal representation @@ -134,7 +145,7 @@ tree_is_indexable (tree t) definition. */ if ((TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL) && DECL_CONTEXT (t)) - return variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t)), NULL_TREE); + return lto_variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t))); /* IMPORTED_DECL is put into BLOCK and thus it never can be shared. We should no longer need to stream it. */ else if (TREE_CODE (t) == IMPORTED_DECL) @@ -154,10 +165,10 @@ tree_is_indexable (tree t) them we have to localize their members as well. ??? In theory that includes non-FIELD_DECLs as well. */ else if (TYPE_P (t) - && variably_modified_type_p (t, NULL_TREE)) + && lto_variably_modified_type_p (t)) return false; else if (TREE_CODE (t) == FIELD_DECL - && variably_modified_type_p (DECL_CONTEXT (t), NULL_TREE)) + && lto_variably_modified_type_p (DECL_CONTEXT (t))) return false; else return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME); diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c index 5152d10956b..d971a74f2b0 100644 --- a/gcc/tree-streamer-in.c +++ b/gcc/tree-streamer-in.c @@ -378,6 +378,7 @@ unpack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr) TYPE_RESTRICT (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1); TYPE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1); + TYPE_LANG_FLAG_0 (expr) = (unsigned) bp_unpack_value (bp, 1); if (RECORD_OR_UNION_TYPE_P (expr)) { TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1); diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c index aadc56ca0db..f2e4ca220f6 100644 --- a/gcc/tree-streamer-out.c +++ b/gcc/tree-streamer-out.c @@ -326,6 +326,12 @@ pack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr) bp_pack_value (bp, TYPE_RESTRICT (expr), 1); bp_pack_value (bp, TYPE_USER_ALIGN (expr), 1); bp_pack_value (bp, TYPE_READONLY (expr), 1); + unsigned vla_p; + if (in_lto_p) + vla_p = TYPE_LANG_FLAG_0 (TYPE_MAIN_VARIANT (expr)); + else + vla_p = variably_modified_type_p (expr, NULL_TREE); + bp_pack_value (bp, vla_p, 1); /* We used to stream TYPE_ALIAS_SET == 0 information to let frontends mark types that are opaque for TBAA. This however did not work as intended, because TYPE_ALIAS_SET == 0 was regularly lost in type merging. */ -- 2.30.2