From: Martin Liska Date: Fri, 17 Apr 2015 13:56:15 +0000 (+0200) Subject: Fix IPA memory leaks. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bbd08a5dfa54f0f694c7869662531498c3289164;p=gcc.git Fix IPA memory leaks. * ipa-cp.c (ipcp_driver): Release prev_edge_clone. * ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs): Release symbol_compare_collection. * ipa-reference.c: Add TODO that a vector should be released. From-SVN: r222180 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 275e4e07580..75c3ef358b8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-04-17 Martin Liska + + * ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs): + Release symbol_compare_collection. + * ipa-reference.c: Add TODO that a vector should be released. + 2015-04-17 Sivanupandi Pitchumani PR target/65296 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index b902373b31a..a72ac2ee482 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -2712,6 +2712,9 @@ sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa) unsigned sem_item_optimizer::subdivide_classes_by_sensitive_refs () { + typedef hash_map , + symbol_compare_hashmap_traits> subdivide_hash_map; + unsigned newly_created_classes = 0; for (hash_table ::iterator it = m_classes.begin (); @@ -2726,8 +2729,7 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs () if (c->members.length() > 1) { - hash_map , - symbol_compare_hashmap_traits> split_map; + subdivide_hash_map split_map; for (unsigned j = 0; j < c->members.length (); j++) { @@ -2735,10 +2737,15 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs () symbol_compare_collection *collection = new symbol_compare_collection (source_node->node); - vec *slot = &split_map.get_or_insert (collection); + bool existed; + vec *slot = &split_map.get_or_insert (collection, + &existed); gcc_checking_assert (slot); slot->safe_push (source_node); + + if (existed) + delete collection; } /* If the map contains more than one key, we have to split the map @@ -2747,9 +2754,8 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs () { bool first_class = true; - hash_map , - symbol_compare_hashmap_traits>::iterator it2 = split_map.begin (); - for (; it2 != split_map.end (); ++it2) + for (subdivide_hash_map::iterator it2 = split_map.begin (); + it2 != split_map.end (); ++it2) { congruence_class *new_cls; new_cls = new congruence_class (class_id++); @@ -2772,6 +2778,14 @@ sem_item_optimizer::subdivide_classes_by_sensitive_refs () } } } + + /* Release memory. */ + for (subdivide_hash_map::iterator it2 = split_map.begin (); + it2 != split_map.end (); ++it2) + { + delete (*it2).first; + (*it2).second.release (); + } } } diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 219a9b3828d..a420cb2042b 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -150,6 +150,7 @@ static struct cgraph_node_hook_list *node_removal_hook_holder; Indexed by UID of call graph nodes. */ static vec ipa_reference_vars_vector; +/* TODO: find a place where we should release the vector. */ static vec ipa_reference_opt_sum_vector; /* Return the ipa_reference_vars structure starting from the cgraph NODE. */