https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82060

            Bug ID: 82060
           Summary: [7/8 Regression] ICE in refs_may_alias_p_1 with
                    devirtualization enabled
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wielkiegie at gmail dot com
  Target Milestone: ---

Created attachment 42095
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42095&action=edit
Annotated test case used in order to reproduce the bug

Attached is a minimal test case that triggers an Internal Compiler Error in
refs_may_alias_p_1 when compiling at least with -O1 -fdevirtualize. The bug
occurs on gcc 7 and the current snapshot (tested on godbolt).

I have tried to check which -O1 optimization is needed alongside -fdevirtualize
in order to trigger this bug, but when I replaced -O1 with a list of -f options
from the gcc manual the bug went away. I also tried to list the -O1
optimizations using `-Q --help=optimizers', but it didn't help. It might be
something not listed there or otherwise hidden inside the -O1 setting.

Comments in the test case show what is needed in order to encounter this bug.
Some of these might be erroneous, but if I tried to simplify/change any of
these, the bug goes away.

$ g++ -O1 -fdevirtualize testcase.cpp 
testcase.cpp: In function ‘void foo(D&)’:
testcase.cpp:30:1: internal compiler error: in refs_may_alias_p_1, at
tree-ssa-alias.c:1538
 }
 ^
0xbd1e49 refs_may_alias_p_1(ao_ref*, ao_ref*, bool)
        ../../gcc/tree-ssa-alias.c:1538
0xbd3369 stmt_may_clobber_ref_p_1(gimple*, ao_ref*)
        ../../gcc/tree-ssa-alias.c:2289
0xbd3b0a walk_aliased_vdefs_1
        ../../gcc/tree-ssa-alias.c:2947
0xbd3b9d walk_aliased_vdefs_1
        ../../gcc/tree-ssa-alias.c:2934
0xbd3c41 walk_aliased_vdefs(ao_ref*, tree_node*, bool (*)(ao_ref*, tree_node*,
void*), void*, bitmap_head**, bool*, unsigned int)
        ../../gcc/tree-ssa-alias.c:2970
0x96d2ec ipa_polymorphic_call_context::get_dynamic_type(tree_node*, tree_node*,
tree_node*, gimple*)
        ../../gcc/ipa-polymorphic-call.c:1680
0xc43392 eliminate_dom_walker::before_dom_children(basic_block_def*)
        ../../gcc/tree-ssa-pre.c:4604
0x10fe12a dom_walker::walk(basic_block_def*)
        ../../gcc/domwalk.c:265
0xc42c01 eliminate
        ../../gcc/tree-ssa-pre.c:4773
0xc42f44 execute
        ../../gcc/tree-ssa-pre.c:5207
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to