aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2014-06-28 20:29:32 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2014-06-28 18:29:32 +0000
commitb49407f81a769c53bc2dccb20c2f3a7b1b255290 (patch)
tree65bca9d9066431bf79ff6235031e6588852b5bfd /gcc
parentc7e1befad2b375b2245dca11329df92b600ef3ed (diff)
downloadgcc-b49407f81a769c53bc2dccb20c2f3a7b1b255290.zip
gcc-b49407f81a769c53bc2dccb20c2f3a7b1b255290.tar.gz
gcc-b49407f81a769c53bc2dccb20c2f3a7b1b255290.tar.bz2
ipa-prop.c (ipa_set_jf_known_type): Record always the main variant of the type.
* ipa-prop.c (ipa_set_jf_known_type): Record always the main variant of the type. (ipa_set_ancestor_jf) Likewise. (check_stmt_for_type_change): Check that we work on main variant. (detect_type_change): Look into main variant. (compute_known_type_jump_func): Check that main variant has BINFO. From-SVN: r212108
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/ipa-prop.c19
2 files changed, 24 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f5d9983..75b2816 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,14 @@
2014-06-28 Jan Hubicka <hubicka@ucw.cz>
+ * ipa-prop.c (ipa_set_jf_known_type): Record always the main variant
+ of the type.
+ (ipa_set_ancestor_jf) Likewise.
+ (check_stmt_for_type_change): Check that we work on main variant.
+ (detect_type_change): Look into main variant.
+ (compute_known_type_jump_func): Check that main variant has BINFO.
+
+2014-06-28 Jan Hubicka <hubicka@ucw.cz>
+
* ipa-devirt.c (set_type_binfo): New function.
(add_type_duplicate): Use it.
(get_odr_type): Sanity check that binfos points to main variants.
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 68efc77..dab8291 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -438,6 +438,11 @@ static void
ipa_set_jf_known_type (struct ipa_jump_func *jfunc, HOST_WIDE_INT offset,
tree base_type, tree component_type)
{
+ /* Recording and propagating main variants increases change that types
+ will match. */
+ base_type = TYPE_MAIN_VARIANT (base_type);
+ component_type = TYPE_MAIN_VARIANT (component_type);
+
gcc_assert (TREE_CODE (component_type) == RECORD_TYPE
&& TYPE_BINFO (component_type));
if (!flag_devirtualize)
@@ -529,6 +534,8 @@ ipa_set_ancestor_jf (struct ipa_jump_func *jfunc, HOST_WIDE_INT offset,
{
if (!flag_devirtualize)
type_preserved = false;
+ if (type)
+ type = TYPE_MAIN_VARIANT (type);
gcc_assert (!type_preserved
|| (TREE_CODE (type) == RECORD_TYPE
&& TYPE_BINFO (type)
@@ -712,7 +719,9 @@ check_stmt_for_type_change (ao_ref *ao ATTRIBUTE_UNUSED, tree vdef, void *data)
if (stmt_may_be_vtbl_ptr_store (stmt))
{
tree type;
+
type = extr_type_from_vtbl_ptr_store (stmt, tci);
+ gcc_assert (!type || TYPE_MAIN_VARIANT (type) == type);
if (tci->type_maybe_changed
&& type != tci->known_current_type)
tci->multiple_types_encountered = true;
@@ -749,10 +758,12 @@ detect_type_change (tree arg, tree base, tree comp_type, gimple call,
/* Be sure expected_type is polymorphic. */
|| !comp_type
|| TREE_CODE (comp_type) != RECORD_TYPE
- || !TYPE_BINFO (comp_type)
- || !BINFO_VTABLE (TYPE_BINFO (comp_type)))
+ || !TYPE_BINFO (TYPE_MAIN_VARIANT (comp_type))
+ || !BINFO_VTABLE (TYPE_BINFO (TYPE_MAIN_VARIANT (comp_type))))
return true;
+ comp_type = TYPE_MAIN_VARIANT (comp_type);
+
/* C++ methods are not allowed to change THIS pointer unless they
are constructors or destructors. */
if (TREE_CODE (base) == MEM_REF
@@ -1408,8 +1419,8 @@ compute_known_type_jump_func (tree op, struct ipa_jump_func *jfunc,
/* Be sure expected_type is polymorphic. */
|| !expected_type
|| TREE_CODE (expected_type) != RECORD_TYPE
- || !TYPE_BINFO (expected_type)
- || !BINFO_VTABLE (TYPE_BINFO (expected_type)))
+ || !TYPE_BINFO (TYPE_MAIN_VARIANT (expected_type))
+ || !BINFO_VTABLE (TYPE_BINFO (TYPE_MAIN_VARIANT (expected_type))))
return;
op = TREE_OPERAND (op, 0);