https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65538
Bug ID: 65538 Summary: [5 Regression] Memory leak of ipa_node_params_sum elements Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org CC: hubicka at gcc dot gnu.org, marxin at gcc dot gnu.org Seen recently in valgrind output (e.g. on the pr65533.c testcase): ==19246== 216 (48 direct, 168 indirect) bytes in 1 blocks are definitely lost in loss record 501 of 594 ==19246== at 0x4A070D7: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==19246== by 0xAEBAAE: function_summary<ipa_node_params*>::allocate_new() (symbol-summary.h:106) ==19246== by 0xAEAF20: function_summary<ipa_node_params*>::get(int) (symbol-summary.h:232) ==19246== by 0xAE9B97: function_summary<ipa_node_params*>::get(cgraph_node*) (symbol-summary.h:112) ==19246== by 0xAF9C38: ipa_analyze_node(cgraph_node*) (ipa-prop.c:2386) ==19246== by 0x15B5578: ipcp_generate_summary() (ipa-cp.c:4449) ==19246== by 0xC255AF: execute_ipa_summary_passes(ipa_opt_pass_d*) (passes.c:2154) ==19246== by 0x841202: ipa_passes() (cgraphunit.c:2179) ==19246== by 0x8415E5: symbol_table::compile() (cgraphunit.c:2295) ==19246== by 0x841907: symbol_table::finalize_compilation_unit() (cgraphunit.c:2444) ==19246== by 0x69CEB8: c_write_global_declarations() (c-decl.c:10801) ==19246== by 0xD1EBAC: compile_file() (toplev.c:608) ==19246== ==19246== 384 (192 direct, 192 indirect) bytes in 4 blocks are definitely lost in loss record 519 of 594 ==19246== at 0x4A070D7: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==19246== by 0xAEBAAE: function_summary<ipa_node_params*>::allocate_new() (symbol-summary.h:106) ==19246== by 0xAEAF20: function_summary<ipa_node_params*>::get(int) (symbol-summary.h:232) ==19246== by 0xAE9B97: function_summary<ipa_node_params*>::get(cgraph_node*) (symbol-summary.h:112) ==19246== by 0xAF42FC: ipa_initialize_node_params(cgraph_node*) (ipa-prop.c:293) ==19246== by 0xAE323D: estimate_function_body_sizes(cgraph_node*, bool) (ipa-inline-analysis.c:2518) ==19246== by 0xAE4F54: compute_inline_parameters(cgraph_node*, bool) (ipa-inline-analysis.c:2951) ==19246== by 0xAE5051: compute_inline_parameters_for_current() (ipa-inline-analysis.c:2978) ==19246== by 0xAE50D8: (anonymous namespace)::pass_inline_parameters::execute(function*) (ipa-inline-analysis.c:3008) ==19246== by 0xC25B24: execute_one_pass(opt_pass*) (passes.c:2328) ==19246== by 0xC25D5E: execute_pass_list_1(opt_pass*) (passes.c:2380) ==19246== by 0xC25DCC: execute_pass_list(function*, opt_pass*) (passes.c:2391) inline summaries are ggc allocated and so not a problem, but the ipa-prop summaries are not, and thus something should arrange that the ipa_node_params class objects allocated by allocate_new are destructed when m_map is destructed. So, perhaps summary_hashmap_traits needs to implement the remove template method? Though, it is unclear how it could find out if the hash_map is ggc or not. Perhaps the decision ggc vs. non-ggc should be done as function_summary template parameter or similar.