Patchwork [tree-opt] : Fix PR5118, ICE: tree check: expected tree that contains ‘typed’ structure, have ‘block’ in fold_checksum_tree

login
register
mail settings
Submitter Uros Bizjak
Date Nov. 17, 2011, 7:47 p.m.
Message ID <CAFULd4YKrfDHfbSZB947b5O2PJty72q5nsVFrnDFwag91u4Ykw@mail.gmail.com>
Download mbox | patch
Permalink /patch/126303/
State New
Headers show

Comments

Uros Bizjak - Nov. 17, 2011, 7:47 p.m.
Hello!

Currently, bootstrap crashes with --enable-stage1-checking=all with:

../../../libgcc/libgcc2.c:553:3: internal compiler error: tree check: expected
tree that contains ‘typed’ structure, have ‘block’ in fold_checksum_tree, at
fold-const.c:14160

The problem is in fold_checksum_tree function itself, when it recurses for i.e.

(gdb) p debug_tree (expr)
 <bind_expr 0x7ffff1ac6000
    type <void_type 0x7ffff19a5bd0 void VOID
        align 8 symtab 0 alias set -1 canonical type 0x7ffff19a5bd0
        pointer_to_this <pointer_type 0x7ffff19a5c78>>
---
    body <decl_expr 0x7ffff1aa3f28 type <void_type 0x7ffff19a5bd0 void>
        side-effects arg 0 <var_decl 0x7ffff1ac5140 __w>
        031.c:4:32>
    block <block 0x7ffff1ab6f50 used vars <var_decl 0x7ffff1ac5140 __w>>
    031.c:4:23>

The function decomposes the tree expression with:

    case tcc_expression:
...
      len = TREE_OPERAND_LENGTH (expr);
      for (i = 0; i < len; ++i)
>>	fold_checksum_tree (TREE_OPERAND (expr, i), ctx, ht);
      break;

where we recurse with "block" expression, that has no type. This
recursion crashes at

  md5_process_bytes (expr, tree_size (expr), ctx);
>>  fold_checksum_tree (TREE_TYPE (expr), ctx, ht);

The fix is fairly trivial - check for typed structure before using
TREE_TYPE accessor, as the error said.

2011-11-17  Uros Bizjak  <ubizjak@gmail.com>

	PR tree-optimization/51118
	* fold-const.c (fold_checksum_tree): Check for TS_TYPED structure
	before using TREE_TYPE accessor on expr.

Patch was tested by bootstrapping --enable-stage1-checking=all
configured bootstrap (which takes ages...) on x86_64-pc-linux-gnu.

OK for mainline and release branches?

Uros.
Richard Guenther - Nov. 18, 2011, 9:34 a.m.
On Thu, Nov 17, 2011 at 8:47 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> Currently, bootstrap crashes with --enable-stage1-checking=all with:
>
> ../../../libgcc/libgcc2.c:553:3: internal compiler error: tree check: expected
> tree that contains ‘typed’ structure, have ‘block’ in fold_checksum_tree, at
> fold-const.c:14160
>
> The problem is in fold_checksum_tree function itself, when it recurses for i.e.
>
> (gdb) p debug_tree (expr)
>  <bind_expr 0x7ffff1ac6000
>    type <void_type 0x7ffff19a5bd0 void VOID
>        align 8 symtab 0 alias set -1 canonical type 0x7ffff19a5bd0
>        pointer_to_this <pointer_type 0x7ffff19a5c78>>
> ---
>    body <decl_expr 0x7ffff1aa3f28 type <void_type 0x7ffff19a5bd0 void>
>        side-effects arg 0 <var_decl 0x7ffff1ac5140 __w>
>        031.c:4:32>
>    block <block 0x7ffff1ab6f50 used vars <var_decl 0x7ffff1ac5140 __w>>
>    031.c:4:23>
>
> The function decomposes the tree expression with:
>
>    case tcc_expression:
> ...
>      len = TREE_OPERAND_LENGTH (expr);
>      for (i = 0; i < len; ++i)
>>>      fold_checksum_tree (TREE_OPERAND (expr, i), ctx, ht);
>      break;
>
> where we recurse with "block" expression, that has no type. This
> recursion crashes at
>
>  md5_process_bytes (expr, tree_size (expr), ctx);
>>>  fold_checksum_tree (TREE_TYPE (expr), ctx, ht);
>
> The fix is fairly trivial - check for typed structure before using
> TREE_TYPE accessor, as the error said.
>
> 2011-11-17  Uros Bizjak  <ubizjak@gmail.com>
>
>        PR tree-optimization/51118
>        * fold-const.c (fold_checksum_tree): Check for TS_TYPED structure
>        before using TREE_TYPE accessor on expr.
>
> Patch was tested by bootstrapping --enable-stage1-checking=all
> configured bootstrap (which takes ages...) on x86_64-pc-linux-gnu.
>
> OK for mainline and release branches?

Ok for trunk.

Thanks,
Richard.

> Uros.
>

Patch

Index: fold-const.c
===================================================================
--- fold-const.c	(revision 181443)
+++ fold-const.c	(working copy)
@@ -14157,7 +14157,8 @@  fold_checksum_tree (const_tree expr, struct md5_ct
 	}
     }
   md5_process_bytes (expr, tree_size (expr), ctx);
-  fold_checksum_tree (TREE_TYPE (expr), ctx, ht);
+  if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
+    fold_checksum_tree (TREE_TYPE (expr), ctx, ht);
   if (TREE_CODE_CLASS (code) != tcc_type
       && TREE_CODE_CLASS (code) != tcc_declaration
       && code != TREE_LIST