My excision of TYPE_METHODS frees up the TYPE_MAX_VALUES_RAW slot in
RECORD_TYPEs. This patch moves TYPE_BINFO to there.
That move frees up type_non_common::binfo, which I rename to
type_non_common::lang_1 and adjust TYPE_LANG_SLOT_1 to allow any type
slot to use it.
TYPE_LANG_SLOT_1 is used in a number of FEs already, and removing it
looked hard.
I have a plan for the C++ FE's use of that slot in RECORD_TYPE -- so
hands off!
Applied to trunk.
nathan
--
Nathan Sidwell
2017-08-16 Nathan Sidwell <nat...@acm.org>
* tree-core.h (tree_type_non_common): Rename binfo to lang_1.
* tree.h (TYPE_BINFO): Use type_non_common.maxval.
(TYPE_LANG_SLOT_1): Use type_non_common.lang_1, for any type.
* tree.c (free_lang_data_in_type): Use else-if chain. Always
clear TYPE_LANG_1. Remove obsolete member-function stripping.
(find_decls_types_r): Comment about TYPE_MAX_VALUES_RAW.
(verify_type): Adjust for TYPE_BINFO move.
* lto-streamer-out.c (DFS::DFS_write_tree_body): No need to
process TYPE_BINFO directly.
(hash_tree): Likewise.
* tree-streamer-in.c (lto_input_ts_type_non_common_tree_pointers):
Likewise.
* tree-streamer-out.c (write_ts_type_non_common_tree_pointers):
Likewise.
lto/
* lto.c (mentions_vars_p_type): Use TYPE_LANG_SLOT_1.
(compare_tree_sccs_1): No need to compare TYPE_BINFO directly.
(lto_fixup_prevailing_decls): Use TYPE_LANG_SLOT_1.
Index: lto/lto.c
===================================================================
--- lto/lto.c (revision 251119)
+++ lto/lto.c (working copy)
@@ -651,7 +651,7 @@ mentions_vars_p_type (tree t)
CHECK_VAR (TYPE_MAX_VALUE_RAW (t));
/* Accessor is for derived node types only. */
- CHECK_NO_VAR (t->type_non_common.binfo);
+ CHECK_NO_VAR (TYPE_LANG_SLOT_1 (t));
CHECK_VAR (TYPE_CONTEXT (t));
CHECK_NO_VAR (TYPE_CANONICAL (t));
@@ -1410,7 +1410,6 @@ compare_tree_sccs_1 (tree t1, tree t2, t
f1 || f2;
f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
compare_tree_edges (f1, f2);
- compare_tree_edges (TYPE_BINFO (t1), TYPE_BINFO (t2));
}
else if (code == FUNCTION_TYPE
|| code == METHOD_TYPE)
@@ -2584,7 +2583,7 @@ lto_fixup_prevailing_decls (tree t)
LTO_SET_PREVAIL (TYPE_MIN_VALUE_RAW (t));
LTO_SET_PREVAIL (TYPE_MAX_VALUE_RAW (t));
- LTO_NO_PREVAIL (t->type_non_common.binfo);
+ LTO_NO_PREVAIL (TYPE_LANG_SLOT_1 (t));
LTO_SET_PREVAIL (TYPE_CONTEXT (t));
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c (revision 251119)
+++ lto-streamer-out.c (working copy)
@@ -837,8 +837,6 @@ DFS::DFS_write_tree_body (struct output_
if (!POINTER_TYPE_P (expr))
DFS_follow_tree_edge (TYPE_MIN_VALUE_RAW (expr));
DFS_follow_tree_edge (TYPE_MAX_VALUE_RAW (expr));
- if (RECORD_OR_UNION_TYPE_P (expr))
- DFS_follow_tree_edge (TYPE_BINFO (expr));
}
if (CODE_CONTAINS_STRUCT (code, TS_LIST))
@@ -1273,8 +1271,6 @@ hash_tree (struct streamer_tree_cache_d
if (!POINTER_TYPE_P (t))
visit (TYPE_MIN_VALUE_RAW (t));
visit (TYPE_MAX_VALUE_RAW (t));
- if (RECORD_OR_UNION_TYPE_P (t))
- visit (TYPE_BINFO (t));
}
if (CODE_CONTAINS_STRUCT (code, TS_LIST))
Index: tree-core.h
===================================================================
--- tree-core.h (revision 251119)
+++ tree-core.h (working copy)
@@ -1552,7 +1552,7 @@ struct GTY(()) tree_type_non_common {
tree values;
tree minval;
tree maxval;
- tree binfo;
+ tree lang_1;
};
struct GTY (()) tree_binfo {
Index: tree-streamer-in.c
===================================================================
--- tree-streamer-in.c (revision 251119)
+++ tree-streamer-in.c (working copy)
@@ -841,8 +841,6 @@ lto_input_ts_type_non_common_tree_pointe
if (!POINTER_TYPE_P (expr))
TYPE_MIN_VALUE_RAW (expr) = stream_read_tree (ib, data_in);
TYPE_MAX_VALUE_RAW (expr) = stream_read_tree (ib, data_in);
- if (RECORD_OR_UNION_TYPE_P (expr))
- TYPE_BINFO (expr) = stream_read_tree (ib, data_in);
}
Index: tree-streamer-out.c
===================================================================
--- tree-streamer-out.c (revision 251119)
+++ tree-streamer-out.c (working copy)
@@ -706,8 +706,6 @@ write_ts_type_non_common_tree_pointers (
if (!POINTER_TYPE_P (expr))
stream_write_tree (ob, TYPE_MIN_VALUE_RAW (expr), ref_p);
stream_write_tree (ob, TYPE_MAX_VALUE_RAW (expr), ref_p);
- if (RECORD_OR_UNION_TYPE_P (expr))
- stream_write_tree (ob, TYPE_BINFO (expr), ref_p);
}
Index: tree.c
===================================================================
--- tree.c (revision 251119)
+++ tree.c (working copy)
@@ -4890,9 +4890,7 @@ free_lang_data_in_type (tree type)
leading to false ODR violation errors when merging two
instances of the same function signature compiled by
different front ends. */
- tree p;
-
- for (p = TYPE_ARG_TYPES (type); p; p = TREE_CHAIN (p))
+ for (tree p = TYPE_ARG_TYPES (type); p; p = TREE_CHAIN (p))
{
tree arg_type = TREE_VALUE (p);
@@ -4908,69 +4906,30 @@ free_lang_data_in_type (tree type)
TREE_PURPOSE (p) = NULL;
}
}
- if (TREE_CODE (type) == METHOD_TYPE)
- {
- tree p;
-
- for (p = TYPE_ARG_TYPES (type); p; p = TREE_CHAIN (p))
- {
- /* C++ FE uses TREE_PURPOSE to store initial values. */
- TREE_PURPOSE (p) = NULL;
- }
- }
-
- /* Remove members that are not actually FIELD_DECLs from the field
- list of an aggregate. These occur in C++. */
- if (RECORD_OR_UNION_TYPE_P (type))
- {
- tree prev, member;
-
- /* Note that TYPE_FIELDS can be shared across distinct
- TREE_TYPEs. Therefore, if the first field of TYPE_FIELDS is
- to be removed, we cannot set its TREE_CHAIN to NULL.
- Otherwise, we would not be able to find all the other fields
- in the other instances of this TREE_TYPE.
-
- This was causing an ICE in testsuite/g++.dg/lto/20080915.C. */
- prev = NULL_TREE;
- member = TYPE_FIELDS (type);
- while (member)
- {
- if (TREE_CODE (member) == FIELD_DECL
- || (TREE_CODE (member) == TYPE_DECL
- && !DECL_IGNORED_P (member)
- && debug_info_level > DINFO_LEVEL_TERSE
- && !is_redundant_typedef (member)))
- {
- if (prev)
- TREE_CHAIN (prev) = member;
- else
- TYPE_FIELDS (type) = member;
- prev = member;
- }
-
- member = TREE_CHAIN (member);
- }
-
- if (prev)
- TREE_CHAIN (prev) = NULL_TREE;
- else
- TYPE_FIELDS (type) = NULL_TREE;
+ else if (TREE_CODE (type) == METHOD_TYPE)
+ for (tree p = TYPE_ARG_TYPES (type); p; p = TREE_CHAIN (p))
+ /* C++ FE uses TREE_PURPOSE to store initial values. */
+ TREE_PURPOSE (p) = NULL;
+ else if (RECORD_OR_UNION_TYPE_P (type))
+ {
+ /* Remove members that are not FIELD_DECLs (and maybe
+ TYPE_DECLs) from the field list of an aggregate. These occur
+ in C++. */
+ for (tree *prev = &TYPE_FIELDS (type), member; (member = *prev);)
+ if (TREE_CODE (member) == FIELD_DECL
+ || (TREE_CODE (member) == TYPE_DECL
+ && !DECL_IGNORED_P (member)
+ && debug_info_level > DINFO_LEVEL_TERSE
+ && !is_redundant_typedef (member)))
+ prev = &DECL_CHAIN (member);
+ else
+ *prev = DECL_CHAIN (member);
/* FIXME: C FE uses TYPE_VFIELD to record C_TYPE_INCOMPLETE_VARS
and danagle the pointer from time to time. */
if (TYPE_VFIELD (type) && TREE_CODE (TYPE_VFIELD (type)) != FIELD_DECL)
TYPE_VFIELD (type) = NULL_TREE;
- /* Splice out FUNCTION_DECLS and TEMPLATE_DECLS from
- TYPE_FIELDS. So LTO doesn't grow. */
- for (tree probe, *prev= &TYPE_FIELDS (type); (probe = *prev); )
- if (TREE_CODE (probe) == FUNCTION_DECL
- || TREE_CODE (probe) == TEMPLATE_DECL)
- *prev = probe;
- else
- prev = &DECL_CHAIN (probe);
-
if (TYPE_BINFO (type))
{
free_lang_data_in_binfo (TYPE_BINFO (type));
@@ -4987,21 +4946,16 @@ free_lang_data_in_type (tree type)
TYPE_BINFO (type) = NULL;
}
}
- else
+ else if (INTEGRAL_TYPE_P (type)
+ || SCALAR_FLOAT_TYPE_P (type)
+ || FIXED_POINT_TYPE_P (type))
{
- /* For non-aggregate types, clear out the language slot (which
- overloads TYPE_BINFO). */
- TYPE_LANG_SLOT_1 (type) = NULL_TREE;
-
- if (INTEGRAL_TYPE_P (type)
- || SCALAR_FLOAT_TYPE_P (type)
- || FIXED_POINT_TYPE_P (type))
- {
- free_lang_data_in_one_sizepos (&TYPE_MIN_VALUE (type));
- free_lang_data_in_one_sizepos (&TYPE_MAX_VALUE (type));
- }
+ free_lang_data_in_one_sizepos (&TYPE_MIN_VALUE (type));
+ free_lang_data_in_one_sizepos (&TYPE_MAX_VALUE (type));
}
+ TYPE_LANG_SLOT_1 (type) = NULL_TREE;
+
free_lang_data_in_one_sizepos (&TYPE_SIZE (type));
free_lang_data_in_one_sizepos (&TYPE_SIZE_UNIT (type));
@@ -5382,6 +5336,7 @@ find_decls_types_r (tree *tp, int *ws, v
this way. */
if (!POINTER_TYPE_P (t))
fld_worklist_push (TYPE_MIN_VALUE_RAW (t), fld);
+ /* TYPE_MAX_VALUE_RAW is TYPE_BINFO for record types. */
if (!RECORD_OR_UNION_TYPE_P (t))
fld_worklist_push (TYPE_MAX_VALUE_RAW (t), fld);
fld_worklist_push (TYPE_MAIN_VARIANT (t), fld);
@@ -13267,9 +13222,23 @@ verify_type (const_tree t)
but does not for C sizetypes in LTO. */
}
- /* Check various uses of TYPE_MAXVAL. */
+ /* Check various uses of TYPE_MAXVAL_RAW. */
if (RECORD_OR_UNION_TYPE_P (t))
{
+ if (!TYPE_BINFO (t))
+ ;
+ else if (TREE_CODE (TYPE_BINFO (t)) != TREE_BINFO)
+ {
+ error ("TYPE_BINFO is not TREE_BINFO");
+ debug_tree (TYPE_BINFO (t));
+ error_found = true;
+ }
+ else if (TREE_TYPE (TYPE_BINFO (t)) != TYPE_MAIN_VARIANT (t))
+ {
+ error ("TYPE_BINFO type is not TYPE_MAIN_VARIANT");
+ debug_tree (TREE_TYPE (TYPE_BINFO (t)));
+ error_found = true;
+ }
}
else if (TREE_CODE (t) == FUNCTION_TYPE || TREE_CODE (t) == METHOD_TYPE)
{
@@ -13318,19 +13287,7 @@ verify_type (const_tree t)
error_found = true;
}
- /* Check various uses of TYPE_BINFO. */
- if (RECORD_OR_UNION_TYPE_P (t))
- {
- if (!TYPE_BINFO (t))
- ;
- else if (TREE_CODE (TYPE_BINFO (t)) != TREE_BINFO)
- {
- error ("TYPE_BINFO is not TREE_BINFO");
- debug_tree (TYPE_BINFO (t));
- error_found = true;
- }
- }
- else if (TYPE_LANG_SLOT_1 (t) && in_lto_p)
+ if (TYPE_LANG_SLOT_1 (t) && in_lto_p)
{
error ("TYPE_LANG_SLOT_1 (binfo) field is non-NULL");
debug_tree (TYPE_LANG_SLOT_1 (t));
Index: tree.h
===================================================================
--- tree.h (revision 251119)
+++ tree.h (working copy)
@@ -2129,14 +2129,13 @@ extern machine_mode element_mode (const_
#define TYPE_ARRAY_MAX_SIZE(ARRAY_TYPE) \
(ARRAY_TYPE_CHECK (ARRAY_TYPE)->type_non_common.maxval)
#define TYPE_MAX_VALUE_RAW(NODE) (TYPE_CHECK (NODE)->type_non_common.maxval)
-
/* For record and union types, information about this type, as a base type
for itself. */
-#define TYPE_BINFO(NODE) (RECORD_OR_UNION_CHECK (NODE)->type_non_common.binfo)
+#define TYPE_BINFO(NODE) (RECORD_OR_UNION_CHECK (NODE)->type_non_common.maxval)
-/* For non record and union types, used in a language-dependent way. */
+/* For types, used in a language-dependent way. */
#define TYPE_LANG_SLOT_1(NODE) \
- (NOT_RECORD_OR_UNION_CHECK (NODE)->type_non_common.binfo)
+ (TYPE_CHECK (NODE)->type_non_common.lang_1)
/* Define accessor macros for information about type inheritance
and basetypes.