sem_function::bb_dict_test should take a vec<int> *
diff mbox

Message ID 1424310247-3852-1-git-send-email-tbsaunde+gcc@tbsaunde.org
State New
Headers show

Commit Message

tbsaunde+gcc@tbsaunde.org Feb. 19, 2015, 1:44 a.m. UTC
From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

bb_dict_test () ment to operate on the callers vector, not a copy of it.
Otherwise it either does nothing or crashes.

approved by Honza off list committing to trunk (bootstrapped + regtested x86_64-linux-gnu).

Trev

gcc/ChangeLog:

2015-02-18  Trevor Saunders  <tsaunders@mozilla.com>

	* ipa-icf.c (sem_function::equals_private): Adjust.
	(sem_function::bb_dict_test): Take a vec<int> * instead of
	auto_vec<int>.
	* ipa-icf.h (bb_dict_test): Likewise.
---
 gcc/ChangeLog |  7 +++++++
 gcc/ipa-icf.c | 16 ++++++++--------
 gcc/ipa-icf.h |  2 +-
 3 files changed, 16 insertions(+), 9 deletions(-)

Patch
diff mbox

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 07cadb3..174e5b4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@ 
+2015-02-18  Trevor Saunders  <tsaunders@mozilla.com>
+
+	* ipa-icf.c (sem_function::equals_private): Adjust.
+	(sem_function::bb_dict_test): Take a vec<int> * instead of
+	auto_vec<int>.
+	* ipa-icf.h (bb_dict_test): Likewise.
+
 2015-02-18  Jakub Jelinek  <jakub@redhat.com>
 
 	PR gcov-profile/64634
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 692946a..494fdcf 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -563,10 +563,10 @@  sem_function::equals_private (sem_item *item,
 	  if (e1->flags != e2->flags)
 	    return return_false_with_msg ("flags comparison returns false");
 
-	  if (!bb_dict_test (bb_dict, e1->src->index, e2->src->index))
+	  if (!bb_dict_test (&bb_dict, e1->src->index, e2->src->index))
 	    return return_false_with_msg ("edge comparison returns false");
 
-	  if (!bb_dict_test (bb_dict, e1->dest->index, e2->dest->index))
+	  if (!bb_dict_test (&bb_dict, e1->dest->index, e2->dest->index))
 	    return return_false_with_msg ("BB comparison returns false");
 
 	  if (!m_checker->compare_edge (e1, e2))
@@ -1053,21 +1053,21 @@  sem_function::icf_handled_component_p (tree t)
    corresponds to TARGET.  */
 
 bool
-sem_function::bb_dict_test (auto_vec<int> bb_dict, int source, int target)
+sem_function::bb_dict_test (vec<int> *bb_dict, int source, int target)
 {
   source++;
   target++;
 
-  if (bb_dict.length () <= (unsigned)source)
-    bb_dict.safe_grow_cleared (source + 1);
+  if (bb_dict->length () <= (unsigned)source)
+    bb_dict->safe_grow_cleared (source + 1);
 
-  if (bb_dict[source] == 0)
+  if ((*bb_dict)[source] == 0)
     {
-      bb_dict[source] = target;
+      (*bb_dict)[source] = target;
       return true;
     }
   else
-    return bb_dict[source] == target;
+    return (*bb_dict)[source] == target;
 }
 
 /* Iterates all tree types in T1 and T2 and returns true if all types
diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
index adbedd6..a55699b 100644
--- a/gcc/ipa-icf.h
+++ b/gcc/ipa-icf.h
@@ -275,7 +275,7 @@  private:
 
   /* Basic blocks dictionary BB_DICT returns true if SOURCE index BB
      corresponds to TARGET.  */
-  bool bb_dict_test (auto_vec<int> bb_dict, int source, int target);
+  bool bb_dict_test (vec<int> *bb_dict, int source, int target);
 
   /* Iterates all tree types in T1 and T2 and returns true if all types
      are compatible. If COMPARE_POLYMORPHIC is set to true,