Commit 3ef276e4 by Richard Biener Committed by Richard Biener

gimple-fold.c (fold_gimple_assign): Properly build a null-pointer constant when…

gimple-fold.c (fold_gimple_assign): Properly build a null-pointer constant when devirtualizing addresses.

2014-08-19  Richard Biener  <rguenther@suse.de>

	* gimple-fold.c (fold_gimple_assign): Properly build a
	null-pointer constant when devirtualizing addresses.

From-SVN: r214141
parent a98c0e91
2014-08-19 Richard Biener <rguenther@suse.de>
* gimple-fold.c (fold_gimple_assign): Properly build a
null-pointer constant when devirtualizing addresses.
2014-07-07 Mark Wielaard <mjw@redhat.com> 2014-07-07 Mark Wielaard <mjw@redhat.com>
* dwarf2out.c (decl_quals): New function. * dwarf2out.c (decl_quals): New function.
......
...@@ -319,14 +319,6 @@ fold_gimple_assign (gimple_stmt_iterator *si) ...@@ -319,14 +319,6 @@ fold_gimple_assign (gimple_stmt_iterator *si)
= possible_polymorphic_call_targets (rhs, stmt, &final); = possible_polymorphic_call_targets (rhs, stmt, &final);
if (final && targets.length () <= 1 && dbg_cnt (devirt)) if (final && targets.length () <= 1 && dbg_cnt (devirt))
{ {
tree fndecl;
if (targets.length () == 1)
fndecl = targets[0]->decl;
else
/* We can not use __builtin_unreachable here because it
can not have address taken. */
fndecl = integer_zero_node;
if (dump_enabled_p ()) if (dump_enabled_p ())
{ {
location_t loc = gimple_location_safe (stmt); location_t loc = gimple_location_safe (stmt);
...@@ -335,11 +327,19 @@ fold_gimple_assign (gimple_stmt_iterator *si) ...@@ -335,11 +327,19 @@ fold_gimple_assign (gimple_stmt_iterator *si)
"reference to function %s\n", "reference to function %s\n",
targets.length () == 1 targets.length () == 1
? targets[0]->name () ? targets[0]->name ()
: "__builtin_unreachable"); : "NULL");
} }
val = fold_convert (TREE_TYPE (val), if (targets.length () == 1)
build_fold_addr_expr_loc (loc, fndecl)); {
STRIP_USELESS_TYPE_CONVERSION (val); val = fold_convert (TREE_TYPE (val),
build_fold_addr_expr_loc
(loc, targets[0]->decl));
STRIP_USELESS_TYPE_CONVERSION (val);
}
else
/* We can not use __builtin_unreachable here because it
can not have address taken. */
val = build_int_cst (TREE_TYPE (val), 0);
return val; return val;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment