diff mbox

Fix crash in vect_is_slp_reduction

Message ID 4DD67554.5050904@qnx.com
State New
Headers show

Commit Message

Ryan Mansfield May 20, 2011, 2:06 p.m. UTC
There is a crash in vect_is_slp_reduction where use_stmt doesn't get 
initialized in the FOR_EACH_IMM_USE_FAST loop.

1718	      FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
(gdb) call debug_tree(lhs)
  <ssa_name 0x7ffff6e3a5a0
     type <integer_type 0x7ffff7f8c7e0 int32_t sizes-gimplified public SI
         size <integer_cst 0x7ffff7ec47e0 constant 32>
         unit size <integer_cst 0x7ffff7ec4580 constant 4>
         align 32 symtab 0 alias set -1 canonical type 0x7ffff7ecb498 
precision 32 min <integer_cst 0x7ffff7ec4780 -2147483648> max 
<integer_cst 0x7ffff7ec47a0 2147483647> context <translation_unit_decl 
0x7ffff7f98508 D.1314>
         pointer_to_this <pointer_type 0x7ffff7f9f930>>
     var <var_decl 0x7ffff6e1ce60 g_29_lsm.18>def_stmt g_29_lsm.18_137 = 
PHI <g_29_lsm.18_87(15), D.2113_96(18)>

     version 137>
(gdb) n
1742	      if (found)
(gdb)
1746	      if (gimple_code (use_stmt) == GIMPLE_PHI)
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x0000000000980f22 in gimple_code (g=0x0) at ../../gcc/gimple.h:1098
1098	  return g->gsbase.code;

Is the following sufficient?

        if (!is_gimple_assign (use_stmt)

Regards,

Ryan Mansfield

Comments

Richard Biener May 20, 2011, 2:17 p.m. UTC | #1
On Fri, May 20, 2011 at 4:06 PM, Ryan Mansfield <rmansfield@qnx.com> wrote:
> There is a crash in vect_is_slp_reduction where use_stmt doesn't get
> initialized in the FOR_EACH_IMM_USE_FAST loop.
>
> 1718          FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
> (gdb) call debug_tree(lhs)
>  <ssa_name 0x7ffff6e3a5a0
>    type <integer_type 0x7ffff7f8c7e0 int32_t sizes-gimplified public SI
>        size <integer_cst 0x7ffff7ec47e0 constant 32>
>        unit size <integer_cst 0x7ffff7ec4580 constant 4>
>        align 32 symtab 0 alias set -1 canonical type 0x7ffff7ecb498
> precision 32 min <integer_cst 0x7ffff7ec4780 -2147483648> max <integer_cst
> 0x7ffff7ec47a0 2147483647> context <translation_unit_decl 0x7ffff7f98508
> D.1314>
>        pointer_to_this <pointer_type 0x7ffff7f9f930>>
>    var <var_decl 0x7ffff6e1ce60 g_29_lsm.18>def_stmt g_29_lsm.18_137 = PHI
> <g_29_lsm.18_87(15), D.2113_96(18)>
>
>    version 137>
> (gdb) n
> 1742          if (found)
> (gdb)
> 1746          if (gimple_code (use_stmt) == GIMPLE_PHI)
> (gdb)
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000980f22 in gimple_code (g=0x0) at ../../gcc/gimple.h:1098
> 1098      return g->gsbase.code;
>
> Is the following sufficient?

No, we shouldn't arrive with a NULL use_stmt here.

Richard.

> Index: tree-vect-loop.c
> ===================================================================
> --- tree-vect-loop.c    (revision 173945)
> +++ tree-vect-loop.c    (working copy)
> @@ -1743,7 +1743,7 @@
>         break;
>
>       /* This is a loop exit phi, and we haven't reached the reduction phi.
>  */
> -      if (gimple_code (use_stmt) == GIMPLE_PHI)
> +      if (!use_stmt || gimple_code (use_stmt) == GIMPLE_PHI)
>         return false;
>
>       if (!is_gimple_assign (use_stmt)
>
> Regards,
>
> Ryan Mansfield
>
Ryan Mansfield May 20, 2011, 4:50 p.m. UTC | #2
On 11-05-20 10:17 AM, Richard Guenther wrote:
> On Fri, May 20, 2011 at 4:06 PM, Ryan Mansfield<rmansfield@qnx.com>  wrote:
>> There is a crash in vect_is_slp_reduction where use_stmt doesn't get
>> initialized in the FOR_EACH_IMM_USE_FAST loop.
>>
>> 1718          FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
>> (gdb) call debug_tree(lhs)
>>   <ssa_name 0x7ffff6e3a5a0
>>     type<integer_type 0x7ffff7f8c7e0 int32_t sizes-gimplified public SI
>>         size<integer_cst 0x7ffff7ec47e0 constant 32>
>>         unit size<integer_cst 0x7ffff7ec4580 constant 4>
>>         align 32 symtab 0 alias set -1 canonical type 0x7ffff7ecb498
>> precision 32 min<integer_cst 0x7ffff7ec4780 -2147483648>  max<integer_cst
>> 0x7ffff7ec47a0 2147483647>  context<translation_unit_decl 0x7ffff7f98508
>> D.1314>
>>         pointer_to_this<pointer_type 0x7ffff7f9f930>>
>>     var<var_decl 0x7ffff6e1ce60 g_29_lsm.18>def_stmt g_29_lsm.18_137 = PHI
>> <g_29_lsm.18_87(15), D.2113_96(18)>
>>
>>     version 137>
>> (gdb) n
>> 1742          if (found)
>> (gdb)
>> 1746          if (gimple_code (use_stmt) == GIMPLE_PHI)
>> (gdb)
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x0000000000980f22 in gimple_code (g=0x0) at ../../gcc/gimple.h:1098
>> 1098      return g->gsbase.code;
>>
>> Is the following sufficient?
>
> No, we shouldn't arrive with a NULL use_stmt here.

OK, thanks. I've filed PR49087 with a testcase.

Regards,

Ryan Mansfield
diff mbox

Patch

Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c	(revision 173945)
+++ tree-vect-loop.c	(working copy)
@@ -1743,7 +1743,7 @@ 
          break;

        /* This is a loop exit phi, and we haven't reached the reduction 
phi.  */
-      if (gimple_code (use_stmt) == GIMPLE_PHI)
+      if (!use_stmt || gimple_code (use_stmt) == GIMPLE_PHI)
          return false;