public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: "gcc-pa >> GCC Patches" <gcc-patches@gcc.gnu.org>
Cc: pinskia@gcc.gnu.org, "hubicka >> Jan Hubicka" <hubicka@ucw.cz>
Subject: [PATCH] Fix for PR63569
Date: Fri, 17 Oct 2014 13:45:00 -0000	[thread overview]
Message-ID: <54411B64.1060908@suse.cz> (raw)

[-- Attachment #1: Type: text/plain, Size: 153 bytes --]

Hello.

Following patch fixes PR63569.

Bootstrap executed on ppc64-linux and no regression seen on x86_64-pc-linux.
Ready for trunk?

Thank you,
Martin

[-- Attachment #2: ipa-icf-volatility.changelog --]
[-- Type: text/plain, Size: 387 bytes --]

gcc/testsuite/ChangeLog:

2014-10-17  Martin Liska  <mliska@suse.cz>

	* gcc.dg/ipa/ipa-icf-31.c: New test.


gcc/ChangeLog:

2014-10-17  Martin Liska  <mliska@suse.cz>

	* ipa-icf-gimple.c (func_checker::compare_volatility): New function.
	(func_checker::compare_gimple_call): Volatility check added.
	(func_checker::compare_gimple_assign): Likewise.
	* ipa-icf-gimple.h: New function.

[-- Attachment #3: ipa-icf-volatility.patch --]
[-- Type: text/x-patch, Size: 2715 bytes --]

diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 792a3e4..1b9ee85 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -452,6 +452,17 @@ func_checker::compare_tree_list_operand (tree t1, tree t2)
   return true;
 }
 
+/* Compares if both trees T1 and T2 have equal volatility.  */
+
+bool
+func_checker::compare_volatility (tree t1, tree t2)
+{
+  if (t1 && t2)
+    return TREE_THIS_VOLATILE (t1) == TREE_THIS_VOLATILE (t2);
+
+  return !(t1 || t2);
+}
+
 /* Verifies that trees T1 and T2, representing function declarations
    are equivalent from perspective of ICF.  */
 
@@ -663,6 +674,9 @@ func_checker::compare_gimple_call (gimple s1, gimple s2)
   t1 = gimple_get_lhs (s1);
   t2 = gimple_get_lhs (s2);
 
+  if (!compare_volatility (t1, t2))
+    return return_false_with_msg ("different volatility for call statement");
+
   return compare_operand (t1, t2);
 }
 
@@ -696,8 +710,11 @@ func_checker::compare_gimple_assign (gimple s1, gimple s2)
 
       if (!compare_operand (arg1, arg2))
 	return false;
-    }
 
+      if (!compare_volatility (arg1, arg2))
+	return return_false_with_msg ("different volatility for assignment "
+	  "statement");
+    }
 
   return true;
 }
diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h
index 8487a2a..b791c21 100644
--- a/gcc/ipa-icf-gimple.h
+++ b/gcc/ipa-icf-gimple.h
@@ -209,6 +209,10 @@ public:
      two trees are semantically equivalent.  */
   bool compare_tree_list_operand (tree t1, tree t2);
 
+  /* Compares two tree list operands T1 and T2 and returns true if these
+     two trees are semantically equivalent.  */
+  bool compare_volatility (tree t1, tree t2);
+
   /* Verifies that trees T1 and T2, representing function declarations
      are equivalent from perspective of ICF.  */
   bool compare_function_decl (tree t1, tree t2);
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-31.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-31.c
new file mode 100644
index 0000000..e70d72d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-31.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-fipa-icf -fdump-ipa-icf-details"  } */
+
+
+static int f(int t, int *a) __attribute__((noinline));
+
+static int g(int t, volatile int *a) __attribute__((noinline));
+static int g(int t, volatile int *a)
+{
+  int i;
+  int tt = 0;
+  for(i=0;i<t;i++)
+    tt += *a;
+  return tt;
+}
+static int f(int t, int *a)
+{
+  int i;
+  int tt = 0;
+  for(i=0;i<t;i++)
+    tt += *a;
+  return tt;
+}
+
+
+int main()
+{
+  return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf"  } } */
+/* { dg-final { scan-ipa-dump "different volatility for assignment statement" "icf"  } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */

             reply	other threads:[~2014-10-17 13:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-17 13:45 Martin Liška [this message]
2014-10-20  8:00 ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54411B64.1060908@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=pinskia@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).