From 807b7d6209c7bd54b4dfc9abdc17f451e71aa648 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 27 Jun 2014 11:24:45 +0200 Subject: [PATCH] Fix for devirtualization dump functions * gimple.h (gimple_location_safe): New function introduced. * cgraphunit.c (walk_polymorphic_call_targets): Usage of gimple_location_safe replaces gimple_location. (gimple_fold_call): Likewise. * ipa-devirt.c (ipa_devirt): Likewise. * ipa-prop.c (ipa_make_edge_direct_to_target): Likewise. * ipa.c (walk_polymorphic_call_targets): Likewise. * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Likewise. From-SVN: r212067 --- gcc/ChangeLog | 11 +++++++++++ gcc/cgraphunit.c | 2 +- gcc/gimple-fold.c | 4 ++-- gcc/gimple.h | 9 +++++++++ gcc/ipa-devirt.c | 2 +- gcc/ipa-prop.c | 31 +++++++++---------------------- gcc/ipa.c | 2 +- gcc/tree-ssa-pre.c | 2 +- 8 files changed, 35 insertions(+), 28 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 42e6908fb63c..9d96c2baf240 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2014-06-27 Martin Liska + + * gimple.h (gimple_location_safe): New function introduced. + * cgraphunit.c (walk_polymorphic_call_targets): Usage + of gimple_location_safe replaces gimple_location. + (gimple_fold_call): Likewise. + * ipa-devirt.c (ipa_devirt): Likewise. + * ipa-prop.c (ipa_make_edge_direct_to_target): Likewise. + * ipa.c (walk_polymorphic_call_targets): Likewise. + * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children): Likewise. + 2014-06-27 Jakub Jelinek PR tree-optimization/57233 diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 76b2fda1d1e4..d7e8038ec64e 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -906,7 +906,7 @@ walk_polymorphic_call_targets (pointer_set_t *reachable_call_targets, } if (dump_enabled_p ()) { - location_t locus = gimple_location (edge->call_stmt); + location_t locus = gimple_location_safe (edge->call_stmt); dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, locus, "devirtualizing call in %s to %s\n", edge->caller->name (), target->name ()); diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 403dee707a32..3dcb57602c6e 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -387,7 +387,7 @@ fold_gimple_assign (gimple_stmt_iterator *si) fndecl = builtin_decl_implicit (BUILT_IN_UNREACHABLE); if (dump_enabled_p ()) { - location_t loc = gimple_location (stmt); + location_t loc = gimple_location_safe (stmt); dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, "resolving virtual function address " "reference to function %s\n", @@ -1131,7 +1131,7 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace) tree lhs = gimple_call_lhs (stmt); if (dump_enabled_p ()) { - location_t loc = gimple_location (stmt); + location_t loc = gimple_location_safe (stmt); dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, "folding virtual function call to %s\n", targets.length () == 1 diff --git a/gcc/gimple.h b/gcc/gimple.h index ceefbc0890f0..3dfafc6d7c17 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1501,6 +1501,15 @@ gimple_location (const_gimple g) return g->location; } +/* Return location information for statement G if g is not NULL. + Otherwise, UNKNOWN_LOCATION is returned. */ + +static inline location_t +gimple_location_safe (const_gimple g) +{ + return g ? gimple_location (g) : UNKNOWN_LOCATION; +} + /* Return pointer to location information for statement G. */ static inline const location_t * diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 21f4f11218f8..d6b85bf3415b 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -2080,7 +2080,7 @@ ipa_devirt (void) { if (dump_enabled_p ()) { - location_t locus = gimple_location (e->call_stmt); + location_t locus = gimple_location_safe (e->call_stmt); dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, locus, "speculatively devirtualizing call in %s/%i to %s/%i\n", n->name (), n->order, diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 1e10b53b00fb..68efc77851c9 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -2673,17 +2673,11 @@ ipa_make_edge_direct_to_target (struct cgraph_edge *ie, tree target) if (dump_enabled_p ()) { - const char *fmt = "discovered direct call to non-function in %s/%i, " - "making it __builtin_unreachable\n"; - - if (ie->call_stmt) - { - location_t loc = gimple_location (ie->call_stmt); - dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, fmt, - ie->caller->name (), ie->caller->order); - } - else if (dump_file) - fprintf (dump_file, fmt, ie->caller->name (), ie->caller->order); + location_t loc = gimple_location_safe (ie->call_stmt); + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, + "discovered direct call to non-function in %s/%i, " + "making it __builtin_unreachable\n", + ie->caller->name (), ie->caller->order); } target = builtin_decl_implicit (BUILT_IN_UNREACHABLE); @@ -2745,18 +2739,11 @@ ipa_make_edge_direct_to_target (struct cgraph_edge *ie, tree target) } if (dump_enabled_p ()) { - const char *fmt = "converting indirect call in %s to direct call to %s\n"; - - if (ie->call_stmt) - { - location_t loc = gimple_location (ie->call_stmt); + location_t loc = gimple_location_safe (ie->call_stmt); - dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, fmt, - ie->caller->name (), callee->name ()); - - } - else if (dump_file) - fprintf (dump_file, fmt, ie->caller->name (), callee->name ()); + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, + "converting indirect call in %s to direct call to %s\n", + ie->caller->name (), callee->name ()); } ie = cgraph_make_edge_direct (ie, callee); es = inline_edge_summary (ie); diff --git a/gcc/ipa.c b/gcc/ipa.c index fce2e36174f7..76815648d898 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -198,7 +198,7 @@ walk_polymorphic_call_targets (pointer_set_t *reachable_call_targets, if (dump_enabled_p ()) { - location_t locus = gimple_location (edge->call_stmt); + location_t locus = gimple_location_safe (edge->call_stmt); dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, locus, "devirtualizing call in %s/%i to %s/%i\n", edge->caller->name (), edge->caller->order, diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 74238decfef3..d05a40be1ee4 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -4367,7 +4367,7 @@ eliminate_dom_walker::before_dom_children (basic_block b) { if (dump_enabled_p ()) { - location_t loc = gimple_location (stmt); + location_t loc = gimple_location_safe (stmt); dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, "converting indirect call to " "function %s\n", -- 2.47.2