aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2015-03-05 01:10:29 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2015-03-05 00:10:29 +0000
commitfe75bd206937c1362f3d97e6e8bed55fa912461b (patch)
tree81dc24309df2019c75eaf84f0e3205a5dfbb72ef /gcc
parentd10a61fbe8a35256164aca7a9a7a51d16cc57370 (diff)
downloadgcc-fe75bd206937c1362f3d97e6e8bed55fa912461b.zip
gcc-fe75bd206937c1362f3d97e6e8bed55fa912461b.tar.gz
gcc-fe75bd206937c1362f3d97e6e8bed55fa912461b.tar.bz2
re PR ipa/65270 (issues with merging memory accesses from different code paths)
PR ipa/65270 * ipa-icf.c (sem_item::compare_cgraph_references): Compare vtable references for their containing type. (sem_function::equals_wpa): Compare TYPE_RESTRICT and type attributes. From-SVN: r221199
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/ipa-icf.c22
2 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 72760c0..55e212d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2015-03-03 Jan Hubicka <hubicka@ucw.cz>
+
+ PR ipa/65270
+ * ipa-icf.c (sem_item::compare_cgraph_references): Compare
+ vtable references for their containing type.
+ (sem_function::equals_wpa): Compare TYPE_RESTRICT
+ and type attributes.
+
2015-03-04 Eric Botcazou <ebotcazou@adacore.com>
* fold-const.c (round_up_loc): Cast divisor to signed on all paths
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 1055c23..c55a09f 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -345,6 +345,20 @@ sem_item::compare_cgraph_references (
{
enum availability avail1, avail2;
+ if (n1 == n2)
+ return true;
+
+ /* Merging two definitions with a reference to equivalent vtables, but
+ belonging to a different type may result in ipa-polymorphic-call analysis
+ giving a wrong answer about the dynamic type of instance. */
+ if (is_a <varpool_node *> (n1)
+ && (DECL_VIRTUAL_P (n1->decl) || DECL_VIRTUAL_P (n2->decl))
+ && (DECL_VIRTUAL_P (n1->decl) != DECL_VIRTUAL_P (n2->decl)
+ || !types_must_be_same_for_odr (DECL_CONTEXT (n1->decl),
+ DECL_CONTEXT (n2->decl))))
+ return return_false_with_msg
+ ("references to virtual tables can not be merged");
+
if (address && n1->equal_address_to (n2) == 1)
return true;
if (!address && n1->semantically_equivalent_p (n2))
@@ -407,6 +421,10 @@ sem_function::equals_wpa (sem_item *item,
m_compared_func->arg_types[i],
is_not_leaf, i == 0))
return return_false_with_msg ("argument type is different");
+ if (POINTER_TYPE_P (arg_types[i])
+ && (TYPE_RESTRICT (arg_types[i])
+ != TYPE_RESTRICT (m_compared_func->arg_types[i])))
+ return return_false_with_msg ("argument restrict flag mismatch");
}
/* Result type checking. */
@@ -417,6 +435,10 @@ sem_function::equals_wpa (sem_item *item,
if (node->num_references () != item->node->num_references ())
return return_false_with_msg ("different number of references");
+ if (comp_type_attributes (TREE_TYPE (decl),
+ TREE_TYPE (item->decl)) != 1)
+ return return_false_with_msg ("different type attributes");
+
ipa_ref *ref = NULL, *ref2 = NULL;
for (unsigned i = 0; node->iterate_reference (i, ref); i++)
{