aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-08-19 11:19:52 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-08-19 11:19:52 +0000
commit3ef276e4423713be6ff9a0eca4cbbd2bc3180910 (patch)
tree0d74c883a32a076e2c085404edf7925248d58fb1 /gcc
parenta98c0e91c7ec2cbb72ec7fc2fa12443c0b33be3a (diff)
downloadgcc-3ef276e4423713be6ff9a0eca4cbbd2bc3180910.zip
gcc-3ef276e4423713be6ff9a0eca4cbbd2bc3180910.tar.gz
gcc-3ef276e4423713be6ff9a0eca4cbbd2bc3180910.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/gimple-fold.c24
2 files changed, 17 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ccb3e51..84fc047 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+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>
* dwarf2out.c (decl_quals): New function.
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 9afaedf..3c03c01 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -319,14 +319,6 @@ fold_gimple_assign (gimple_stmt_iterator *si)
= possible_polymorphic_call_targets (rhs, stmt, &final);
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 ())
{
location_t loc = gimple_location_safe (stmt);
@@ -335,11 +327,19 @@ fold_gimple_assign (gimple_stmt_iterator *si)
"reference to function %s\n",
targets.length () == 1
? targets[0]->name ()
- : "__builtin_unreachable");
+ : "NULL");
}
- val = fold_convert (TREE_TYPE (val),
- build_fold_addr_expr_loc (loc, fndecl));
- STRIP_USELESS_TYPE_CONVERSION (val);
+ if (targets.length () == 1)
+ {
+ 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;
}
}