ipa-icf.c was leaking 16 bytes per iteration in the jit testcases here:

80 bytes in 5 blocks are definitely lost in loss record 94 of 199
   at 0x4A0645D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x5D764B7: xmalloc (xmalloc.c:147)
   by 0x5C962FF: ipa_icf::sem_item_optimizer::get_group_by_hash(unsigned int, 
ipa_icf::sem_item_type) (ipa-icf.c:1503)
   by 0x5C96C8C: ipa_icf::sem_item_optimizer::build_hash_based_classes() 
(ipa-icf.c:1723)
   by 0x5C96765: ipa_icf::sem_item_optimizer::execute() (ipa-icf.c:1616)
   by 0x5C98E81: ipa_icf::ipa_icf_driver() (ipa-icf.c:2373)
   by 0x5C993C8: ipa_icf::pass_ipa_icf::execute(function*) (ipa-icf.c:2421)
   by 0x5223CCD: execute_one_pass(opt_pass*) (passes.c:2306)
   by 0x5224BA7: execute_ipa_pass_list(opt_pass*) (passes.c:2700)
   by 0x4E49B0D: ipa_passes() (cgraphunit.c:2088)
   by 0x4E49E2C: symbol_table::compile() (cgraphunit.c:2172)
   by 0x4E4A1C2: symbol_table::finalize_compilation_unit() (cgraphunit.c:2325)

by not freeing the allocation here:

  congruence_class_group *item = XNEW (congruence_class_group);

in sem_item_optimizer::get_group_by_hash.

Fix it.

gcc/ChangeLog:
        PR jit/63854
        * ipa-icf.c (sem_item_optimizer::~sem_item_optimizer): Free each
        congruence_class_group *.
---
 gcc/ipa-icf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 2d5fcf5..b0ba82e 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -1322,6 +1322,7 @@ sem_item_optimizer::~sem_item_optimizer ()
        delete (*it)->classes[i];
 
       (*it)->classes.release ();
+      free (*it);
     }
 
   m_items.release ();
-- 
1.8.5.3

Reply via email to