diff mbox

Fix PR ipa/65318

Message ID 54F85FE8.2070104@suse.cz
State New
Headers show

Commit Message

Martin Liška March 5, 2015, 1:53 p.m. UTC
Hello.

This is patch that prevents merge operation for ICF on variables types which are not compatible.
Regression tests were run on x86_64-linux-pc.

Ready for trunk?
Thanks,
Martin

Comments

Marek Polacek March 5, 2015, 2:29 p.m. UTC | #1
On Thu, Mar 05, 2015 at 02:53:44PM +0100, Martin Liška wrote:
> --- a/gcc/ipa-icf.c
> +++ b/gcc/ipa-icf.c
> @@ -1501,6 +1501,11 @@ sem_variable::equals (sem_item *item,
>    if (DECL_INITIAL (item->decl) == error_mark_node && in_lto_p)
>      dyn_cast <varpool_node *>(item->node)->get_constructor ();
>  
> +  /* As seen in PR ipa/65303 we have to compare variable's types.  */

"variables"?

> +  if (!func_checker::compatible_types_p(TREE_TYPE (decl),

Missing space before paren.

> +					TREE_TYPE (item->decl)))
> +    return return_false_with_msg ("variable types are different");

Here "variables" as well?

> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/ipa/PR65318.c

Why PR* and not pr*, which is common?

	Marek
diff mbox

Patch

From b92ec230162b99ff11d4e5688f63ae978e75af12 Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Thu, 5 Mar 2015 13:41:07 +0100
Subject: [PATCH] Fix PR ipa/65318.

gcc/ChangeLog:

2015-03-05  Martin Liska  <mliska@suse.cz>

	PR ipa/65318
	* ipa-icf.c (sem_variable::equals): Compare variable types.

gcc/testsuite/ChangeLog:

2015-03-05  Martin Liska  <mliska@suse.cz>

	* gcc.dg/ipa/PR65318.c: New test.
---
 gcc/ipa-icf.c                      |  5 +++++
 gcc/testsuite/gcc.dg/ipa/PR65318.c | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/ipa/PR65318.c

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index c55a09f..1752e67 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -1501,6 +1501,11 @@  sem_variable::equals (sem_item *item,
   if (DECL_INITIAL (item->decl) == error_mark_node && in_lto_p)
     dyn_cast <varpool_node *>(item->node)->get_constructor ();
 
+  /* As seen in PR ipa/65303 we have to compare variable's types.  */
+  if (!func_checker::compatible_types_p(TREE_TYPE (decl),
+					TREE_TYPE (item->decl)))
+    return return_false_with_msg ("variable types are different");
+
   ret = sem_variable::equals (DECL_INITIAL (decl),
 			      DECL_INITIAL (item->node->decl));
   if (dump_file && (dump_flags & TDF_DETAILS))
diff --git a/gcc/testsuite/gcc.dg/ipa/PR65318.c b/gcc/testsuite/gcc.dg/ipa/PR65318.c
new file mode 100644
index 0000000..f23b3a2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/PR65318.c
@@ -0,0 +1,18 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf-details"  } */
+
+static short a = 0;
+short b = -1;
+static unsigned short c = 0;
+
+int
+main ()
+{
+  if (a <= b)
+   return 1;
+
+  return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf"  } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
-- 
2.1.2