diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2015-05-12 20:30:40 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2015-05-12 18:30:40 +0000 |
commit | e7a677ca1a53221276c0b382811c0351d381b35a (patch) | |
tree | b8df808b4fa8ac89aaf5398200870e9e35e4c94b /gcc/tree.c | |
parent | 2162235ef67bd4bb10fa1cc7c05ebb7a04c54625 (diff) | |
download | gcc-e7a677ca1a53221276c0b382811c0351d381b35a.zip gcc-e7a677ca1a53221276c0b382811c0351d381b35a.tar.gz gcc-e7a677ca1a53221276c0b382811c0351d381b35a.tar.bz2 |
ipa-devirt.c (type_with_linkage_p): New function.
* ipa-devirt.c (type_with_linkage_p): New function.
(type_in_anonymous_namespace_p): Move here from tree.c; assert that
type has linkage.
(odr_type_p): Move here from ipa-utils.h; use type_with_linkage_p.
(can_be_name_hashed_p): Simplify.
(hash_odr_name): Check that type has linkage before checking if it is
anonymous.
(types_same_for_odr): Likewise.
(odr_name_hasher::equal): Likewise.
(odr_subtypes_equivalent_p): Likewise.
(warn_types_mismatch): Likewise.
(get_odr_type): Likewise.
(odr_types_equivalent_p): Fix checking of TYPE_MAIN_VARIANT.
* ipa-utils.h (odr_type_p): Move offline.
* tree.c (need_assembler_name_p): Fix handling of types
without linkages.
(type_in_anonymous_namespace_p): Move to ipa-devirt.c
From-SVN: r223094
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 50 |
1 files changed, 22 insertions, 28 deletions
@@ -5160,27 +5160,33 @@ free_lang_data_in_type (tree type) static inline bool need_assembler_name_p (tree decl) { - /* We use DECL_ASSEMBLER_NAME to hold mangled type names for One Definition Rule - merging. */ + /* We use DECL_ASSEMBLER_NAME to hold mangled type names for One Definition + Rule merging. This makes type_odr_p to return true on those types during + LTO and by comparing the mangled name, we can say what types are intended + to be equivalent across compilation unit. + + We do not store names of type_in_anonymous_namespace_p. + + Record, union and enumeration type have linkage that allows use + to check type_in_anonymous_namespace_p. We do not mangle compound types + that always can be compared structurally. + + Similarly for builtin types, we compare properties of their main variant. + A special case are integer types where mangling do make differences + between char/signed char/unsigned char etc. Storing name for these makes + e.g. -fno-signed-char/-fsigned-char mismatches to be handled well. + See cp/mangle.c:write_builtin_type for details. */ + if (flag_lto_odr_type_mering && TREE_CODE (decl) == TYPE_DECL && DECL_NAME (decl) && decl == TYPE_NAME (TREE_TYPE (decl)) - && !is_lang_specific (TREE_TYPE (decl)) - /* Save some work. Names of builtin types are always derived from - properties of its main variant. A special case are integer types - where mangling do make differences between char/signed char/unsigned - char etc. Storing name for these makes e.g. - -fno-signed-char/-fsigned-char mismatches to be handled well. - - See cp/mangle.c:write_builtin_type for details. */ - && (TREE_CODE (TREE_TYPE (decl)) != VOID_TYPE - && TREE_CODE (TREE_TYPE (decl)) != BOOLEAN_TYPE - && TREE_CODE (TREE_TYPE (decl)) != REAL_TYPE - && TREE_CODE (TREE_TYPE (decl)) != FIXED_POINT_TYPE) && !TYPE_ARTIFICIAL (TREE_TYPE (decl)) - && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE) - && !type_in_anonymous_namespace_p (TREE_TYPE (decl))) + && (((RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl)) + || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE) + && !type_in_anonymous_namespace_p (TREE_TYPE (decl))) + || TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE) + && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE)) return !DECL_ASSEMBLER_NAME_SET_P (decl); /* Only FUNCTION_DECLs and VAR_DECLs are considered. */ if (TREE_CODE (decl) != FUNCTION_DECL @@ -12037,18 +12043,6 @@ obj_type_ref_class (tree ref) return TREE_TYPE (ref); } -/* Return true if T is in anonymous namespace. */ - -bool -type_in_anonymous_namespace_p (const_tree t) -{ - /* TREE_PUBLIC of TYPE_STUB_DECL may not be properly set for - bulitin types; those have CONTEXT NULL. */ - if (!TYPE_CONTEXT (t)) - return false; - return (TYPE_STUB_DECL (t) && !TREE_PUBLIC (TYPE_STUB_DECL (t))); -} - /* Lookup sub-BINFO of BINFO of TYPE at offset POS. */ static tree |