From 4d6eb35a6dbe6c9808779ca446667f8a8374a11b Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Tue, 19 May 2015 23:02:06 +0200 Subject: [PATCH] ipa-devirt.c (type_in_anonymous_namespace_p): Return true or implicit declarations. * ipa-devirt.c (type_in_anonymous_namespace_p): Return true or implicit declarations. (odr_type_p): Check that TYPE_NAME is TYPE_DECL before looking into it. (get_odr_type): Check type has linkage before adding bases. (register_odr_type): Check that type has linkage before adding it. (type_known_to_have_no_deriavations_p): Rename to .. (type_known_to_have_no_derivations_p): This one. * ipa-utils.h (type_known_to_have_no_deriavations_p): Rename to .. (type_known_to_have_no_derivations_p): This one. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::restrict_to_inner_type): Check that type has linkage. From-SVN: r223415 --- gcc/ChangeLog | 16 ++++++++++++++++ gcc/ipa-devirt.c | 10 +++++++--- gcc/ipa-polymorphic-call.c | 5 +++-- gcc/ipa-utils.h | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d692d06376a..f9d91ecf205 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2015-05-19 Jan Hubicka + + * ipa-devirt.c (type_in_anonymous_namespace_p): Return true + or implicit declarations. + (odr_type_p): Check that TYPE_NAME is TYPE_DECL before looking + into it. + (get_odr_type): Check type has linkage before adding bases. + (register_odr_type): Check that type has linkage before adding it. + (type_known_to_have_no_deriavations_p): Rename to .. + (type_known_to_have_no_derivations_p): This one. + * ipa-utils.h (type_known_to_have_no_deriavations_p): Rename to .. + (type_known_to_have_no_derivations_p): This one. + * ipa-polymorphic-call.c + (ipa_polymorphic_call_context::restrict_to_inner_type): Check that + type has linkage. + 2015-05-19 Eric Botcazou * stor-layout.c (finalize_type_size): Use AGGREGATE_TYPE_P. diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index bf43859f47e..09c3b5b0455 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -269,6 +269,8 @@ type_in_anonymous_namespace_p (const_tree t) if (TYPE_STUB_DECL (t) && !TREE_PUBLIC (TYPE_STUB_DECL (t))) { + if (DECL_ARTIFICIAL (TYPE_NAME (t))) + return true; tree ctx = DECL_CONTEXT (TYPE_NAME (t)); while (ctx) { @@ -296,7 +298,7 @@ odr_type_p (const_tree t) to care, since it is used only for type merging. */ gcc_checking_assert (in_lto_p || flag_lto); - return (TYPE_NAME (t) + return (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL && (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))); } @@ -2124,6 +2126,7 @@ get_odr_type (tree type, bool insert) } if (build_bases && TREE_CODE (type) == RECORD_TYPE && TYPE_BINFO (type) + && type_with_linkage_p (type) && type == TYPE_MAIN_VARIANT (type)) { tree binfo = TYPE_BINFO (type); @@ -2183,7 +2186,8 @@ register_odr_type (tree type) makes it possible that non-ODR type is main_odr_variant of ODR type. Things may get smoother if LTO FE set mangled name of those types same way as C++ FE does. */ - if (odr_type_p (main_odr_variant (TYPE_MAIN_VARIANT (type)))) + if (odr_type_p (main_odr_variant (TYPE_MAIN_VARIANT (type))) + && odr_type_p (TYPE_MAIN_VARIANT (type))) get_odr_type (TYPE_MAIN_VARIANT (type), true); if (TYPE_MAIN_VARIANT (type) != type && odr_type_p (main_odr_variant (type))) get_odr_type (type, true); @@ -2192,7 +2196,7 @@ register_odr_type (tree type) /* Return true if type is known to have no derivations. */ bool -type_known_to_have_no_deriavations_p (tree t) +type_known_to_have_no_derivations_p (tree t) { return (type_all_derivations_known_p (t) && (TYPE_FINAL_P (t) diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index 41d56872e60..083648d7e42 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -269,7 +269,8 @@ ipa_polymorphic_call_context::restrict_to_inner_class (tree otr_type, types. Testing it here may help us to avoid speculation. */ if (otr_type && TREE_CODE (outer_type) == RECORD_TYPE && (!in_lto_p || odr_type_p (outer_type)) - && type_known_to_have_no_deriavations_p (outer_type)) + && type_with_linkage_p (outer_type) + && type_known_to_have_no_derivations_p (outer_type)) maybe_derived_type = false; /* Type can not contain itself on an non-zero offset. In that case @@ -393,7 +394,7 @@ ipa_polymorphic_call_context::restrict_to_inner_class (tree otr_type, goto no_useful_type_info; cur_offset = new_offset; - type = subtype; + type = TYPE_MAIN_VARIANT (subtype); if (!speculative) { outer_type = type; diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h index 3378f6946f9..46c82dafd80 100644 --- a/gcc/ipa-utils.h +++ b/gcc/ipa-utils.h @@ -80,7 +80,7 @@ bool vtable_pointer_value_to_vtable (const_tree, tree *, unsigned HOST_WIDE_INT tree subbinfo_with_vtable_at_offset (tree, unsigned HOST_WIDE_INT, tree); void compare_virtual_tables (varpool_node *, varpool_node *); bool type_all_derivations_known_p (const_tree); -bool type_known_to_have_no_deriavations_p (tree); +bool type_known_to_have_no_derivations_p (tree); bool contains_polymorphic_type_p (const_tree); void register_odr_type (tree); bool types_must_be_same_for_odr (tree, tree); -- 2.30.2