* 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
+2014-06-27 Martin Liska <mliska@suse.cz>
+
+ * 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 <jakub@redhat.com>
PR tree-optimization/57233
}
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 ());
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",
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
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 *
{
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,
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);
}
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);
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,
{
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",