aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-devirt.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2019-06-27 14:07:43 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2019-06-27 12:07:43 +0000
commita0276c00934da47fa511aa52e1973b68ffd8b2ab (patch)
tree665e4f690d6caafce10b0ade27ecfeef5909742f /gcc/ipa-devirt.c
parentef874db611879d5004e1d834543e55d31f2bfe1c (diff)
downloadgcc-a0276c00934da47fa511aa52e1973b68ffd8b2ab.zip
gcc-a0276c00934da47fa511aa52e1973b68ffd8b2ab.tar.gz
gcc-a0276c00934da47fa511aa52e1973b68ffd8b2ab.tar.bz2
class.c (layout_class_type): Set TYPE_CXX_ODR_P for as-base type copy.
* class.c (layout_class_type): Set TYPE_CXX_ODR_P for as-base type copy. * ipa-devirt.c (odr_type_d): Add tbaa_enabled flag. (add_type_duplicate): When odr hash is not allocated, to nothing. (odr_based_tbaa_p): New function. (set_type_canonical_for_odr_type): New function. * ipa-utils.h (enable_odr_based_tbaa, odr_based_tbaa_p, set_type_canonical_for_odr_type): New. * tree.c (gimple_canonical_types_compatible_p): ODR types with ODR based TBAA are not equivalent to non-ODR types. * lto-common.c: Include demangle.h and tree-pretty-print.h (type_streaming_finished): New static var. (gimple_register_canonical_type_1): Return updated hash; handle ODR types. (iterative_hash_canonical_type): Update use of gimple_register_canonical_type_1. * g++.dg/lto/alias-2_0.C: New testcase. * g++.dg/lto/alias-2_1.C: New testcase. From-SVN: r272749
Diffstat (limited to 'gcc/ipa-devirt.c')
-rw-r--r--gcc/ipa-devirt.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index a4c8b0d..252d920 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -213,6 +213,8 @@ struct GTY(()) odr_type_d
bool odr_violated;
/* Set when virtual table without RTTI previaled table with. */
bool rtti_broken;
+ /* Set when the canonical type is determined using the type name. */
+ bool tbaa_enabled;
};
/* Return TRUE if all derived types of T are known and thus
@@ -1610,6 +1612,9 @@ add_type_duplicate (odr_type val, tree type)
val->types_set->add (type);
+ if (!odr_hash)
+ return NULL;
+
gcc_checking_assert (can_be_name_hashed_p (type)
&& can_be_name_hashed_p (val->type));
@@ -1989,6 +1994,46 @@ prevailing_odr_type (tree type)
return t->type;
}
+/* Set tbaa_enabled flag for TYPE. */
+
+void
+enable_odr_based_tbaa (tree type)
+{
+ odr_type t = get_odr_type (type, true);
+ t->tbaa_enabled = true;
+}
+
+/* True if canonical type of TYPE is determined using ODR name. */
+
+bool
+odr_based_tbaa_p (const_tree type)
+{
+ if (!RECORD_OR_UNION_TYPE_P (type))
+ return false;
+ odr_type t = get_odr_type (const_cast <tree> (type), false);
+ if (!t || !t->tbaa_enabled)
+ return false;
+ return true;
+}
+
+/* Set TYPE_CANONICAL of type and all its variants and duplicates
+ to CANONICAL. */
+
+void
+set_type_canonical_for_odr_type (tree type, tree canonical)
+{
+ odr_type t = get_odr_type (type, false);
+ unsigned int i;
+ tree tt;
+
+ for (tree t2 = t->type; t2; t2 = TYPE_NEXT_VARIANT (t2))
+ TYPE_CANONICAL (t2) = canonical;
+ if (t->types)
+ FOR_EACH_VEC_ELT (*t->types, i, tt)
+ for (tree t2 = tt; t2; t2 = TYPE_NEXT_VARIANT (t2))
+ TYPE_CANONICAL (t2) = canonical;
+}
+
/* Return true if we reported some ODR violation on TYPE. */
bool