From: Jan Hubicka Date: Wed, 4 Feb 2015 20:28:49 +0000 (+0100) Subject: re PR middle-end/64922 (runtime error: member call on misaligned address for type... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0b986c6ac777aa4ecbfa29549148ef8ab95595e1;p=gcc.git re PR middle-end/64922 (runtime error: member call on misaligned address for type 'struct _Rep') PR middle-end/64922 * gimple.c: Include gimple-ssa.h. (maybe_remove_unused_call_args): New function. * gimple.h (maybe_remove_unused_call_args): Declare. * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Use it. * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Likewise. * gimple-fold.c (gimple_fold_call): Likewise. From-SVN: r220417 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f724d54539b..755ff3e5377 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-02-04 Jan Hubicka + + PR middle-end/64922 + * gimple.c: Include gimple-ssa.h. + (maybe_remove_unused_call_args): New function. + * gimple.h (maybe_remove_unused_call_args): Declare. + * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Use it. + * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Likewise. + * gimple-fold.c (gimple_fold_call): Likewise. + 2015-02-04 H.J. Lu PR rtl-optimization/64905 diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 89d0d2feb9f..8ea8ae93714 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1324,7 +1324,8 @@ cgraph_edge::redirect_call_stmt_to_callee (void) (int64_t)e->count); gcc_assert (e2->speculative); push_cfun (DECL_STRUCT_FUNCTION (e->caller->decl)); - new_stmt = gimple_ic (e->call_stmt, dyn_cast (ref->referred), + new_stmt = gimple_ic (e->call_stmt, + dyn_cast (ref->referred), e->count || e2->count ? RDIV (e->count * REG_BR_PROB_BASE, e->count + e2->count) @@ -1464,6 +1465,9 @@ cgraph_edge::redirect_call_stmt_to_callee (void) update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); } + maybe_remove_unused_call_args (DECL_STRUCT_FUNCTION (e->caller->decl), + new_stmt); + e->caller->set_call_stmt_including_clones (e->call_stmt, new_stmt, false); if (symtab->dump_file) diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 3015901d8c1..f89220c5a68 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -3120,6 +3120,7 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace) } gimple_call_set_lhs (stmt, NULL_TREE); } + maybe_remove_unused_call_args (cfun, stmt); } else { diff --git a/gcc/gimple.c b/gcc/gimple.c index caa1cbd2d09..a5c1192f776 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -67,6 +67,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-ref.h" #include "lto-streamer.h" #include "cgraph.h" +#include "gimple-ssa.h" /* All the tuples have their operand vector (if present) at the very bottom @@ -2950,3 +2951,20 @@ gimple_seq_discard (gimple_seq seq) ggc_free (stmt); } } + +/* See if STMT now calls function that takes no parameters and if so, drop + call arguments. This is used when devirtualization machinery redirects + to __builtiln_unreacahble or __cxa_pure_virutal. */ + +void +maybe_remove_unused_call_args (struct function *fn, gimple stmt) +{ + tree decl = gimple_call_fndecl (stmt); + if (TYPE_ARG_TYPES (TREE_TYPE (decl)) + && TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))) == void_type_node + && gimple_call_num_args (stmt)) + { + gimple_set_num_ops (stmt, 3); + update_stmt_fn (fn, stmt); + } +} diff --git a/gcc/gimple.h b/gcc/gimple.h index 769bad01181..5503625c9f1 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1404,6 +1404,7 @@ extern void sort_case_labels (vec); extern void preprocess_case_label_vec_for_gimple (vec, tree, tree *); extern void gimple_seq_set_location (gimple_seq, location_t); extern void gimple_seq_discard (gimple_seq); +extern void maybe_remove_unused_call_args (struct function *, gimple); /* Formal (expression) temporary table handling: multiple occurrences of the same scalar expression are evaluated into the same temporary. */ diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 32cd74dd3bb..83b48df8b4e 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -4406,6 +4406,7 @@ eliminate_dom_walker::before_dom_children (basic_block b) cgraph_node::get (fn)->name ()); } gimple_call_set_fndecl (call_stmt, fn); + maybe_remove_unused_call_args (cfun, call_stmt); gimple_set_modified (stmt, true); } }