This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR ipa/77653
- From: Martin Liška <mliska at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Biener <richard dot guenther at gmail dot com>
- Date: Thu, 22 Sep 2016 13:18:44 +0200
- Subject: [PATCH] Fix PR ipa/77653
- Authentication-results: sourceware.org; auth=none
Hi.
After some investigation, it shows that IPA ICF merges a pair of variables where
for just one them address matters. Which is obvious error, fixed in attached patch.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Ready to be installed?
Martin
>From d16301adc382a1cf5ede151993633a2a6d29825f Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 22 Sep 2016 11:18:49 +0200
Subject: [PATCH] Fix PR ipa/77653
gcc/testsuite/ChangeLog:
2016-09-22 Martin Liska <mliska@suse.cz>
PR ipa/77653
* gcc.dg/ipa/pr77653.c: New test.
gcc/ChangeLog:
2016-09-22 Martin Liska <mliska@suse.cz>
PR ipa/77653
* ipa-icf.c (sem_variable::merge): Yield merge operation if
alias address matters, not necessarily address of original.
---
gcc/ipa-icf.c | 7 ++-----
gcc/testsuite/gcc.dg/ipa/pr77653.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+), 5 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/ipa/pr77653.c
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 798d833..0869756 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -2179,7 +2179,6 @@ sem_variable::merge (sem_item *alias_item)
varpool_node *alias = alias_var->get_node ();
bool original_discardable = false;
- bool original_address_matters = original->address_matters_p ();
bool alias_address_matters = alias->address_matters_p ();
/* See if original is in a section that can be discarded if the main
@@ -2222,13 +2221,11 @@ sem_variable::merge (sem_item *alias_item)
}
/* We can not merge if address comparsion metters. */
- if (original_address_matters && alias_address_matters
- && flag_merge_constants < 2)
+ if (alias_address_matters && flag_merge_constants < 2)
{
if (dump_file)
fprintf (dump_file,
- "Not unifying; "
- "adress of original and alias may be compared.\n\n");
+ "Not unifying; adress of original may be compared.\n\n");
return false;
}
diff --git a/gcc/testsuite/gcc.dg/ipa/pr77653.c b/gcc/testsuite/gcc.dg/ipa/pr77653.c
new file mode 100644
index 0000000..8d11739
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr77653.c
@@ -0,0 +1,24 @@
+/* { dg-options "-O2 -fdump-ipa-icf-details" } */
+
+int a, b, c, d, e, h, i, j, k, l;
+const int f;
+static int g;
+
+void fn1 (int p1)
+{
+ k = d ? c % k : a * b;
+ h &= j ^ i ^ 1;
+}
+
+int main ()
+{
+ const int *m = &f, **n = &m;
+ l && (*n = &e);
+ if (m != &f)
+ __builtin_abort ();
+ fn1 (g);
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { scan-ipa-dump "Not unifying; adress of original may be compared." "icf" } } */
--
2.9.2