From 1bce4ff313bf2e2c9e942df52b494bf22886f163 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 17 Mar 2011 14:59:00 +0000 Subject: [PATCH] re PR tree-optimization/48134 (ICE: in refs_may_alias_p_1, at tree-ssa-alias.c:1085 with custom flags) 2011-03-17 Richard Guenther PR middle-end/48134 * tree-ssa.c (insert_debug_temp_for_var_def): If we propagated a value make sure to fold the statement. * gcc.dg/pr48134.c: New testcase. From-SVN: r171098 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr48134.c | 31 +++++++++++++++++++++++++++++++ gcc/tree-ssa.c | 20 +++++++++++++------- 4 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr48134.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bc80f7ab8fb..298815dc353 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-03-17 Richard Guenther + + PR middle-end/48134 + * tree-ssa.c (insert_debug_temp_for_var_def): If we propagated + a value make sure to fold the statement. + 2011-03-17 Chung-Lin Tang PR target/43872 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a7d874981d3..20ba8d6a6a1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-17 Richard Guenther + + PR middle-end/48134 + * gcc.dg/pr48134.c: New testcase. + 2011-03-17 Richard Guenther PR middle-end/48165 diff --git a/gcc/testsuite/gcc.dg/pr48134.c b/gcc/testsuite/gcc.dg/pr48134.c new file mode 100644 index 00000000000..8dc5a6d0d41 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr48134.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-check=specific -fno-tree-dse -fno-tree-fre -fno-tree-loop-optimize -g" } */ + +struct S +{ + int w, z; +}; +struct T +{ + struct S s; +}; + +int i; + +static inline struct S +bar (struct S x) +{ + i++; + return x; +} + +int +foo (struct T t, struct S s) +{ + struct S *c = &s; + if (i) + c = &t.s; + t.s.w = 3; + s = bar (*c); + return t.s.w; +} diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index e7e3edcf6f1..d542e0a253a 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -455,13 +455,19 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var) continue; if (value) - FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) - /* unshare_expr is not needed here. vexpr is either a - SINGLE_RHS, that can be safely shared, some other RHS - that was unshared when we found it had a single debug - use, or a DEBUG_EXPR_DECL, that can be safely - shared. */ - SET_USE (use_p, value); + { + FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) + /* unshare_expr is not needed here. vexpr is either a + SINGLE_RHS, that can be safely shared, some other RHS + that was unshared when we found it had a single debug + use, or a DEBUG_EXPR_DECL, that can be safely + shared. */ + SET_USE (use_p, value); + /* If we didn't replace uses with a debug decl fold the + resulting expression. Otherwise we end up with invalid IL. */ + if (TREE_CODE (value) != DEBUG_EXPR_DECL) + fold_stmt_inplace (stmt); + } else gimple_debug_bind_reset_value (stmt); -- 2.30.2