diff mbox

Fix ICE with -fauto-profile when walking vdefs

Message ID CAFk3UF-kgPKNpFmBsfSs_YH8iY=CN9W8dAkX9P3-gka4zbetvg@mail.gmail.com
State New
Headers show

Commit Message

Sebastian Pop March 31, 2017, 4:04 p.m. UTC
Hi,

with trunk gcc as of today and gcc releases 6.* and 5.*,
I get an ICE when compiling a large c++ project with autoFDO
at -O1 and above with -fauto-profile=some.gcov

internal compiler error: tree check: expected ssa_name, have var_decl
in walk_aliased_vdefs_1, at tree-ssa-alias.c:2912
0x1072fec tree_check_failed(tree_node const*, char const*, int, char
const*, ...)
        ../../gcc/tree.c:9819
0xed6ad9 tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/tree.h:3064
0xed6ad9 walk_aliased_vdefs_1
        ../../gcc/tree-ssa-alias.c:2912
0xed6b61 walk_aliased_vdefs(ao_ref*, tree_node*, bool (*)(ao_ref*,
tree_node*, void*), void*, bitmap_head**, bool*, unsigned int)
        ../../gcc/tree-ssa-alias.c:2972
0xbe97f0 parm_ref_data_preserved_p
        ../../gcc/ipa-prop.c:1015
0xbe97f0 ipa_load_from_parm_agg(ipa_func_body_info*,
vec<ipa_param_descriptor, va_gc, vl_embed>*, gimple*, tree_node*,
int*, long*, long*, bool*, bool*)
        ../../gcc/ipa-prop.c:1138
0xbd3213 unmodified_parm_or_parm_agg_item
        ../../gcc/ipa-inline-analysis.c:1626
0xbd4d05 set_cond_stmt_execution_predicate
        ../../gcc/ipa-inline-analysis.c:1789
0xbd4d05 compute_bb_predicates
        ../../gcc/ipa-inline-analysis.c:1925
0xbdb140 estimate_function_body_sizes
        ../../gcc/ipa-inline-analysis.c:2603
0xbdfcce compute_inline_parameters(cgraph_node*, bool)
        ../../gcc/ipa-inline-analysis.c:3048
0x1446ce8 early_inline
        ../../gcc/auto-profile.c:1592
0x1449aac auto_profile
        ../../gcc/auto-profile.c:1656

The patch below fixes the ICE by checking that the vdef is an SSA_NAME
before trying to walk to a def stmt.  At that point I see that the
vdef is a var_decl:

(gdb) p vdef
$1 = (tree) 0x7fffda143750
(gdb) pt
warning: Expression is not an assignment (and might have no effect)
 <var_decl 0x7fffda143750 .MEM
    type <void_type 0x7ffff65d4f18 void type_6 VOID
        align 8 symtab 0 alias set -1 canonical type 0x7ffff65d4f18
        pointer_to_this <pointer_type 0x7ffff65dc0a8>>
    used static ignored external VOID file <built-in> line 0 col 0
    align 8>
(gdb) pgs
warning: Expression is not an assignment (and might have no effect)
.MEM

vdef comes from two frames above as gimple_vuse (stmt) in:

  int walked = walk_aliased_vdefs (&refd, gimple_vuse (stmt), mark_modified,
  &modified, NULL);

(gdb) p stmt
$2 = (gimple *) 0x7fffd77d4730
(gdb) pgg
# VUSE <.MEM>
_66 = this_13(D)->s_;

The reason why I have left the check in the do-while loop
is because vdef is updated at the bottom of the loop as:

      vdef = gimple_vuse (def_stmt);

and that may again find a default definition vdef
that is not pointing to another statement defining it.

The patch passed bootstrap and regression test on x86_64-linux.
Ok for trunk and other release branches?

Thanks,
Sebastian

        * tree-ssa-alias.c (walk_aliased_vdefs_1): Handle default virtual defs.

Comments

Richard Biener March 31, 2017, 5:06 p.m. UTC | #1
On March 31, 2017 6:04:32 PM GMT+02:00, Sebastian Pop <sebpop@gmail.com> wrote:
>Hi,
>
>with trunk gcc as of today and gcc releases 6.* and 5.*,
>I get an ICE when compiling a large c++ project with autoFDO
>at -O1 and above with -fauto-profile=some.gcov
>
>internal compiler error: tree check: expected ssa_name, have var_decl
>in walk_aliased_vdefs_1, at tree-ssa-alias.c:2912
>0x1072fec tree_check_failed(tree_node const*, char const*, int, char
>const*, ...)
>        ../../gcc/tree.c:9819
>0xed6ad9 tree_check(tree_node*, char const*, int, char const*,
>tree_code)
>        ../../gcc/tree.h:3064
>0xed6ad9 walk_aliased_vdefs_1
>        ../../gcc/tree-ssa-alias.c:2912
>0xed6b61 walk_aliased_vdefs(ao_ref*, tree_node*, bool (*)(ao_ref*,
>tree_node*, void*), void*, bitmap_head**, bool*, unsigned int)
>        ../../gcc/tree-ssa-alias.c:2972
>0xbe97f0 parm_ref_data_preserved_p
>        ../../gcc/ipa-prop.c:1015
>0xbe97f0 ipa_load_from_parm_agg(ipa_func_body_info*,
>vec<ipa_param_descriptor, va_gc, vl_embed>*, gimple*, tree_node*,
>int*, long*, long*, bool*, bool*)
>        ../../gcc/ipa-prop.c:1138
>0xbd3213 unmodified_parm_or_parm_agg_item
>        ../../gcc/ipa-inline-analysis.c:1626
>0xbd4d05 set_cond_stmt_execution_predicate
>        ../../gcc/ipa-inline-analysis.c:1789
>0xbd4d05 compute_bb_predicates
>        ../../gcc/ipa-inline-analysis.c:1925
>0xbdb140 estimate_function_body_sizes
>        ../../gcc/ipa-inline-analysis.c:2603
>0xbdfcce compute_inline_parameters(cgraph_node*, bool)
>        ../../gcc/ipa-inline-analysis.c:3048
>0x1446ce8 early_inline
>        ../../gcc/auto-profile.c:1592
>0x1449aac auto_profile
>        ../../gcc/auto-profile.c:1656
>
>The patch below fixes the ICE by checking that the vdef is an SSA_NAME
>before trying to walk to a def stmt.  At that point I see that the
>vdef is a var_decl:
>
>(gdb) p vdef
>$1 = (tree) 0x7fffda143750
>(gdb) pt
>warning: Expression is not an assignment (and might have no effect)
> <var_decl 0x7fffda143750 .MEM
>    type <void_type 0x7ffff65d4f18 void type_6 VOID
>        align 8 symtab 0 alias set -1 canonical type 0x7ffff65d4f18
>        pointer_to_this <pointer_type 0x7ffff65dc0a8>>
>    used static ignored external VOID file <built-in> line 0 col 0
>    align 8>
>(gdb) pgs
>warning: Expression is not an assignment (and might have no effect)
>.MEM
>
>vdef comes from two frames above as gimple_vuse (stmt) in:
>
>int walked = walk_aliased_vdefs (&refd, gimple_vuse (stmt),
>mark_modified,
>  &modified, NULL);
>
>(gdb) p stmt
>$2 = (gimple *) 0x7fffd77d4730
>(gdb) pgg
># VUSE <.MEM>
>_66 = this_13(D)->s_;
>
>The reason why I have left the check in the do-while loop
>is because vdef is updated at the bottom of the loop as:
>
>      vdef = gimple_vuse (def_stmt);
>
>and that may again find a default definition vdef
>that is not pointing to another statement defining it.

That's not a default definition but bogus SSA form.  You have to fix that, not this symptom.

Richard.

>
>The patch passed bootstrap and regression test on x86_64-linux.
>Ok for trunk and other release branches?
>
>Thanks,
>Sebastian
>
>* tree-ssa-alias.c (walk_aliased_vdefs_1): Handle default virtual defs.
>
>diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
>index 3f0c650475d..5a66306610f 100644
>--- a/gcc/tree-ssa-alias.c
>+++ b/gcc/tree-ssa-alias.c
>@@ -2909,6 +2909,10 @@ walk_aliased_vdefs_1 (ao_ref *ref, tree vdef,
> {
>   do
>     {
>+      /* Before asking for a statement, check that it is an SSA_NAME. 
>*/
>+      if (TREE_CODE(vdef) != SSA_NAME)
>+       return cnt;
>+
>       gimple *def_stmt = SSA_NAME_DEF_STMT (vdef);
>
>       if (*visited
diff mbox

Patch

diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 3f0c650475d..5a66306610f 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -2909,6 +2909,10 @@  walk_aliased_vdefs_1 (ao_ref *ref, tree vdef,
 {
   do
     {
+      /* Before asking for a statement, check that it is an SSA_NAME.  */
+      if (TREE_CODE(vdef) != SSA_NAME)
+       return cnt;
+
       gimple *def_stmt = SSA_NAME_DEF_STMT (vdef);

       if (*visited