From: David Malcolm Date: Mon, 6 Nov 2017 16:31:04 +0000 (+0000) Subject: ipa-fnsummary.c: fix use-after-free crash (PR jit/82826) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de4381a4e91a5d827dd3b1cf6b290bc656848400;p=gcc.git ipa-fnsummary.c: fix use-after-free crash (PR jit/82826) gcc/ChangeLog: PR jit/82826 * ipa-fnsummary.c (ipa_fnsummary_c_finalize): New function. * ipa-fnsummary.h (ipa_fnsummary_c_finalize): New decl. * toplev.c: Include "ipa-fnsummary.h". (toplev::finalize): Call ipa_fnsummary_c_finalize. From-SVN: r254458 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7c04aa9b313..9c3961a9f19 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-11-06 David Malcolm + + PR jit/82826 + * ipa-fnsummary.c (ipa_fnsummary_c_finalize): New function. + * ipa-fnsummary.h (ipa_fnsummary_c_finalize): New decl. + * toplev.c: Include "ipa-fnsummary.h". + (toplev::finalize): Call ipa_fnsummary_c_finalize. + 2017-11-06 Jakub Jelinek PR tree-optimization/82838 diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index f6841104a32..5168886fe14 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -3619,3 +3619,12 @@ make_pass_ipa_fn_summary (gcc::context *ctxt) { return new pass_ipa_fn_summary (ctxt); } + +/* Reset all state within ipa-fnsummary.c so that we can rerun the compiler + within the same process. For use by toplev::finalize. */ + +void +ipa_fnsummary_c_finalize (void) +{ + ipa_free_fn_summary (); +} diff --git a/gcc/ipa-fnsummary.h b/gcc/ipa-fnsummary.h index a794bd09318..b345bbc4fd7 100644 --- a/gcc/ipa-fnsummary.h +++ b/gcc/ipa-fnsummary.h @@ -266,4 +266,6 @@ void estimate_node_size_and_time (struct cgraph_node *node, vec inline_param_summary); +void ipa_fnsummary_c_finalize (void); + #endif /* GCC_IPA_FNSUMMARY_H */ diff --git a/gcc/toplev.c b/gcc/toplev.c index 81a7cf6b7dc..eff169008d1 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -83,6 +83,7 @@ along with GCC; see the file COPYING3. If not see #include "edit-context.h" #include "tree-pass.h" #include "dumpfile.h" +#include "ipa-fnsummary.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) #include "dbxout.h" @@ -2236,6 +2237,7 @@ toplev::finalize (void) /* Needs to be called before cgraph_c_finalize since it uses symtab. */ ipa_reference_c_finalize (); + ipa_fnsummary_c_finalize (); cgraph_c_finalize (); cgraphunit_c_finalize ();