This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR ipa/65087


On 03/02/2015 06:20 PM, Jan Hubicka wrote:
Hello.

Following one line patch is fix for PR ipa/65087. No regression has been
seen on x86_64-linux-pc.

OK, it won't happend large programs, but can you arrange its execute method to
return TODO_remove_functions only if some merging actually happened?
Patch is preapproved with this change.

Honza

Yes.

Attached patch is the one I've just installed, where TODO_remove_functions is returned
just for cases where we merge an item.

Thanks,
Martin


Ready for trunk?
Thanks,
Martin

>From f39be56c66387c698546c498550d38512ddeb477 Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Mon, 2 Mar 2015 16:56:42 +0100
Subject: [PATCH] Fix PR ipa/65087.

gcc/ChangeLog:

2015-03-02  Martin Liska  <mliska@suse.cz>
	    Martin Jambor  <mjambor@suse.cz>

	PR ipa/65087
	* ipa-icf.c: Add TODO_remove_functions to the IPA pass.
---
  gcc/ipa-icf.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 31fcbec..56f59a9 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -3049,7 +3049,7 @@ const pass_data pass_data_ipa_icf =
    0,                        /* properties_provided */
    0,                        /* properties_destroyed */
    0,                        /* todo_flags_start */
-  0,                        /* todo_flags_finish */
+  TODO_remove_functions,    /* todo_flags_finish */
  };

  class pass_ipa_icf : public ipa_opt_pass_d
--
2.1.2



>From 3a3bc6bda4ab1c47e8fa74e9a46cbd7abe612cc1 Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Mon, 2 Mar 2015 16:56:42 +0100
Subject: [PATCH] Fix PR ipa/65087.

gcc/ChangeLog:

2015-03-02  Martin Liska  <mliska@suse.cz>
	    Martin Jambor  <mjambor@suse.cz>

	PR ipa/65087
	* ipa-icf.c (sem_item_optimizer::execute): Change function
	return value to boolean.
	(sem_item_optimizer::merge_classes): Likewise.
	(ipa_icf_driver): Return TODO_remove_functions in case there's
	a merge operation processed.
	* ipa-icf.h: Change function return value to boolean.
---
 gcc/ipa-icf.c | 26 ++++++++++++++++++--------
 gcc/ipa-icf.h | 11 +++++++----
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 31fcbec..9cdd73e 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -2167,9 +2167,11 @@ sem_item_optimizer::filter_removed_items (void)
     m_items.safe_push (filtered[i]);
 }
 
-/* Optimizer entry point.  */
+/* Optimizer entry point which returns true in case it processes
+   a merge operation. True is returned if there's a merge operation
+   processed.  */
 
-void
+bool
 sem_item_optimizer::execute (void)
 {
   filter_removed_items ();
@@ -2214,10 +2216,12 @@ sem_item_optimizer::execute (void)
   process_cong_reduction ();
   dump_cong_classes ();
   verify_classes ();
-  merge_classes (prev_class_count);
+  bool merged_p = merge_classes (prev_class_count);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     symtab_node::dump_table (dump_file);
+
+  return merged_p;
 }
 
 /* Function responsible for visiting all potential functions and
@@ -2870,9 +2874,10 @@ sem_item_optimizer::dump_cong_classes (void)
 
 /* After reduction is done, we can declare all items in a group
    to be equal. PREV_CLASS_COUNT is start number of classes
-   before reduction.  */
+   before reduction. True is returned if there's a merge operation
+   processed. */
 
-void
+bool
 sem_item_optimizer::merge_classes (unsigned int prev_class_count)
 {
   unsigned int item_count = m_items.length ();
@@ -2882,6 +2887,8 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count)
   unsigned int non_singular_classes_count = 0;
   unsigned int non_singular_classes_sum = 0;
 
+  bool merged_p = false;
+
   for (hash_table<congruence_class_group_hash>::iterator it = m_classes.begin ();
        it != m_classes.end (); ++it)
     for (unsigned int i = 0; i < (*it)->classes.length (); i++)
@@ -2952,9 +2959,12 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count)
 		alias->dump_to_file (dump_file);
 	      }
 
-	    source->merge (alias);
+	    if (source->merge (alias))
+	      merged_p = true;
 	  }
       }
+
+  return merged_p;
 }
 
 /* Dump function prints all class members to a FILE with an INDENT.  */
@@ -3031,12 +3041,12 @@ ipa_icf_driver (void)
 {
   gcc_assert (optimizer);
 
-  optimizer->execute ();
+  bool merged_p = optimizer->execute ();
 
   delete optimizer;
   optimizer = NULL;
 
-  return 0;
+  return merged_p ? TODO_remove_functions : 0;
 }
 
 const pass_data pass_data_ipa_icf =
diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
index e3582db..1481353 100644
--- a/gcc/ipa-icf.h
+++ b/gcc/ipa-icf.h
@@ -470,8 +470,10 @@ public:
      read-only variables that can be merged.  */
   void parse_funcs_and_vars (void);
 
-  /* Optimizer entry point.  */
-  void execute (void);
+  /* Optimizer entry point which returns true in case it processes
+     a merge operation. True is returned if there's a merge operation
+     processed.  */
+  bool execute (void);
 
   /* Dump function. */
   void dump (void);
@@ -545,8 +547,9 @@ private:
 
   /* After reduction is done, we can declare all items in a group
      to be equal. PREV_CLASS_COUNT is start number of classes
-     before reduction.  */
-  void merge_classes (unsigned int prev_class_count);
+     before reduction. True is returned if there's a merge operation
+     processed.  */
+  bool merge_classes (unsigned int prev_class_count);
 
   /* Adds a newly created congruence class CLS to worklist.  */
   void worklist_push (congruence_class *cls);
-- 
2.1.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]