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

Daniel Berlin dberlin@dberlin.org
Thu Sep 6 16:36:00 GMT 2007


I thought the bsi/cbsi stuff was reverted?


On 9/6/07, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> As described in PR, compiler segfaults when trying to iterate through bb
> with no stmt. Attached patch adds checking for NULL bb_stmt_list in
> [c]bsi_start() and [c]bsi_last() to solve this problem.
>
> Patch was bootstrapped on x86_64-pc-linux-gnu. Regression test {,-m32}
> is in progress. OK if it passes?
>
> [BTW: Yes, -ftree-vectorize is enough , we don't need to add -msse2 or
> -altivec or whatever to trigger this bug.]
>
> 2007-09-06  Uros Bizjak  <ubizjak@gmail.com>
>
>         PR tree-optimization/32821
>         * tree-flow-inline.c (bsi_start): Check for bb_stmt_list for NULL.
>         (cbsi_start): Ditto.
>         (bsi_last): Ditto.
>         (cbsi_last): Ditto.
>
> testsuite/ChangeLog:
>
> 2007-09-06  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,14 @@
> +/* { 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-flow-inline.h
> ===================================================================
> --- tree-flow-inline.h  (revision 128183)
> +++ tree-flow-inline.h  (working copy)
> @@ -734,7 +734,8 @@ static inline block_stmt_iterator
>  bsi_start (basic_block bb)
>  {
>    block_stmt_iterator bsi;
> -  if (bb->index < NUM_FIXED_BLOCKS)
> +  if (bb->index < NUM_FIXED_BLOCKS
> +      || bb_stmt_list (bb) == NULL_TREE)
>      {
>        bsi.tsi.ptr = NULL;
>        bsi.tsi.container = NULL;
> @@ -749,7 +750,8 @@ static inline const_block_stmt_iterator
>  cbsi_start (const_basic_block bb)
>  {
>    const_block_stmt_iterator bsi;
> -  if (bb->index < NUM_FIXED_BLOCKS)
> +  if (bb->index < NUM_FIXED_BLOCKS
> +      || bb_stmt_list (bb) == NULL_TREE)
>      {
>        bsi.tsi.ptr = NULL;
>        bsi.tsi.container = NULL;
> @@ -781,7 +783,8 @@ bsi_last (basic_block bb)
>  {
>    block_stmt_iterator bsi;
>
> -  if (bb->index < NUM_FIXED_BLOCKS)
> +  if (bb->index < NUM_FIXED_BLOCKS
> +      || bb_stmt_list (bb) == NULL_TREE)
>      {
>        bsi.tsi.ptr = NULL;
>        bsi.tsi.container = NULL;
> @@ -797,7 +800,8 @@ cbsi_last (const_basic_block bb)
>  {
>    const_block_stmt_iterator bsi;
>
> -  if (bb->index < NUM_FIXED_BLOCKS)
> +  if (bb->index < NUM_FIXED_BLOCKS
> +      || bb_stmt_list (bb) == NULL_TREE)
>      {
>        bsi.tsi.ptr = NULL;
>        bsi.tsi.container = NULL;
>
>



More information about the Gcc-patches mailing list