Committed to branch dmalcolm/jit: Certain client code that repeatedly performed in-process compilations with optimizations and inlinable functions led to a segfault within ipa-cp.c:propagate_effects, whilst traversing the values_topo list.
The root cause was that values_topo was not reset to NULL, and hence could contain entities allocated by a previous compile within a then-defunct alloc_pool. Introduce ipa_cp_c_finalize to clean out state within ipa-cp.c and call it from toplev::finalize. In particular, reset values_topo back to NULL. gcc/ * cgraph.h (ipa_cp_c_finalize): Add prototype. * ipa-cp.c (ipa_cp_c_finalize): New. * toplev.c (toplev::finalize): Add call to ipa_cp_c_finalize. --- gcc/ChangeLog.jit | 6 ++++++ gcc/cgraph.h | 2 ++ gcc/ipa-cp.c | 9 +++++++++ gcc/toplev.c | 1 + 4 files changed, 18 insertions(+) diff --git a/gcc/ChangeLog.jit b/gcc/ChangeLog.jit index f8235f1..3a6ea52 100644 --- a/gcc/ChangeLog.jit +++ b/gcc/ChangeLog.jit @@ -1,3 +1,9 @@ +2014-07-14 David Malcolm <dmalc...@redhat.com> + + * cgraph.h (ipa_cp_c_finalize): Add prototype. + * ipa-cp.c (ipa_cp_c_finalize): New. + * toplev.c (toplev::finalize): Add call to ipa_cp_c_finalize. + 2014-05-08 David Malcolm <dmalc...@redhat.com> * params.c (global_init_params): Require that params_finished be diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 2e2eb97..2d7e574 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -866,6 +866,8 @@ void symtab_initialize_asm_name_hash (void); void symtab_prevail_in_asm_name_hash (symtab_node node); void varpool_remove_initializer (struct varpool_node *); +/* In ipa-cp.c */ +void ipa_cp_c_finalize (void); /* Return callgraph node for given symbol and check it is a function. */ static inline struct cgraph_node * diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 57ec2db..39650f0 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -3689,3 +3689,12 @@ make_pass_ipa_cp (gcc::context *ctxt) { return new pass_ipa_cp (ctxt); } + +void +ipa_cp_c_finalize (void) +{ + max_count = 0; + overall_size = 0; + max_new_size = 0; + values_topo = NULL; +} diff --git a/gcc/toplev.c b/gcc/toplev.c index 5123dbe..8fa92c5 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2014,6 +2014,7 @@ toplev::finalize (void) dwarf2out_c_finalize (); gcse_c_finalize (); ipa_c_finalize (); + ipa_cp_c_finalize (); ipa_reference_c_finalize (); params_c_finalize (); predict_c_finalize (); -- 1.8.5.3