From 2190d7c393d27b6b2603352fda7871b59d3c2c91 Mon Sep 17 00:00:00 2001 From: "nicolas.marie" <nicolas.marie@ensiie.eu> Date: Sun, 5 Nov 2023 22:16:15 +0100 Subject: [PATCH] fixe memory leak by deleting vec --- include/mpi_collective.hpp | 1 + src/mpi_collective_pragma.cpp | 3 +++ src/mpi_collective_warnings.cpp | 22 +++++++++++----------- src/plugin.cpp | 5 +++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/include/mpi_collective.hpp b/include/mpi_collective.hpp index c6f9e1f..8df09a7 100644 --- a/include/mpi_collective.hpp +++ b/include/mpi_collective.hpp @@ -156,6 +156,7 @@ void register_mpicoll_check_pragma(void *event_data, void *data); void mpicoll_check_pragma(cpp_reader *); //raising warning for unprocessed fun in pragma and freeing memory void verify_mpicoll_list(void *event_data, void *data); + extern vec<tree> *fun_vec; //function vector in pragma. extern vec<location_t> *loc_vec; //function of the location of the token diff --git a/src/mpi_collective_pragma.cpp b/src/mpi_collective_pragma.cpp index 0b22096..5452e59 100644 --- a/src/mpi_collective_pragma.cpp +++ b/src/mpi_collective_pragma.cpp @@ -156,4 +156,7 @@ void verify_mpicoll_list(void *event_data, void *data) } fun_vec->release(); loc_vec->release(); + + delete fun_vec; + delete loc_vec; } diff --git a/src/mpi_collective_warnings.cpp b/src/mpi_collective_warnings.cpp index 9fc800c..9a05084 100644 --- a/src/mpi_collective_warnings.cpp +++ b/src/mpi_collective_warnings.cpp @@ -356,12 +356,12 @@ void pass_mpi_collective::raise_warning_mpi_order(function *fun) get_bb_from_index( fun, diff_index))); - warning_at (loc - , 0 - , "MPI Collective %<%s%>(%i) might not be " - "reachable due to a precedent %<%s%> call:" - , mpi_collective_name[mpi_code] - , rank, mpi_collective_name[cursor_code]); + warning_at(loc + , 0 + , "MPI Collective %<%s%>(%i) might not be " + "reachable due to a precedent %<%s%> call:" + , mpi_collective_name[mpi_code] + , rank, mpi_collective_name[cursor_code]); EXECUTE_IF_SET_IN_BITMAP(nodes, 0, index, bi) { @@ -370,11 +370,11 @@ void pass_mpi_collective::raise_warning_mpi_order(function *fun) loc = gimple_location( get_mpi_stmt( get_bb_from_index(fun, index))); - inform (loc - , "reachable %<%s%>(%i) without " - "a prior %<%s%> call:" - , mpi_collective_name[mpi_code] - , rank, mpi_collective_name[cursor_code]); + inform(loc + , "reachable %<%s%>(%i) without " + "a prior %<%s%> call:" + , mpi_collective_name[mpi_code] + , rank, mpi_collective_name[cursor_code]); } } } diff --git a/src/plugin.cpp b/src/plugin.cpp index dcf42b3..0a7cf05 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -50,12 +50,13 @@ plugin_init(struct plugin_name_args *plugin_info, } pass_mpi_collective p(g); - //irresponsible code + fun_vec = new vec<tree>; loc_vec = new vec<location_t>; + fun_vec->create(0); loc_vec->create(0); - //fun_vec.release(); //FIXME release memory in last callback + // RELEASE in verify_mpi_colllist at PLUGIN FINISH UNIT struct register_pass_info pass_info; -- GitLab