This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Release unnecesary binfos; avoid field walk in get_binfo_at_offset
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 Nov 2014 21:38:55 +0100
- Subject: Release unnecesary binfos; avoid field walk in get_binfo_at_offset
- Authentication-results: sourceware.org; auth=none
Hi,
after Martin's ipa-cp reorg, get_binfo_at_offset is finally used only
for lookup of base at given offset (not to walk into fields that it
used to do too even if it is not documented and old BINFO code in
ipa-cp relied on it.)
This also allows us to drop BINFOs that are not important for
debug output nor for construction of the type inheritance graph.
This reduce binfos in firefox by about 30%.
Bootstrapped/regtested x86_64-linux, will commit it shortly.
Honza
* tree.c (free_lang_data_in_type): If BINFO has no important
information in it, set it to NULL.
(get_binfo_at_offset): Do not walk fields, only bases.
* ipa-utils.h (polymorphic_type_binfo_p): Be ready for BINFO_TYPE
to be NULL.
* ipa-polymorphic-call.c (record_known_type): Likewise.
Index: tree.c
===================================================================
--- tree.c (revision 217803)
+++ tree.c (working copy)
@@ -4976,7 +4976,14 @@ free_lang_data_in_type (tree type)
TYPE_METHODS (type) = NULL_TREE;
if (TYPE_BINFO (type))
- free_lang_data_in_binfo (TYPE_BINFO (type));
+ {
+ free_lang_data_in_binfo (TYPE_BINFO (type));
+ if ((!BINFO_VTABLE (TYPE_BINFO (type))
+ || !flag_devirtualize)
+ && (!BINFO_N_BASE_BINFOS (TYPE_BINFO (type))
+ || debug_info_level != DINFO_LEVEL_NONE))
+ TYPE_BINFO (type) = NULL;
+ }
}
else
{
@@ -11926,7 +11933,7 @@ get_binfo_at_offset (tree binfo, HOST_WI
for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
{
- if (TREE_CODE (fld) != FIELD_DECL)
+ if (TREE_CODE (fld) != FIELD_DECL || !DECL_ARTIFICIAL (fld))
continue;
pos = int_bit_position (fld);
@@ -11937,12 +11944,6 @@ get_binfo_at_offset (tree binfo, HOST_WI
if (!fld || TREE_CODE (TREE_TYPE (fld)) != RECORD_TYPE)
return NULL_TREE;
- if (!DECL_ARTIFICIAL (fld))
- {
- binfo = TYPE_BINFO (TREE_TYPE (fld));
- if (!binfo)
- return NULL_TREE;
- }
/* Offset 0 indicates the primary base, whose vtable contents are
represented in the binfo for the derived class. */
else if (offset != 0)
@@ -11967,6 +11968,7 @@ get_binfo_at_offset (tree binfo, HOST_WI
* BITS_PER_UNIT < pos
/* Rule out types with no virtual methods or we can get confused
here by zero sized bases. */
+ && TYPE_BINFO (BINFO_TYPE (base_binfo))
&& BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (base_binfo)))
&& (!containing_binfo
|| (tree_to_shwi (BINFO_OFFSET (containing_binfo))
Index: ipa-utils.h
===================================================================
--- ipa-utils.h (revision 217803)
+++ ipa-utils.h (working copy)
@@ -183,7 +183,8 @@ polymorphic_type_binfo_p (const_tree bin
/* See if BINFO's type has an virtual table associtated with it.
Check is defensive because of Java FE produces BINFOs
without BINFO_TYPE set. */
- return BINFO_TYPE (binfo) && BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo)));
+ return (BINFO_TYPE (binfo) && TYPE_BINFO (BINFO_TYPE (binfo))
+ && BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo))));
}
#endif /* GCC_IPA_UTILS_H */
Index: ipa-polymorphic-call.c
===================================================================
--- ipa-polymorphic-call.c (revision 217803)
+++ ipa-polymorphic-call.c (working copy)
@@ -1307,6 +1307,7 @@ record_known_type (struct type_change_in
if (type
&& (offset
|| (TREE_CODE (type) != RECORD_TYPE
+ || !TYPE_BINFO (type)
|| !polymorphic_type_binfo_p (TYPE_BINFO (type)))))
{
ipa_polymorphic_call_context context;