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

--- Comment #5 from Stefan Schulze Frielinghaus <stefansf at gcc dot gnu.org> 
---
Sorry for taking so long.  I accidentally switched to a checking=release build.
 With checking=yes it is reproducible and I get a proper ICE.  Now, even
earlier tests fail.  With the appended reduced test I get:

$ c++ -O3 -std=c++14 -c t.ii  
t.ii:133:3: warning: access declarations are deprecated in favor of
using-declarations; suggestion: add the 'using' keyword [-Wdeprecated]
  133 |   DenseCoeffsBase<Derived>::derived;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~
during GIMPLE pass: aprefetch
t.ii: In function 'void product()':
t.ii:422:6: internal compiler error: tree check: expected ssa_name, have
integer_cst in ptr_deref_may_alias_decl_p, at tree-ssa-alias.cc:299
  422 | void product() {
      |      ^~~~~~~
0x1269571 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        /gcc/src/gcc/tree.cc:8995
0x1ff009b tree_check(tree_node*, char const*, int, char const*, tree_code)
        /gcc/src/gcc/tree.h:3624
0x1ff009b ptr_deref_may_alias_decl_p
        /gcc/src/gcc/tree-ssa-alias.cc:299
0x2cad1bf initialize_data_dependence_relation(data_reference*, data_reference*,
vec<loop*, va_heap, vl_ptr>)
        /gcc/src/gcc/tree-data-ref.cc:3489
0x2cad2db compute_all_dependences(vec<data_reference*, va_heap, vl_ptr> const&,
vec<data_dependence_relation*, va_heap, vl_ptr>*, vec<loop*, va_heap, vl_ptr>
const&, bool)
        /gcc/src/gcc/tree-data-ref.cc:5764
0x2cad2db compute_all_dependences(vec<data_reference*, va_heap, vl_ptr> const&,
vec<data_dependence_relation*, va_heap, vl_ptr>*, vec<loop*, va_heap, vl_ptr>
const&, bool)
        /gcc/src/gcc/tree-data-ref.cc:5739
0x209d323 determine_loop_nest_reuse
        /gcc/src/gcc/tree-ssa-loop-prefetch.cc:1693
0x209d323 loop_prefetch_arrays
        /gcc/src/gcc/tree-ssa-loop-prefetch.cc:1939
0x209d323 tree_ssa_prefetch_arrays()
        /gcc/src/gcc/tree-ssa-loop-prefetch.cc:2041

we enter ptr_deref_may_alias_decl_p with

call debug_tree(ptr)
 <addr_expr 0x3fff74c5380
    type <pointer_type 0x3fff78237e0
        type <real_type 0x3fff78232a0 float sizes-gimplified type_6 SF
            size <integer_cst 0x3fff7802fd8 constant 32>
            unit-size <integer_cst 0x3fff781f000 constant 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set 2 canonical-type
0x3fff78232a0 precision:32
            pointer_to_this <pointer_type 0x3fff78237e0> reference_to_this
<reference_type 0x3fff79dc1f8>>
        sizes-gimplified public unsigned type_6 DI
        size <integer_cst 0x3fff7802d98 constant 64>
        unit-size <integer_cst 0x3fff7802db0 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set 3 canonical-type
0x3fff78237e0>
    constant
    arg:0 <component_ref 0x3fff744bba0 type <real_type 0x3fff78232a0 float>

        arg:0 <mem_ref 0x3fff7496c30 type <union_type 0x3fff79dc540 Packet>

            arg:0 <integer_cst 0x3fff740a5b8 constant 0>
            arg:1 <integer_cst 0x3fff740a630 constant 0>>
        arg:1 <field_decl 0x3fff79db130 v4f type <real_type 0x3fff78232a0
float>
            used nonlocal decl_3 SF t.ii:114:9 size <integer_cst 0x3fff7802fd8
32> unit-size <integer_cst 0x3fff781f000 4>
            align:32 warn_if_not_align:0 offset_align 64 decl_not_flexarray: 0
            offset <integer_cst 0x3fff7802dc8 constant 0>
            bit-offset <integer_cst 0x3fff7802e10 constant 0> context
<union_type 0x3fff79d9bd0 Packet> chain <type_decl 0x3fff79db098 ._anon_6>>
        t.ii:121:16 start: t.ii:121:10 finish: t.ii:121:18>>

then in

if (TREE_CODE (ptr) == ADDR_EXPR)
  {
    tree base = get_base_address (TREE_OPERAND (ptr, 0));
    if (base
        && (TREE_CODE (base) == MEM_REF
            || TREE_CODE (base) == TARGET_MEM_REF))
      ptr = TREE_OPERAND (base, 0);

we have

call debug_tree (base)
 <mem_ref 0x3fff7496c30
    type <union_type 0x3fff79dc540 Packet readonly sizes-gimplified cxx-odr-p
type_5 SI
        size <integer_cst 0x3fff7802fd8 constant 32>
        unit-size <integer_cst 0x3fff781f000 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x3fff79dc540
        fields <function_decl 0x3fff79de300 __dt  type <method_type
0x3fff79dc3f0>
            public abstract external autoinline decl_3 QI t.ii:115:3 align:64
warn_if_not_align:0 context <union_type 0x3fff79d9bd0 Packet>
            full-name "Packet::~Packet() noexcept (<uninstantiated>)"
            not-really-extern chain <function_decl 0x3fff79de500 __dt_base >>
context <translation_unit_decl 0x3fff7819000 t.ii>
        full-name "const union Packet"
        X() X(constX&) this=(X&)
        pointer_to_this <pointer_type 0x3fff79dca80> reference_to_this
<reference_type 0x3fff79dc5e8>>

    arg:0 <integer_cst 0x3fff740a5b8 type <pointer_type 0x3fff7945348> constant
0>
    arg:1 <integer_cst 0x3fff740a630 type <reference_type 0x3fff79dc5e8>
constant 0>>

which means we end up with a const_int

call debug_tree (ptr)
 <integer_cst 0x3fff740a5b8 type <pointer_type 0x3fff7945348> constant 0>

with checking=yes we finally ICE in

pi = SSA_NAME_PTR_INFO (ptr);

or with checking=release we don't ICE but later on segfault.

Commit r15-491-gc290e6a0b7a9de introduces

diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index e7c1c1aa624..374ba04e6fd 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -294,6 +294,11 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl)
   if (!may_be_aliased (decl))
     return false;

+  /* From here we require a SSA name pointer.  Anything else aliases.  */
+  if (TREE_CODE (ptr) != SSA_NAME
+      || !POINTER_TYPE_P (TREE_TYPE (ptr)))
+    return true;

which is why we don't see an ICE/segfault anymore.

Reply via email to