Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-15 Thread Jeff Law

On 01/15/15 09:20, Rainer Orth wrote:

Martin Liška mli...@suse.cz writes:


On 01/07/2015 12:38 PM, Martin Liška wrote:

Hello.

Following patch adds support for target and optimization nodes
comparison, which is
based on Honza's newly added infrastructure.

Apart from that, there's a small hunk that corrects formatting and
removes unnecessary
call to a comparison function.

Hope it can be applied as one patch.

Tested on x86_64-linux-pc without any new regression introduction.

Ready for trunk?

Thank you,
Martin


Hello.

Apart from the previous patch, I would like to install following patch
which introduces
new dump functions related to target and optimization nodes. These
functions dump just
different flags.

Patch has been tested on x86_64-linux-pc.


Unfortunately, this patch breaks Solaris/SPARC bootstrap:

options-save.c:3267:34: error: unused parameter 'indent' 
[-Werror=unused-parameter]
   int indent,
   ^
options-save.c:3268:55: error: unused parameter 'ptr1' 
[-Werror=unused-parameter]
   struct cl_target_option *ptr1,
^
options-save.c:3269:55: error: unused parameter 'ptr2' 
[-Werror=unused-parameter]
   struct cl_target_option *ptr2)
^

The following patch fixes this and allow the bootstrap to continue.

2015-01-15  Rainer Orth  r...@cebitec.uni-bielefeld.de

* optc-save-gen.awk (cl_target_option_print_diff): Mark indent,
ptr1, ptr2 unused.




Ok for mainline?

OK.
jeff



Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-15 Thread Rainer Orth
Martin Liška mli...@suse.cz writes:

 On 01/07/2015 12:38 PM, Martin Liška wrote:
 Hello.

 Following patch adds support for target and optimization nodes
 comparison, which is
 based on Honza's newly added infrastructure.

 Apart from that, there's a small hunk that corrects formatting and
 removes unnecessary
 call to a comparison function.

 Hope it can be applied as one patch.

 Tested on x86_64-linux-pc without any new regression introduction.

 Ready for trunk?

 Thank you,
 Martin

 Hello.

 Apart from the previous patch, I would like to install following patch
 which introduces
 new dump functions related to target and optimization nodes. These
 functions dump just
 different flags.

 Patch has been tested on x86_64-linux-pc.

Unfortunately, this patch breaks Solaris/SPARC bootstrap:

options-save.c:3267:34: error: unused parameter 'indent' 
[-Werror=unused-parameter]
  int indent,
  ^
options-save.c:3268:55: error: unused parameter 'ptr1' 
[-Werror=unused-parameter]
  struct cl_target_option *ptr1,
   ^
options-save.c:3269:55: error: unused parameter 'ptr2' 
[-Werror=unused-parameter]
  struct cl_target_option *ptr2)
   ^

The following patch fixes this and allow the bootstrap to continue.

2015-01-15  Rainer Orth  r...@cebitec.uni-bielefeld.de

* optc-save-gen.awk (cl_target_option_print_diff): Mark indent,
ptr1, ptr2 unused.

diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -505,9 +505,9 @@ print ;
 print /* Print different target option variables from structures provided as arguments.  */;
 print void;
 print cl_target_option_print_diff (FILE *file,;
-print  int indent,;
-print  struct cl_target_option *ptr1,;
-print  struct cl_target_option *ptr2);
+print  int indent ATTRIBUTE_UNUSED,;
+print  struct cl_target_option *ptr1 ATTRIBUTE_UNUSED,;
+print  struct cl_target_option *ptr2 ATTRIBUTE_UNUSED);
 print {;
 
 print   fputs (\\\n\, file);;

Ok for mainline?

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-15 Thread Martin Liška

On 01/15/2015 05:20 PM, Rainer Orth wrote:

Martin Liška mli...@suse.cz writes:


On 01/07/2015 12:38 PM, Martin Liška wrote:

Hello.

Following patch adds support for target and optimization nodes
comparison, which is
based on Honza's newly added infrastructure.

Apart from that, there's a small hunk that corrects formatting and
removes unnecessary
call to a comparison function.

Hope it can be applied as one patch.

Tested on x86_64-linux-pc without any new regression introduction.

Ready for trunk?

Thank you,
Martin


Hello.

Apart from the previous patch, I would like to install following patch
which introduces
new dump functions related to target and optimization nodes. These
functions dump just
different flags.

Patch has been tested on x86_64-linux-pc.


Unfortunately, this patch breaks Solaris/SPARC bootstrap:

options-save.c:3267:34: error: unused parameter 'indent' 
[-Werror=unused-parameter]
   int indent,
   ^
options-save.c:3268:55: error: unused parameter 'ptr1' 
[-Werror=unused-parameter]
   struct cl_target_option *ptr1,
^
options-save.c:3269:55: error: unused parameter 'ptr2' 
[-Werror=unused-parameter]
   struct cl_target_option *ptr2)
^

The following patch fixes this and allow the bootstrap to continue.

2015-01-15  Rainer Orth  r...@cebitec.uni-bielefeld.de

* optc-save-gen.awk (cl_target_option_print_diff): Mark indent,
ptr1, ptr2 unused.




Ok for mainline?

Rainer



Hello Rainer.

Thank you for the patch.

Martin


Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-13 Thread Jan Hubicka
 Hello.
 
 Following patch adds support for target and optimization nodes comparison, 
 which is
 based on Honza's newly added infrastructure.
 
 Apart from that, there's a small hunk that corrects formatting and removes 
 unnecessary
 call to a comparison function.
 
 Hope it can be applied as one patch.
 
 Tested on x86_64-linux-pc without any new regression introduction.
 
 Ready for trunk?

OK, thanks!
Honza
 
 Thank you,
 Martin

 From 393eaa47c8aef9a91a1c635016f23ca2f5aa25e4 Mon Sep 17 00:00:00 2001
 From: mliska mli...@suse.cz
 Date: Tue, 6 Jan 2015 15:06:18 +0100
 Subject: [PATCH] IPA ICF: target and optimization flags comparison.
 
 gcc/ChangeLog:
 
 2015-01-06  Martin Liska  mli...@suse.cz
 
   * cgraphunit.c (cgraph_node::create_wrapper): Fix level of indentation.
   * ipa-icf.c (sem_function::equals_private): Add support for target and
   (sem_item_optimizer::merge_classes): Remove redundant function
   comparison.
   optimization flags comparison.
   * tree.h (target_opts_for_fn): New function.
 ---
  gcc/cgraphunit.c | 52 ++--
  gcc/ipa-icf.c| 44 +++-
  gcc/tree.h   | 10 ++
  3 files changed, 79 insertions(+), 27 deletions(-)
 
 diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
 index c8c8562..81246e2 100644
 --- a/gcc/cgraphunit.c
 +++ b/gcc/cgraphunit.c
 @@ -2385,40 +2385,40 @@ cgraphunit_c_finalize (void)
  void
  cgraph_node::create_wrapper (cgraph_node *target)
  {
 -/* Preserve DECL_RESULT so we get right by reference flag.  */
 -tree decl_result = DECL_RESULT (decl);
 +  /* Preserve DECL_RESULT so we get right by reference flag.  */
 +  tree decl_result = DECL_RESULT (decl);
  
 -/* Remove the function's body but keep arguments to be reused
 -   for thunk.  */
 -release_body (true);
 -reset ();
 +  /* Remove the function's body but keep arguments to be reused
 + for thunk.  */
 +  release_body (true);
 +  reset ();
  
 -DECL_RESULT (decl) = decl_result;
 -DECL_INITIAL (decl) = NULL;
 -allocate_struct_function (decl, false);
 -set_cfun (NULL);
 +  DECL_RESULT (decl) = decl_result;
 +  DECL_INITIAL (decl) = NULL;
 +  allocate_struct_function (decl, false);
 +  set_cfun (NULL);
  
 -/* Turn alias into thunk and expand it into GIMPLE representation.  */
 -definition = true;
 -thunk.thunk_p = true;
 -thunk.this_adjusting = false;
 +  /* Turn alias into thunk and expand it into GIMPLE representation.  */
 +  definition = true;
 +  thunk.thunk_p = true;
 +  thunk.this_adjusting = false;
  
 -cgraph_edge *e = create_edge (target, NULL, 0, CGRAPH_FREQ_BASE);
 +  cgraph_edge *e = create_edge (target, NULL, 0, CGRAPH_FREQ_BASE);
  
 -tree arguments = DECL_ARGUMENTS (decl);
 +  tree arguments = DECL_ARGUMENTS (decl);
  
 -while (arguments)
 -  {
 - TREE_ADDRESSABLE (arguments) = false;
 - arguments = TREE_CHAIN (arguments);
 -  }
 +  while (arguments)
 +{
 +  TREE_ADDRESSABLE (arguments) = false;
 +  arguments = TREE_CHAIN (arguments);
 +}
  
 -expand_thunk (false, true);
 -e-call_stmt_cannot_inline_p = true;
 +  expand_thunk (false, true);
 +  e-call_stmt_cannot_inline_p = true;
  
 -/* Inline summary set-up.  */
 -analyze ();
 -inline_analyze_function (this);
 +  /* Inline summary set-up.  */
 +  analyze ();
 +  inline_analyze_function (this);
  }
  
  #include gt-cgraphunit.h
 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
 index c7ba75a..28158b3 100644
 --- a/gcc/ipa-icf.c
 +++ b/gcc/ipa-icf.c
 @@ -427,6 +427,49 @@ sem_function::equals_private (sem_item *item,
if (!equals_wpa (item, ignored_nodes))
  return false;
  
 +  /* Checking function TARGET and OPTIMIZATION flags.  */
 +  cl_target_option *tar1 = target_opts_for_fn (decl);
 +  cl_target_option *tar2 = target_opts_for_fn (m_compared_func-decl);
 +
 +  if (tar1 != NULL || tar2 != NULL)
 +{
 +  if (!cl_target_option_eq (tar1, tar2))
 + {
 +   if (dump_file  (dump_flags  TDF_DETAILS))
 + {
 +   fprintf (dump_file, Source target flags\n);
 +   cl_target_option_print (dump_file, 2, tar1);
 +   fprintf (dump_file, Target target flags\n);
 +   cl_target_option_print (dump_file, 2, tar2);
 + }
 +
 +   return return_false_with_msg (Target flags are different);
 + }
 +}
 +  else if (tar1 != NULL || tar2 != NULL)
 +return return_false_with_msg (Target flags are different);
 +
 +  cl_optimization *opt1 = opts_for_fn (decl);
 +  cl_optimization *opt2 = opts_for_fn (m_compared_func-decl);
 +
 +  if (opt1 != NULL  opt2 != NULL)
 +{
 +  if (memcmp (opt1, opt2, sizeof(cl_optimization)))
 + {
 +   if (dump_file  (dump_flags  TDF_DETAILS))
 + {
 +   fprintf (dump_file, Source optimization flags\n);
 +   cl_optimization_print (dump_file, 2, opt1);
 +   fprintf (dump_file, Target 

Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-09 Thread John David Anglin
On Fri, 09 Jan 2015, Kyrill Tkachov wrote:


 On 09/01/15 16:11, Christophe Lyon wrote:
 On 9 January 2015 at 11:26, Martin Liška mli...@suse.cz wrote:
 On 01/09/2015 06:21 AM, Jeff Law wrote:
 On 01/07/15 04:38, Martin Liška wrote:
 Hello.

 Following patch adds support for target and optimization nodes
 comparison, which is
 based on Honza's newly added infrastructure.

 Apart from that, there's a small hunk that corrects formatting and
 removes unnecessary
 call to a comparison function.

 Hope it can be applied as one patch.

 Tested on x86_64-linux-pc without any new regression introduction.

 Ready for trunk?

 Thank you,
 Martin

 0001-IPA-ICF-target-and-optimization-flags-comparison.patch


   From 393eaa47c8aef9a91a1c635016f23ca2f5aa25e4 Mon Sep 17 00:00:00 
 2001
 From: mliskamli...@suse.cz
 Date: Tue, 6 Jan 2015 15:06:18 +0100
 Subject: [PATCH] IPA ICF: target and optimization flags comparison.

 gcc/ChangeLog:

 2015-01-06  Martin Liskamli...@suse.cz

  * cgraphunit.c (cgraph_node::create_wrapper): Fix level of
 indentation.
  * ipa-icf.c (sem_function::equals_private): Add support for target
 and
  (sem_item_optimizer::merge_classes): Remove redundant function
  comparison.
  optimization flags comparison.
  * tree.h (target_opts_for_fn): New function.
 Looks like the changelog is a bit goof'd with lines intermixed.

 Patch itself is good for the trunk.  It'd be nice if you could add a
 testcase as well.

 Jeff

 Hi.

 You are right, I forgot to delete a line in Changelog.
 Attachment contains final version with a new test case I'm going to 
 install.

 Hi,

 It looks like this patch broke GCC builds for ARM and AArch64 targets at 
 least.

 I see failures builds pr-support.o and unwind-arm.o:

 0x10bb077 tree_check
  
 /tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree.h:2778
 0x10bb077 target_opts_for_fn
  
 /tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree.h:4681
 0x10bb077 ipa_icf::sem_function::equals_private(ipa_icf::sem_item*,
 hash_mapsymtab_node*, ipa_icf::sem_item*, default_hashmap_traits)
  
 /tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:431
 0x10bbd27 ipa_icf::sem_function::equals(ipa_icf::sem_item*,
 hash_mapsymtab_node*, ipa_icf::sem_item*, default_hashmap_traits)
  
 /tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:386
 0x10ba63a ipa_icf::sem_item_optimizer::subdivide_classes_by_equality(bool)
  
 /tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:1893
 0x10bcd86 ipa_icf::sem_item_optimizer::execute()
  
 /tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:1712
 0x10bce11 ipa_icf_driver
  
 /tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:2441

 (for target arm-none-eabi)

 Yeah, I see these too when trying to bootstrap arm and aarch64

Also seen on hppa-hpux.


 Kyrill


 Thanks,
 Martin


Dave
-- 
J. David Anglin  dave.ang...@bell.net


Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-09 Thread Christophe Lyon
On 9 January 2015 at 11:26, Martin Liška mli...@suse.cz wrote:
 On 01/09/2015 06:21 AM, Jeff Law wrote:

 On 01/07/15 04:38, Martin Liška wrote:

 Hello.

 Following patch adds support for target and optimization nodes
 comparison, which is
 based on Honza's newly added infrastructure.

 Apart from that, there's a small hunk that corrects formatting and
 removes unnecessary
 call to a comparison function.

 Hope it can be applied as one patch.

 Tested on x86_64-linux-pc without any new regression introduction.

 Ready for trunk?

 Thank you,
 Martin

 0001-IPA-ICF-target-and-optimization-flags-comparison.patch


  From 393eaa47c8aef9a91a1c635016f23ca2f5aa25e4 Mon Sep 17 00:00:00 2001
 From: mliskamli...@suse.cz
 Date: Tue, 6 Jan 2015 15:06:18 +0100
 Subject: [PATCH] IPA ICF: target and optimization flags comparison.

 gcc/ChangeLog:

 2015-01-06  Martin Liskamli...@suse.cz

 * cgraphunit.c (cgraph_node::create_wrapper): Fix level of
 indentation.
 * ipa-icf.c (sem_function::equals_private): Add support for target
 and
 (sem_item_optimizer::merge_classes): Remove redundant function
 comparison.
 optimization flags comparison.
 * tree.h (target_opts_for_fn): New function.

 Looks like the changelog is a bit goof'd with lines intermixed.

 Patch itself is good for the trunk.  It'd be nice if you could add a
 testcase as well.

 Jeff


 Hi.

 You are right, I forgot to delete a line in Changelog.
 Attachment contains final version with a new test case I'm going to install.

Hi,

It looks like this patch broke GCC builds for ARM and AArch64 targets at least.

I see failures builds pr-support.o and unwind-arm.o:

0x10bb077 tree_check
/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree.h:2778
0x10bb077 target_opts_for_fn
/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree.h:4681
0x10bb077 ipa_icf::sem_function::equals_private(ipa_icf::sem_item*,
hash_mapsymtab_node*, ipa_icf::sem_item*, default_hashmap_traits)

/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:431
0x10bbd27 ipa_icf::sem_function::equals(ipa_icf::sem_item*,
hash_mapsymtab_node*, ipa_icf::sem_item*, default_hashmap_traits)

/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:386
0x10ba63a ipa_icf::sem_item_optimizer::subdivide_classes_by_equality(bool)

/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:1893
0x10bcd86 ipa_icf::sem_item_optimizer::execute()

/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:1712
0x10bce11 ipa_icf_driver

/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:2441

(for target arm-none-eabi)

 Thanks,
 Martin


Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-09 Thread Martin Liška

On 01/09/2015 06:21 AM, Jeff Law wrote:

On 01/07/15 04:38, Martin Liška wrote:

Hello.

Following patch adds support for target and optimization nodes
comparison, which is
based on Honza's newly added infrastructure.

Apart from that, there's a small hunk that corrects formatting and
removes unnecessary
call to a comparison function.

Hope it can be applied as one patch.

Tested on x86_64-linux-pc without any new regression introduction.

Ready for trunk?

Thank you,
Martin

0001-IPA-ICF-target-and-optimization-flags-comparison.patch


 From 393eaa47c8aef9a91a1c635016f23ca2f5aa25e4 Mon Sep 17 00:00:00 2001
From: mliskamli...@suse.cz
Date: Tue, 6 Jan 2015 15:06:18 +0100
Subject: [PATCH] IPA ICF: target and optimization flags comparison.

gcc/ChangeLog:

2015-01-06  Martin Liskamli...@suse.cz

* cgraphunit.c (cgraph_node::create_wrapper): Fix level of indentation.
* ipa-icf.c (sem_function::equals_private): Add support for target and
(sem_item_optimizer::merge_classes): Remove redundant function
comparison.
optimization flags comparison.
* tree.h (target_opts_for_fn): New function.

Looks like the changelog is a bit goof'd with lines intermixed.

Patch itself is good for the trunk.  It'd be nice if you could add a testcase 
as well.

Jeff


Hi.

You are right, I forgot to delete a line in Changelog.
Attachment contains final version with a new test case I'm going to install.

Thanks,
Martin
From 76f728dca65a266eb35bb5d96326f28e2147aafa Mon Sep 17 00:00:00 2001
From: mliska mli...@suse.cz
Date: Tue, 6 Jan 2015 15:06:18 +0100
Subject: [PATCH 1/2] IPA ICF: target and optimization flags comparison.

gcc/ChangeLog:

2015-01-06  Martin Liska  mli...@suse.cz

	* cgraphunit.c (cgraph_node::create_wrapper): Fix level of indentation.
	* ipa-icf.c (sem_function::equals_private): Add support for target and
	(sem_item_optimizer::merge_classes): Remove redundant function
	optimization flags comparison.
	* tree.h (target_opts_for_fn): New function.

gcc/testsuite/ChangeLog:

2015-01-09  Martin Liska  mli...@suse.cz

	* gcc.dg/ipa/ipa-icf-32.c: New test.
---
 gcc/cgraphunit.c  | 52 +--
 gcc/ipa-icf.c | 44 -
 gcc/testsuite/gcc.dg/ipa/ipa-icf-32.c | 24 
 gcc/tree.h| 10 +++
 4 files changed, 103 insertions(+), 27 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-icf-32.c

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index c8c8562..81246e2 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2385,40 +2385,40 @@ cgraphunit_c_finalize (void)
 void
 cgraph_node::create_wrapper (cgraph_node *target)
 {
-/* Preserve DECL_RESULT so we get right by reference flag.  */
-tree decl_result = DECL_RESULT (decl);
+  /* Preserve DECL_RESULT so we get right by reference flag.  */
+  tree decl_result = DECL_RESULT (decl);
 
-/* Remove the function's body but keep arguments to be reused
-   for thunk.  */
-release_body (true);
-reset ();
+  /* Remove the function's body but keep arguments to be reused
+ for thunk.  */
+  release_body (true);
+  reset ();
 
-DECL_RESULT (decl) = decl_result;
-DECL_INITIAL (decl) = NULL;
-allocate_struct_function (decl, false);
-set_cfun (NULL);
+  DECL_RESULT (decl) = decl_result;
+  DECL_INITIAL (decl) = NULL;
+  allocate_struct_function (decl, false);
+  set_cfun (NULL);
 
-/* Turn alias into thunk and expand it into GIMPLE representation.  */
-definition = true;
-thunk.thunk_p = true;
-thunk.this_adjusting = false;
+  /* Turn alias into thunk and expand it into GIMPLE representation.  */
+  definition = true;
+  thunk.thunk_p = true;
+  thunk.this_adjusting = false;
 
-cgraph_edge *e = create_edge (target, NULL, 0, CGRAPH_FREQ_BASE);
+  cgraph_edge *e = create_edge (target, NULL, 0, CGRAPH_FREQ_BASE);
 
-tree arguments = DECL_ARGUMENTS (decl);
+  tree arguments = DECL_ARGUMENTS (decl);
 
-while (arguments)
-  {
-	TREE_ADDRESSABLE (arguments) = false;
-	arguments = TREE_CHAIN (arguments);
-  }
+  while (arguments)
+{
+  TREE_ADDRESSABLE (arguments) = false;
+  arguments = TREE_CHAIN (arguments);
+}
 
-expand_thunk (false, true);
-e-call_stmt_cannot_inline_p = true;
+  expand_thunk (false, true);
+  e-call_stmt_cannot_inline_p = true;
 
-/* Inline summary set-up.  */
-analyze ();
-inline_analyze_function (this);
+  /* Inline summary set-up.  */
+  analyze ();
+  inline_analyze_function (this);
 }
 
 #include gt-cgraphunit.h
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index c7ba75a..28158b3 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -427,6 +427,49 @@ sem_function::equals_private (sem_item *item,
   if (!equals_wpa (item, ignored_nodes))
 return false;
 
+  /* Checking function TARGET and OPTIMIZATION flags.  */
+  cl_target_option *tar1 = target_opts_for_fn (decl);
+  cl_target_option *tar2 = 

Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-09 Thread Kyrill Tkachov


On 09/01/15 16:11, Christophe Lyon wrote:

On 9 January 2015 at 11:26, Martin Liška mli...@suse.cz wrote:

On 01/09/2015 06:21 AM, Jeff Law wrote:

On 01/07/15 04:38, Martin Liška wrote:

Hello.

Following patch adds support for target and optimization nodes
comparison, which is
based on Honza's newly added infrastructure.

Apart from that, there's a small hunk that corrects formatting and
removes unnecessary
call to a comparison function.

Hope it can be applied as one patch.

Tested on x86_64-linux-pc without any new regression introduction.

Ready for trunk?

Thank you,
Martin

0001-IPA-ICF-target-and-optimization-flags-comparison.patch


  From 393eaa47c8aef9a91a1c635016f23ca2f5aa25e4 Mon Sep 17 00:00:00 2001
From: mliskamli...@suse.cz
Date: Tue, 6 Jan 2015 15:06:18 +0100
Subject: [PATCH] IPA ICF: target and optimization flags comparison.

gcc/ChangeLog:

2015-01-06  Martin Liskamli...@suse.cz

 * cgraphunit.c (cgraph_node::create_wrapper): Fix level of
indentation.
 * ipa-icf.c (sem_function::equals_private): Add support for target
and
 (sem_item_optimizer::merge_classes): Remove redundant function
 comparison.
 optimization flags comparison.
 * tree.h (target_opts_for_fn): New function.

Looks like the changelog is a bit goof'd with lines intermixed.

Patch itself is good for the trunk.  It'd be nice if you could add a
testcase as well.

Jeff


Hi.

You are right, I forgot to delete a line in Changelog.
Attachment contains final version with a new test case I'm going to install.


Hi,

It looks like this patch broke GCC builds for ARM and AArch64 targets at least.

I see failures builds pr-support.o and unwind-arm.o:

0x10bb077 tree_check
 
/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree.h:2778
0x10bb077 target_opts_for_fn
 
/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree.h:4681
0x10bb077 ipa_icf::sem_function::equals_private(ipa_icf::sem_item*,
hash_mapsymtab_node*, ipa_icf::sem_item*, default_hashmap_traits)
 
/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:431
0x10bbd27 ipa_icf::sem_function::equals(ipa_icf::sem_item*,
hash_mapsymtab_node*, ipa_icf::sem_item*, default_hashmap_traits)
 
/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:386
0x10ba63a ipa_icf::sem_item_optimizer::subdivide_classes_by_equality(bool)
 
/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:1893
0x10bcd86 ipa_icf::sem_item_optimizer::execute()
 
/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:1712
0x10bce11 ipa_icf_driver
 
/tmp/2239141_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/ipa-icf.c:2441

(for target arm-none-eabi)


Yeah, I see these too when trying to bootstrap arm and aarch64

Kyrill




Thanks,
Martin





Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-09 Thread Martin Liška

On 01/07/2015 12:38 PM, Martin Liška wrote:

Hello.

Following patch adds support for target and optimization nodes comparison, 
which is
based on Honza's newly added infrastructure.

Apart from that, there's a small hunk that corrects formatting and removes 
unnecessary
call to a comparison function.

Hope it can be applied as one patch.

Tested on x86_64-linux-pc without any new regression introduction.

Ready for trunk?

Thank you,
Martin


Hello.

Apart from the previous patch, I would like to install following patch which 
introduces
new dump functions related to target and optimization nodes. These functions 
dump just
different flags.

Patch has been tested on x86_64-linux-pc.

Thanks,
Martin
From dfc2b68a2f81745f3768cc9349076cc56d3efc8f Mon Sep 17 00:00:00 2001
From: mliska mli...@suse.cz
Date: Thu, 8 Jan 2015 10:35:38 +0100
Subject: [PATCH 2/2] Option diff dump is added for target and optimization
 flags.

gcc/ChangeLog:

2015-01-09  Martin Liska  mli...@suse.cz

	* ipa-icf.c (sem_function::equals_private): Call new functions
	cl_target_option_print_diff and cl_optimization_print_diff.
	* optc-save-gen.awk (cl_target_option_print_diff): New function.
	(cl_optimization_print_diff): Likewise.
	* opth-gen.awk: Likewise.
---
 gcc/ipa-icf.c |  12 ++---
 gcc/optc-save-gen.awk | 133 ++
 gcc/opth-gen.awk  |   6 +++
 3 files changed, 143 insertions(+), 8 deletions(-)

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 28158b3..3d9943e 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -437,10 +437,8 @@ sem_function::equals_private (sem_item *item,
 	{
 	  if (dump_file  (dump_flags  TDF_DETAILS))
 	{
-	  fprintf (dump_file, Source target flags\n);
-	  cl_target_option_print (dump_file, 2, tar1);
-	  fprintf (dump_file, Target target flags\n);
-	  cl_target_option_print (dump_file, 2, tar2);
+	  fprintf (dump_file, target flags difference);
+	  cl_target_option_print_diff (dump_file, 2, tar1, tar2);
 	}
 
 	  return return_false_with_msg (Target flags are different);
@@ -458,10 +456,8 @@ sem_function::equals_private (sem_item *item,
 	{
 	  if (dump_file  (dump_flags  TDF_DETAILS))
 	{
-	  fprintf (dump_file, Source optimization flags\n);
-	  cl_optimization_print (dump_file, 2, opt1);
-	  fprintf (dump_file, Target optimization flags\n);
-	  cl_optimization_print (dump_file, 2, opt2);
+	  fprintf (dump_file, optimization flags difference);
+	  cl_optimization_print_diff (dump_file, 2, opt1, opt2);
 	}
 
 	  return return_false_with_msg (optimization flags are different);
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index ebeb509..4e28261 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -234,6 +234,69 @@ for (i = 0; i  n_opt_char; i++) {
 print };
 
 print ;
+print /* Print different optimization variables from structures provided as arguments.  */;
+print void;
+print cl_optimization_print_diff (FILE *file,;
+print int indent_to,;
+print struct cl_optimization *ptr1,;
+print struct cl_optimization *ptr2);
+print {;
+
+print   fputs (\\\n\, file);;
+for (i = 0; i  n_opt_other; i++) {
+	print   if (ptr1-x_ var_opt_other[i]  != ptr2-x_ var_opt_other[i] );
+	print fprintf (file, \%*s%s (%#lx/%#lx)\\n\,;
+	print  indent_to, \\,;
+	print  \ var_opt_other[i] \,;
+	print  (unsigned long)ptr1-x_ var_opt_other[i] ,;
+	print  (unsigned long)ptr2-x_ var_opt_other[i] );;
+	print ;
+}
+
+for (i = 0; i  n_opt_int; i++) {
+	print   if (ptr1-x_ var_opt_int[i]  != ptr2-x_ var_opt_int[i] );
+	print fprintf (file, \%*s%s (%#x/%#x)\\n\,;
+	print  indent_to, \\,;
+	print  \ var_opt_int[i] \,;
+	print  ptr1-x_ var_opt_int[i] ,;
+	print  ptr2-x_ var_opt_int[i] );;
+	print ;
+}
+
+for (i = 0; i  n_opt_enum; i++) {
+	print   if (ptr1-x_ var_opt_enum[i]  != ptr2-x_ var_opt_enum[i] );
+	print   fprintf (file, \%*s%s (%#x/%#x)\\n\,;
+	printindent_to, \\,;
+	print\ var_opt_enum[i] \,;
+	print(int) ptr1-x_ var_opt_enum[i] ,;
+	print(int) ptr2-x_ var_opt_enum[i] );;
+	print ;
+}
+
+for (i = 0; i  n_opt_short; i++) {
+	print   if (ptr1-x_ var_opt_short[i]  != ptr2-x_ var_opt_short[i] );
+	print fprintf (file, \%*s%s (%#x/%#x)\\n\,;
+	print  indent_to, \\,;
+	print  \ var_opt_short[i] \,;
+	print  ptr1-x_ var_opt_short[i] ,;
+	print  ptr2-x_ var_opt_short[i] );;
+	print ;
+}
+
+for (i = 0; i  n_opt_char; i++) {
+	print   if (ptr1-x_ var_opt_char[i]  != ptr2-x_ var_opt_char[i] );
+	print fprintf (file, \%*s%s (%#x/%#x)\\n\,;
+	print  indent_to, \\,;
+	print  \ var_opt_char[i] \,;
+	print  ptr1-x_ var_opt_char[i] ,;
+	print  ptr2-x_ var_opt_char[i] );;
+	

Re: [PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-08 Thread Jeff Law

On 01/07/15 04:38, Martin Liška wrote:

Hello.

Following patch adds support for target and optimization nodes
comparison, which is
based on Honza's newly added infrastructure.

Apart from that, there's a small hunk that corrects formatting and
removes unnecessary
call to a comparison function.

Hope it can be applied as one patch.

Tested on x86_64-linux-pc without any new regression introduction.

Ready for trunk?

Thank you,
Martin

0001-IPA-ICF-target-and-optimization-flags-comparison.patch


 From 393eaa47c8aef9a91a1c635016f23ca2f5aa25e4 Mon Sep 17 00:00:00 2001
From: mliskamli...@suse.cz
Date: Tue, 6 Jan 2015 15:06:18 +0100
Subject: [PATCH] IPA ICF: target and optimization flags comparison.

gcc/ChangeLog:

2015-01-06  Martin Liskamli...@suse.cz

* cgraphunit.c (cgraph_node::create_wrapper): Fix level of indentation.
* ipa-icf.c (sem_function::equals_private): Add support for target and
(sem_item_optimizer::merge_classes): Remove redundant function
comparison.
optimization flags comparison.
* tree.h (target_opts_for_fn): New function.

Looks like the changelog is a bit goof'd with lines intermixed.

Patch itself is good for the trunk.  It'd be nice if you could add a 
testcase as well.


Jeff


[PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-07 Thread Martin Liška

Hello.

Following patch adds support for target and optimization nodes comparison, 
which is
based on Honza's newly added infrastructure.

Apart from that, there's a small hunk that corrects formatting and removes 
unnecessary
call to a comparison function.

Hope it can be applied as one patch.

Tested on x86_64-linux-pc without any new regression introduction.

Ready for trunk?

Thank you,
Martin
From 393eaa47c8aef9a91a1c635016f23ca2f5aa25e4 Mon Sep 17 00:00:00 2001
From: mliska mli...@suse.cz
Date: Tue, 6 Jan 2015 15:06:18 +0100
Subject: [PATCH] IPA ICF: target and optimization flags comparison.

gcc/ChangeLog:

2015-01-06  Martin Liska  mli...@suse.cz

	* cgraphunit.c (cgraph_node::create_wrapper): Fix level of indentation.
	* ipa-icf.c (sem_function::equals_private): Add support for target and
	(sem_item_optimizer::merge_classes): Remove redundant function
	comparison.
	optimization flags comparison.
	* tree.h (target_opts_for_fn): New function.
---
 gcc/cgraphunit.c | 52 ++--
 gcc/ipa-icf.c| 44 +++-
 gcc/tree.h   | 10 ++
 3 files changed, 79 insertions(+), 27 deletions(-)

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index c8c8562..81246e2 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2385,40 +2385,40 @@ cgraphunit_c_finalize (void)
 void
 cgraph_node::create_wrapper (cgraph_node *target)
 {
-/* Preserve DECL_RESULT so we get right by reference flag.  */
-tree decl_result = DECL_RESULT (decl);
+  /* Preserve DECL_RESULT so we get right by reference flag.  */
+  tree decl_result = DECL_RESULT (decl);
 
-/* Remove the function's body but keep arguments to be reused
-   for thunk.  */
-release_body (true);
-reset ();
+  /* Remove the function's body but keep arguments to be reused
+ for thunk.  */
+  release_body (true);
+  reset ();
 
-DECL_RESULT (decl) = decl_result;
-DECL_INITIAL (decl) = NULL;
-allocate_struct_function (decl, false);
-set_cfun (NULL);
+  DECL_RESULT (decl) = decl_result;
+  DECL_INITIAL (decl) = NULL;
+  allocate_struct_function (decl, false);
+  set_cfun (NULL);
 
-/* Turn alias into thunk and expand it into GIMPLE representation.  */
-definition = true;
-thunk.thunk_p = true;
-thunk.this_adjusting = false;
+  /* Turn alias into thunk and expand it into GIMPLE representation.  */
+  definition = true;
+  thunk.thunk_p = true;
+  thunk.this_adjusting = false;
 
-cgraph_edge *e = create_edge (target, NULL, 0, CGRAPH_FREQ_BASE);
+  cgraph_edge *e = create_edge (target, NULL, 0, CGRAPH_FREQ_BASE);
 
-tree arguments = DECL_ARGUMENTS (decl);
+  tree arguments = DECL_ARGUMENTS (decl);
 
-while (arguments)
-  {
-	TREE_ADDRESSABLE (arguments) = false;
-	arguments = TREE_CHAIN (arguments);
-  }
+  while (arguments)
+{
+  TREE_ADDRESSABLE (arguments) = false;
+  arguments = TREE_CHAIN (arguments);
+}
 
-expand_thunk (false, true);
-e-call_stmt_cannot_inline_p = true;
+  expand_thunk (false, true);
+  e-call_stmt_cannot_inline_p = true;
 
-/* Inline summary set-up.  */
-analyze ();
-inline_analyze_function (this);
+  /* Inline summary set-up.  */
+  analyze ();
+  inline_analyze_function (this);
 }
 
 #include gt-cgraphunit.h
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index c7ba75a..28158b3 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -427,6 +427,49 @@ sem_function::equals_private (sem_item *item,
   if (!equals_wpa (item, ignored_nodes))
 return false;
 
+  /* Checking function TARGET and OPTIMIZATION flags.  */
+  cl_target_option *tar1 = target_opts_for_fn (decl);
+  cl_target_option *tar2 = target_opts_for_fn (m_compared_func-decl);
+
+  if (tar1 != NULL || tar2 != NULL)
+{
+  if (!cl_target_option_eq (tar1, tar2))
+	{
+	  if (dump_file  (dump_flags  TDF_DETAILS))
+	{
+	  fprintf (dump_file, Source target flags\n);
+	  cl_target_option_print (dump_file, 2, tar1);
+	  fprintf (dump_file, Target target flags\n);
+	  cl_target_option_print (dump_file, 2, tar2);
+	}
+
+	  return return_false_with_msg (Target flags are different);
+	}
+}
+  else if (tar1 != NULL || tar2 != NULL)
+return return_false_with_msg (Target flags are different);
+
+  cl_optimization *opt1 = opts_for_fn (decl);
+  cl_optimization *opt2 = opts_for_fn (m_compared_func-decl);
+
+  if (opt1 != NULL  opt2 != NULL)
+{
+  if (memcmp (opt1, opt2, sizeof(cl_optimization)))
+	{
+	  if (dump_file  (dump_flags  TDF_DETAILS))
+	{
+	  fprintf (dump_file, Source optimization flags\n);
+	  cl_optimization_print (dump_file, 2, opt1);
+	  fprintf (dump_file, Target optimization flags\n);
+	  cl_optimization_print (dump_file, 2, opt2);
+	}
+
+	  return return_false_with_msg (optimization flags are different);
+	}
+}
+  else if (opt1 != NULL || opt2 != NULL)
+return return_false_with_msg (optimization flags are