This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, tree-optimization]: Fix PR tree-optimization/32821, segfault with -ftree-dump-tree-ifcvt-details


On 9/7/07, Richard Guenther <richard.guenther@gmail.com> wrote:

> The problem is because tree-if-conv.c does
>
>      /* Update stmt list.  */
>       last = tsi_last (bb_stmt_list (merge_target_bb));
>       tsi_link_after (&last, bb_stmt_list (bb), TSI_NEW_STMT);
>       set_bb_stmt_list (bb, NULL);
>
> but NULL statement lists are not allowed.  Instead the set_bb_stmt_list call
> should read
>
> set_bb_stmt_list (bb, alloc_stmt_list());
>
> matching what create_bb does.

Thanks, attached patch implements what have you suggested.

>
> This change is pre-approved.
>

Patch was tested by running gcc testsuite on i686-pc-linux-gnu for
non-bootstrapped compiler (it doesn't bootstrap right now, but
-ftree-vectorize is not used during bootstrap anyway). Patch is
commited to SVN mainline.

2007-09-07  Richard Guenther  <rguenther@suse.de>
	    Uros Bizjak  <ubizjak@gmail.com>

	PR tree-optimization/32821
	* tree_if_conv.c (combine_blocks): Use alloc_stmt_list instead of
	NULL in the call to set_bb_stmt_list.

2007-09-07 Uros Bizjak <ubizjak@gmail.com>

	PR tree-optimization/32821
	* gcc.dg/tree-ssa/pr32821.c: New file.

Uros.

Index: testsuite/gcc.dg/tree-ssa/pr32821.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/pr32821.c (revision 0)
+++ testsuite/gcc.dg/tree-ssa/pr32821.c (revision 0)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize -fdump-tree-ifcvt-details" } */
+
+void
+main1 (int *arr, int n, int a, int b)
+{
+  int i;
+  for (i = 0; i < n; i++)
+    {
+      int m = arr[i];
+      arr[i] = (m < a ? m - a : b);
+    }
+}
+
+/* { dg-final { cleanup-tree-dump "ifcvt" } } */
Index: tree-if-conv.c
===================================================================
--- tree-if-conv.c      (revision 128234)
+++ tree-if-conv.c      (working copy)
@@ -985,7 +985,7 @@
       /* Update stmt list.  */
       last = tsi_last (bb_stmt_list (merge_target_bb));
       tsi_link_after (&last, bb_stmt_list (bb), TSI_NEW_STMT);
-      set_bb_stmt_list (bb, NULL);
+      set_bb_stmt_list (bb, alloc_stmt_list());

       delete_basic_block (bb);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]