aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-06-06 19:12:25 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2011-06-06 19:12:25 +0200
commita9d245448f2529fe9a4aba63d9cd97059a17a121 (patch)
tree49149b6774ee1bc9cd12c2261a21557049cfe8b3 /gcc/gimple-fold.c
parent9a2fc6ada427baaff5b41dcad27861fe28255c82 (diff)
downloadgcc-a9d245448f2529fe9a4aba63d9cd97059a17a121.zip
gcc-a9d245448f2529fe9a4aba63d9cd97059a17a121.tar.gz
gcc-a9d245448f2529fe9a4aba63d9cd97059a17a121.tar.bz2
re PR c++/49264 (Internal compiler error: segmentation fault)
PR c++/49264 * gimple-fold.c (fold_stmt_1): Don't try to fold *& on the lhs if stmt folded into nothing. * tree-inline.c (fold_marked_statements): If a builtin at the end of a bb folded into nothing, just update cgraph edges and move to next bb. * cgraph.c (cgraph_update_edges_for_call_stmt_node): Allow new_stmt to be NULL. Don't compute count and frequency if new_call is NULL. * g++.dg/opt/pr49264.C: New test. From-SVN: r174711
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index c98fd6a..eaff1b3 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1577,6 +1577,11 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace)
bool changed = false;
gimple stmt = gsi_stmt (*gsi);
unsigned i;
+ gimple_stmt_iterator gsinext = *gsi;
+ gimple next_stmt;
+
+ gsi_next (&gsinext);
+ next_stmt = gsi_end_p (gsinext) ? NULL : gsi_stmt (gsinext);
/* Fold the main computation performed by the statement. */
switch (gimple_code (stmt))
@@ -1665,10 +1670,19 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace)
default:;
}
+ /* If stmt folds into nothing and it was the last stmt in a bb,
+ don't call gsi_stmt. */
+ if (gsi_end_p (*gsi))
+ {
+ gcc_assert (next_stmt == NULL);
+ return changed;
+ }
+
stmt = gsi_stmt (*gsi);
- /* Fold *& on the lhs. */
- if (gimple_has_lhs (stmt))
+ /* Fold *& on the lhs. Don't do this if stmt folded into nothing,
+ as we'd changing the next stmt. */
+ if (gimple_has_lhs (stmt) && stmt != next_stmt)
{
tree lhs = gimple_get_lhs (stmt);
if (lhs && REFERENCE_CLASS_P (lhs))