diff options
author | Martin Liska <mliska@suse.cz> | 2014-11-27 16:36:10 +0100 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2014-11-27 15:36:10 +0000 |
commit | c190efccf0bd045b1b4ab4316e17a4674698cca8 (patch) | |
tree | af6e5c910894ed736447a5b8f37d44901fde3654 | |
parent | a92bf1b1c7942a6fb8af77bf8d90382aab60341f (diff) | |
download | gcc-c190efccf0bd045b1b4ab4316e17a4674698cca8.zip gcc-c190efccf0bd045b1b4ab4316e17a4674698cca8.tar.gz gcc-c190efccf0bd045b1b4ab4316e17a4674698cca8.tar.bz2 |
IPA ICF: fix memory leak.
* ipa-icf.c (sem_function::equals_private): int* is replaced with
auto_vec.
(sem_function::bb_dict_test): Likewise.
* ipa-icf.h: Likewise.
Co-Authored-By: David Malcolm <dmalcolm@redhat.com>
From-SVN: r218129
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ipa-icf.c | 16 | ||||
-rw-r--r-- | gcc/ipa-icf.h | 2 |
3 files changed, 19 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dad0704..262cc74 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-11-27 Martin Liska <mliska@suse.cz> + David Malcolm <dmalcolm@redhat.com> + + * ipa-icf.c (sem_function::equals_private): int* is replaced with + auto_vec. + (sem_function::bb_dict_test): Likewise. + * ipa-icf.h: Likewise. + 2014-11-27 Richard Biener <rguenther@suse.de> PR middle-end/64088 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index e0633e7..b193200 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -410,7 +410,6 @@ sem_function::equals_private (sem_item *item, basic_block bb1, bb2; edge e1, e2; edge_iterator ei1, ei2; - int *bb_dict = NULL; bool result = true; tree arg1, arg2; @@ -486,12 +485,11 @@ sem_function::equals_private (sem_item *item, dump_message ("All BBs are equal\n"); + auto_vec <int> bb_dict; + /* Basic block edges check. */ for (unsigned i = 0; i < bb_sorted.length (); ++i) { - bb_dict = XNEWVEC (int, bb_sorted.length () + 2); - memset (bb_dict, -1, (bb_sorted.length () + 2) * sizeof (int)); - bb1 = bb_sorted[i]->bb; bb2 = m_compared_func->bb_sorted[i]->bb; @@ -957,9 +955,15 @@ sem_function::icf_handled_component_p (tree t) corresponds to TARGET. */ bool -sem_function::bb_dict_test (int* bb_dict, int source, int target) +sem_function::bb_dict_test (auto_vec<int> bb_dict, int source, int target) { - if (bb_dict[source] == -1) + source++; + target++; + + if (bb_dict.length () <= (unsigned)source) + bb_dict.safe_grow_cleared (source + 1); + + if (bb_dict[source] == 0) { bb_dict[source] = target; return true; diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h index 046e858..8be6149 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 (int* bb_dict, int source, int target); + bool bb_dict_test (auto_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, |