Patchwork Handle !gimple_in_ssa_p (cfun) in update_call_from_tree (PR middle-end/46360)

login
register
mail settings
Submitter Jakub Jelinek
Date Nov. 8, 2010, 10:14 p.m.
Message ID <20101108221455.GU29412@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/70469/
State New
Headers show

Comments

Jakub Jelinek - Nov. 8, 2010, 10:14 p.m.
Hi!

Honza added fold_stmt call into the gimplifier recently, unfortunately
update_call_from_tree which may be called by fold_stmt wasn't prepared
for non-SSA form.  Similar functions have been updated similarly in the
past.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2010-11-08  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/46360
	* tree-ssa-propagate.c (update_call_from_tree): Fix for use
	not in SSA mode.

	* gcc.c-torture/compile/pr46360.c: New test.


	Jakub
Richard Guenther - Nov. 9, 2010, 10:25 a.m.
On Mon, Nov 8, 2010 at 11:14 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Honza added fold_stmt call into the gimplifier recently, unfortunately
> update_call_from_tree which may be called by fold_stmt wasn't prepared
> for non-SSA form.  Similar functions have been updated similarly in the
> past.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok.

Thanks,
Richard.

> 2010-11-08  Jakub Jelinek  <jakub@redhat.com>
>
>        PR middle-end/46360
>        * tree-ssa-propagate.c (update_call_from_tree): Fix for use
>        not in SSA mode.
>
>        * gcc.c-torture/compile/pr46360.c: New test.
>
> --- gcc/tree-ssa-propagate.c.jj 2010-09-22 17:15:41.000000000 +0200
> +++ gcc/tree-ssa-propagate.c    2010-11-08 20:47:37.000000000 +0100
> @@ -760,8 +760,11 @@ update_call_from_tree (gimple_stmt_itera
>           /* No value is expected, and EXPR has no effect.
>              Replace it with an empty statement.  */
>           new_stmt = gimple_build_nop ();
> -         unlink_stmt_vdef (stmt);
> -         release_defs (stmt);
> +         if (gimple_in_ssa_p (cfun))
> +           {
> +             unlink_stmt_vdef (stmt);
> +             release_defs (stmt);
> +           }
>         }
>       else
>         {
> @@ -773,7 +776,8 @@ update_call_from_tree (gimple_stmt_itera
>           lhs = create_tmp_var (TREE_TYPE (expr), NULL);
>           new_stmt = gimple_build_assign (lhs, expr);
>           add_referenced_var (lhs);
> -          lhs = make_ssa_name (lhs, new_stmt);
> +         if (gimple_in_ssa_p (cfun))
> +           lhs = make_ssa_name (lhs, new_stmt);
>           gimple_assign_set_lhs (new_stmt, lhs);
>          gimple_set_vuse (new_stmt, gimple_vuse (stmt));
>          gimple_set_vdef (new_stmt, gimple_vdef (stmt));
> --- gcc/testsuite/gcc.c-torture/compile/pr46360.c.jj    2010-11-08 20:50:34.000000000 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr46360.c       2010-11-08 20:50:04.000000000 +0100
> @@ -0,0 +1,13 @@
> +/* PR middle-end/46360 */
> +
> +__attribute__((gnu_inline, always_inline)) extern inline char *
> +strncpy (char *dest, const char *src, __SIZE_TYPE__ len)
> +{
> +  return __builtin_strncpy (dest, src, len);
> +}
> +
> +void
> +foo (char *s)
> +{
> +  strncpy (s, "", 0);
> +}
>
>        Jakub
>

Patch

--- gcc/tree-ssa-propagate.c.jj	2010-09-22 17:15:41.000000000 +0200
+++ gcc/tree-ssa-propagate.c	2010-11-08 20:47:37.000000000 +0100
@@ -760,8 +760,11 @@  update_call_from_tree (gimple_stmt_itera
           /* No value is expected, and EXPR has no effect.
              Replace it with an empty statement.  */
           new_stmt = gimple_build_nop ();
-	  unlink_stmt_vdef (stmt);
-	  release_defs (stmt);
+	  if (gimple_in_ssa_p (cfun))
+	    {
+	      unlink_stmt_vdef (stmt);
+	      release_defs (stmt);
+	    }
         }
       else
         {
@@ -773,7 +776,8 @@  update_call_from_tree (gimple_stmt_itera
           lhs = create_tmp_var (TREE_TYPE (expr), NULL);
           new_stmt = gimple_build_assign (lhs, expr);
           add_referenced_var (lhs);
-          lhs = make_ssa_name (lhs, new_stmt);
+	  if (gimple_in_ssa_p (cfun))
+	    lhs = make_ssa_name (lhs, new_stmt);
           gimple_assign_set_lhs (new_stmt, lhs);
 	  gimple_set_vuse (new_stmt, gimple_vuse (stmt));
 	  gimple_set_vdef (new_stmt, gimple_vdef (stmt));
--- gcc/testsuite/gcc.c-torture/compile/pr46360.c.jj	2010-11-08 20:50:34.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr46360.c	2010-11-08 20:50:04.000000000 +0100
@@ -0,0 +1,13 @@ 
+/* PR middle-end/46360 */
+
+__attribute__((gnu_inline, always_inline)) extern inline char *
+strncpy (char *dest, const char *src, __SIZE_TYPE__ len)
+{
+  return __builtin_strncpy (dest, src, len);
+}
+
+void
+foo (char *s)
+{
+  strncpy (s, "", 0);
+}