public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2
@ 2020-12-14 19:25 bengilgit at gmail dot com
  2020-12-14 19:33 ` [Bug c++/98282] " bengilgit at gmail dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: bengilgit at gmail dot com @ 2020-12-14 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98282
           Summary: Segmentation fault when compiling with optimization >=
                    2
           Product: gcc
           Version: 7.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bengilgit at gmail dot com
  Target Milestone: ---

Compilation of the attached preprocessed source produces an internal compiler
error:

$ /usr/bin/g++ -O2 -c ../scalar_cast_nested.cc.preprocessed.cc
../src/arrow/compute/kernels/scalar_cast_nested.cc: In function ‘void
arrow::compute::internal::CastListExec(arrow::compute::KernelContext*, const
arrow::compute::ExecBatch&, arrow::Datum*) [with Type = arrow::ListType]’:
../src/arrow/compute/kernels/scalar_cast_nested.cc:33:6: internal compiler
error: Segmentation fault
 void CastListExec(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
      ^~~~~~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.

$ /usr/bin/g++ --version
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Bisection indicates this is ultimately caused by replacing `nonstd::variant`
with an in-house implementation, change at:
https://github.com/apache/arrow/pull/8472

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/98282] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
@ 2020-12-14 19:33 ` bengilgit at gmail dot com
  2020-12-14 22:06 ` jakub at gcc dot gnu.org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bengilgit at gmail dot com @ 2020-12-14 19:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Benjamin Kietzman <bengilgit at gmail dot com> ---
Created attachment 49765
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49765&action=edit
preprocessed file which reproduces the crash

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/98282] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
  2020-12-14 19:33 ` [Bug c++/98282] " bengilgit at gmail dot com
@ 2020-12-14 22:06 ` jakub at gcc dot gnu.org
  2020-12-14 23:30 ` jakub at gcc dot gnu.org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-14 22:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 7.x isn't supported anymore.
That said, this is an ICE that went away on trunk and in 10.x with the
r10-3583-g562d1e9556777988ae46c5d1357af2636bc272ea
change, which means it likely went latent because those changes were inliner
heuristic changes and the ICE in PRE.
I can reproduce on 9 branch.
cvise reducing now.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/98282] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
  2020-12-14 19:33 ` [Bug c++/98282] " bengilgit at gmail dot com
  2020-12-14 22:06 ` jakub at gcc dot gnu.org
@ 2020-12-14 23:30 ` jakub at gcc dot gnu.org
  2020-12-14 23:34 ` [Bug c++/98282] [8/9/10/11 Regression] " jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-14 23:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-12-14

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Reduced testcase that ICEs with -O2 even with current trunk in PRE:
template <typename> struct g;
template <typename b> struct g<b &> { typedef b c; };
template <typename b> typename g<b>::c &&d(b &&e) {
  return static_cast<typename g<b>::c &&>(e);
}
void *operator new(__SIZE_TYPE__, void *f) { return f; }
struct h;
struct k {
  using i = h *;
};
struct D {
  k::i j;
};
struct p : D {
  p(p &&) : D() {}
};
struct r {
  using l = int;
  r(r &&) : ad() {}
  l *ad;
};
struct s {
  static s m();
};
struct t {
  template <typename ah> void operator=(ah);
};
struct I {
  template <typename o> void q(o ai) {
    *ai = aj();
    s::m();
  }
  h aj();
};
template <typename...> class as;
struct J {
  int a;
  char av;
};
template <typename...> struct aw : J {
  void ax(...) {}
};
template <typename... ay, typename an, typename... n>
struct aw<as<ay...>, an, n...> : aw<as<ay...>, n...> {
  using az = as<ay...>;
  using ba = aw<az, n...>;
  char bb;
  an &bc() { return *reinterpret_cast<an *>(this); }
  void ax(az *bd) {
    if (bb)
      new (bd) an(d(bc()));
    ba::ax(bd);
  }
};
template <typename... n> struct as : aw<as<n...>, n...> {
  as();
  as(as &&be) { be.ax(this); }
  void operator=(as be) { be.ax(this); }
};
struct h {
  as<decltype(nullptr), r, p> bg;
};
using bh = t;
struct u {
  bh bj;
};
I bk();
template <typename> void bl() {
  h a;
  bk().q(&a);
}
template <typename> void bn(int) {
  u b;
  b.bj = bl<int>;
}
void bp() { bn<int>(0); }


/usr/src/gcc/obj/gcc/cc1plus -quiet -O2 pr98282.ii 
during GIMPLE pass: pre
pr98282.ii: In function ‘void bl() [with <template-parameter-1-1> = int]’:
pr98282.ii:68:26: internal compiler error: Segmentation fault
   68 | template <typename> void bl() {
      |                          ^~
0x17098ba crash_signal
        ../../gcc/toplev.c:327
0x9dc372 contains_struct_check(tree_node const*, tree_node_structure_enum, char
const*, int, char const*)
        ../../gcc/tree.h:3707
0xa7089b wi::to_wide(tree_node const*)
        ../../gcc/tree.h:5983
0x19caa55 compute_avail
        ../../gcc/tree-ssa-pre.c:4214
0x19cb145 execute
        ../../gcc/tree-ssa-pre.c:4408
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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/98282] [8/9/10/11 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (2 preceding siblings ...)
  2020-12-14 23:30 ` jakub at gcc dot gnu.org
@ 2020-12-14 23:34 ` jakub at gcc dot gnu.org
  2020-12-15 10:05 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-14 23:34 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Segmentation fault when     |[8/9/10/11 Regression]
                   |compiling with optimization |Segmentation fault when
                   |>= 2                        |compiling with optimization
                   |                            |>= 2
           Priority|P3                          |P2
           Keywords|                            |ice-on-valid-code
   Target Milestone|---                         |8.5

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r7-1867-g3c5b29f56103d60f4f4dca7136ae4dcc7987a728

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/98282] [8/9/10/11 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (3 preceding siblings ...)
  2020-12-14 23:34 ` [Bug c++/98282] [8/9/10/11 Regression] " jakub at gcc dot gnu.org
@ 2020-12-15 10:05 ` jakub at gcc dot gnu.org
  2020-12-16  9:03 ` [Bug tree-optimization/98282] " rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-15 10:05 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, the ICE is because compute_avail gets called twice on VIEW_CONVERT_EXPR
from NULL to decltype(nullptr):
stmt:
_7 = VIEW_CONVERT_EXPR<<<< Unknown tree: nullptr_type >>>>(0B);
rhs1:
 <view_convert_expr 0x7fffe9ddd0e0
    type <nullptr_type 0x7fffea1a3c78 decltype(nullptr) unsigned type_6 DI
        size <integer_cst 0x7fffea041eb8 constant 64>
        unit-size <integer_cst 0x7fffea041ed0 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set 14 canonical-type
0x7fffea1a3c78
        pointer_to_this <pointer_type 0x7fffea21db28> reference_to_this
<reference_type 0x7fffea1eb738>>
    constant
    arg:0 <integer_cst 0x7fffea1b0b28 type <pointer_type 0x7fffea1c3a80>
constant 0>
    pr98282.ii:19:13 start: pr98282.ii:19:13 finish: pr98282.ii:19:16>
TREE_TYPE (TREE_OPERAND (rhs1, 0)):
 <pointer_type 0x7fffea1c3a80
    type <integer_type 0x7fffea1c35e8 l sizes-gimplified type_6 SI
        size <integer_cst 0x7fffea062108 constant 32>
        unit-size <integer_cst 0x7fffea062120 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea05f5e8 precision:32 min <integer_cst 0x7fffea0620c0 -2147483648> max
<integer_cst 0x7fffea0620d8 2147483647>
        pointer_to_this <pointer_type 0x7fffea1c3a80>>
    public unsigned DI
    size <integer_cst 0x7fffea041eb8 type <integer_type 0x7fffea05f0a8
bitsizetype> constant 64>
    unit-size <integer_cst 0x7fffea041ed0 type <integer_type 0x7fffea05f000
sizetype> constant 8>
    align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea0679d8>
TYPE_CANONICAL (TREE_TYPE (TREE_OPERAND (rhs1, 0))):
 <pointer_type 0x7fffea0679d8
    type <integer_type 0x7fffea05f5e8 int sizes-gimplified public type_6 SI
        size <integer_cst 0x7fffea062108 constant 32>
        unit-size <integer_cst 0x7fffea062120 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set 10 canonical-type
0x7fffea05f5e8 precision:32 min <integer_cst 0x7fffea0620c0 -2147483648> max
<integer_cst 0x7fffea0620d8 2147483647>
        pointer_to_this <pointer_type 0x7fffea0679d8>>
    unsigned DI
    size <integer_cst 0x7fffea041eb8 type <integer_type 0x7fffea05f0a8
bitsizetype> constant 64>
    unit-size <integer_cst 0x7fffea041ed0 type <integer_type 0x7fffea05f000
sizetype> constant 8>
    align:64 warn_if_not_align:0 symtab:0 alias-set 4 canonical-type
0x7fffea0679d8>
The alias-set 4 above means get_alias_set on the VCE returns 4.

Second case:
stmt:
_8 = VIEW_CONVERT_EXPR<<<< Unknown tree: nullptr_type >>>>(0B);
rhs1:
 <view_convert_expr 0x7fffe9ddd120
    type <nullptr_type 0x7fffea1a3c78 decltype(nullptr) unsigned type_6 DI
        size <integer_cst 0x7fffea041eb8 constant 64>
        unit-size <integer_cst 0x7fffea041ed0 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set 14 canonical-type
0x7fffea1a3c78
        pointer_to_this <pointer_type 0x7fffea21db28> reference_to_this
<reference_type 0x7fffea1eb738>>
    constant
    arg:0 <integer_cst 0x7fffea1b09f0 type <pointer_type 0x7fffea1bf0a8 i>
constant 0>
    pr98282.ii:15:15 start: pr98282.ii:15:15 finish: pr98282.ii:15:15>
TREE_TYPE (TREE_OPERAND (rhs1, 0)):
 <pointer_type 0x7fffea1bf0a8 i
    type <record_type 0x7fffea1b5dc8 h sizes-gimplified addressable
needs-constructing cxx-odr-p type_5 type_6 BLK
        size <integer_cst 0x7fffea1d35b8 constant 96>
        unit-size <integer_cst 0x7fffea1d35d0 constant 12>
        align:32 warn_if_not_align:0 symtab:0 alias-set 17 canonical-type
0x7fffea1b5dc8
        fields <function_decl 0x7fffea213800 operator= type <method_type
0x7fffea212d20>
            addressable used nothrow public static weak autoinline decl_3
decl_5 QI defer-output pr98282.ii:60:8 align:16 warn_if_not_align:0 context
<record_type 0x7fffea1b5dc8 h> initial <block 0x7fffea1e3600> result
<result_decl 0x7fffea1fa438 D.3000>
            full-name "h& h::operator=(h&&)" chain <function_decl
0x7fffea213700 operator=>> context <translation_unit_decl 0x7fffea04e168
pr98282.ii>
        full-name "struct h"
        needs-constructor X() X(constX&) this=(X&) n_parents=0 use_template=0
interface-unknown
        pointer_to_this <pointer_type 0x7fffea1bf000> reference_to_this
<reference_type 0x7fffea2120a8> chain <type_decl 0x7fffea1be000 h>>
    public unsigned DI
    size <integer_cst 0x7fffea041eb8 type <integer_type 0x7fffea05f0a8
bitsizetype> constant 64>
    unit-size <integer_cst 0x7fffea041ed0 type <integer_type 0x7fffea05f000
sizetype> constant 8>
    align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea1bf000>
TYPE_CANONICAL (TREE_TYPE (TREE_OPERAND (rhs1, 0))):
 <pointer_type 0x7fffea1bf000
    type <record_type 0x7fffea1b5dc8 h sizes-gimplified addressable
needs-constructing cxx-odr-p type_5 type_6 BLK
        size <integer_cst 0x7fffea1d35b8 constant 96>
        unit-size <integer_cst 0x7fffea1d35d0 constant 12>
        align:32 warn_if_not_align:0 symtab:0 alias-set 17 canonical-type
0x7fffea1b5dc8
        fields <function_decl 0x7fffea213800 operator= type <method_type
0x7fffea212d20>
            addressable used nothrow public static weak autoinline decl_3
decl_5 QI defer-output pr98282.ii:60:8 align:16 warn_if_not_align:0 context
<record_type 0x7fffea1b5dc8 h> initial <block 0x7fffea1e3600> result
<result_decl 0x7fffea1fa438 D.3000>
            full-name "h& h::operator=(h&&)" chain <function_decl
0x7fffea213700 operator=>> context <translation_unit_decl 0x7fffea04e168
pr98282.ii>
        full-name "struct h"
        needs-constructor X() X(constX&) this=(X&) n_parents=0 use_template=0
interface-unknown
        pointer_to_this <pointer_type 0x7fffea1bf000> reference_to_this
<reference_type 0x7fffea2120a8> chain <type_decl 0x7fffea1be000 h>>
    public unsigned type_6 DI
    size <integer_cst 0x7fffea041eb8 type <integer_type 0x7fffea05f0a8
bitsizetype> constant 64>
    unit-size <integer_cst 0x7fffea041ed0 type <integer_type 0x7fffea05f000
sizetype> constant 8>
    align:64 warn_if_not_align:0 symtab:0 alias-set 1 canonical-type
0x7fffea1bf000>

And the alias-set 1 means get_alias_set on the second VCE returns 1.

I think at least for the VCE of constant case (but VCE of SSA_NAME etc. would
as well) we shouldn't consider alias set at all.

So, one possible fix is:
--- gcc/tree-ssa-pre.c.jj       2020-11-30 10:48:31.000000000 +0100
+++ gcc/tree-ssa-pre.c  2020-12-15 10:51:51.061206572 +0100
@@ -4176,13 +4176,17 @@ compute_avail (void)
                             && ref2->opcode != MEM_REF
                             && ref2 != &operands[0])
                        --ref2;
-                     if ((ref1->opcode == TARGET_MEM_REF
-                          || ref1->opcode == MEM_REF)
-                         && (TYPE_ALIGN (ref1->type)
-                             > TYPE_ALIGN (ref2->type)))
-                       ref1->type
-                         = build_aligned_type (ref1->type,
-                                               TYPE_ALIGN (ref2->type));
+                     if (ref1->opcode == TARGET_MEM_REF
+                         || ref1->opcode == MEM_REF)
+                       {
+                         if (TYPE_ALIGN (ref1->type)
+                             > TYPE_ALIGN (ref2->type))
+                           ref1->type
+                             = build_aligned_type (ref1->type,
+                                                   TYPE_ALIGN (ref2->type));
+                       }
+                     else
+                       set = ref->set;
                      /* TBAA behavior is an obvious part so make sure
                         that the hashtable one covers this as well
                         by adjusting the ref alias set and its base.  */
i.e. ignore the alias set if there is no MEM_REF or TARGET_MEM_REF, after all,
the code below it relies on the alias sets to be equal except for MEM_REF or
TARGET_MEM_REF.

Another possibility would be for ao_ref_alias_set and ao_ref_base_alias_set to
return 0 if they aren't really memory reads, such as VCE of constant or VCE of
a SSA_NAME.

And yet another would be not to call ao_ref_alias_set at all in the
compute_avail code for such references, but do something different.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug tree-optimization/98282] [8/9/10/11 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (4 preceding siblings ...)
  2020-12-15 10:05 ` jakub at gcc dot gnu.org
@ 2020-12-16  9:03 ` rguenth at gcc dot gnu.org
  2020-12-16  9:14 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-12-16  9:03 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Will have a look after vacation.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug tree-optimization/98282] [8/9/10/11 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (5 preceding siblings ...)
  2020-12-16  9:03 ` [Bug tree-optimization/98282] " rguenth at gcc dot gnu.org
@ 2020-12-16  9:14 ` jakub at gcc dot gnu.org
  2021-01-04 10:40 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-16  9:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49775
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49775&action=edit
gcc11-pr98282.patch

This version passed bootstrap/regtest and I'll use it in our tree temporarily
until you get back from vacation.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug tree-optimization/98282] [8/9/10/11 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (6 preceding siblings ...)
  2020-12-16  9:14 ` jakub at gcc dot gnu.org
@ 2021-01-04 10:40 ` rguenth at gcc dot gnu.org
  2021-01-04 11:59 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-04 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the classification as VN_REFERENCE is wrong.  We're doing

              case tcc_reference:
                /* VOP-less references can go through unary case.  */
                if ((code == REALPART_EXPR
                     || code == IMAGPART_EXPR
                     || code == VIEW_CONVERT_EXPR
                     || code == BIT_FIELD_REF)
                    && TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
                  return VN_NARY;

but do not expect "unfolded" constants to appear.  We're also classifying
&foo as VN_CONSTANT but I guess classifying V_C_E<0> as VN_CONSTANT will
have too many ripple-down effects.

Now another question is of course why we do not fold this conversion.

diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index e0a75636352..b39859dbc1b 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -543,7 +543,8 @@ vn_get_stmt_kind (gimple *stmt)
                     || code == IMAGPART_EXPR
                     || code == VIEW_CONVERT_EXPR
                     || code == BIT_FIELD_REF)
-                   && TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
+                   && (TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME
+                       || is_gimple_min_invariant (TREE_OPERAND (rhs1, 0))))
                  return VN_NARY;

                /* Fallthrough.  */

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug tree-optimization/98282] [8/9/10/11 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (7 preceding siblings ...)
  2021-01-04 10:40 ` rguenth at gcc dot gnu.org
@ 2021-01-04 11:59 ` cvs-commit at gcc dot gnu.org
  2021-01-04 12:05 ` [Bug tree-optimization/98282] [8/9/10 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-04 11:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:13b80a7d1b9b712651f5ece589634a6e57c26362

commit r11-6440-g13b80a7d1b9b712651f5ece589634a6e57c26362
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Jan 4 11:40:40 2021 +0100

    tree-optimization/98282 - classify V_C_E<constant> as nary

    This avoids running into memory reference code in compute_avail by
    properly classifying unfolded reference trees on constants.

    2021-01-04  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/98282
            * tree-ssa-sccvn.c (vn_get_stmt_kind): Classify tcc_reference on
            invariants as VN_NARY.

            * g++.dg/opt/pr98282.C: New testcase.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug tree-optimization/98282] [8/9/10 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (8 preceding siblings ...)
  2021-01-04 11:59 ` cvs-commit at gcc dot gnu.org
@ 2021-01-04 12:05 ` rguenth at gcc dot gnu.org
  2021-01-12 14:51 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-04 12:05 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10/11 Regression]      |[8/9/10 Regression]
                   |Segmentation fault when     |Segmentation fault when
                   |compiling with optimization |compiling with optimization
                   |>= 2                        |>= 2
      Known to work|                            |11.0

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug tree-optimization/98282] [8/9/10 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (9 preceding siblings ...)
  2021-01-04 12:05 ` [Bug tree-optimization/98282] [8/9/10 " rguenth at gcc dot gnu.org
@ 2021-01-12 14:51 ` cvs-commit at gcc dot gnu.org
  2021-03-17  9:35 ` [Bug tree-optimization/98282] [8/9 " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-12 14:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:edb7dbc25de455300ce066a2ebe728256ea46e3a

commit r10-9262-gedb7dbc25de455300ce066a2ebe728256ea46e3a
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Jan 4 11:40:40 2021 +0100

    tree-optimization/98282 - classify V_C_E<constant> as nary

    This avoids running into memory reference code in compute_avail by
    properly classifying unfolded reference trees on constants.

    2021-01-04  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/98282
            * tree-ssa-sccvn.c (vn_get_stmt_kind): Classify tcc_reference on
            invariants as VN_NARY.

            * g++.dg/opt/pr98282.C: New testcase.

    (cherry picked from commit 13b80a7d1b9b712651f5ece589634a6e57c26362)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug tree-optimization/98282] [8/9 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (10 preceding siblings ...)
  2021-01-12 14:51 ` cvs-commit at gcc dot gnu.org
@ 2021-03-17  9:35 ` cvs-commit at gcc dot gnu.org
  2021-03-17 10:20 ` [Bug tree-optimization/98282] [8 " cvs-commit at gcc dot gnu.org
  2021-03-17 10:21 ` rguenth at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-17  9:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:9bb84bd30dcfcdc12f69b148d4dcf8f2e3fe8046

commit r9-9289-g9bb84bd30dcfcdc12f69b148d4dcf8f2e3fe8046
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Jan 4 11:40:40 2021 +0100

    tree-optimization/98282 - classify V_C_E<constant> as nary

    This avoids running into memory reference code in compute_avail by
    properly classifying unfolded reference trees on constants.

    2021-01-04  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/98282
            * tree-ssa-sccvn.c (vn_get_stmt_kind): Classify tcc_reference on
            invariants as VN_NARY.

            * g++.dg/opt/pr98282.C: New testcase.

    (cherry picked from commit edb7dbc25de455300ce066a2ebe728256ea46e3a)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug tree-optimization/98282] [8 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (11 preceding siblings ...)
  2021-03-17  9:35 ` [Bug tree-optimization/98282] [8/9 " cvs-commit at gcc dot gnu.org
@ 2021-03-17 10:20 ` cvs-commit at gcc dot gnu.org
  2021-03-17 10:21 ` rguenth at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-17 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:55bac5c2824dcb4bdae5b309b2b2a26703f273f0

commit r8-10800-g55bac5c2824dcb4bdae5b309b2b2a26703f273f0
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Jan 4 11:40:40 2021 +0100

    tree-optimization/98282 - classify V_C_E<constant> as nary

    This avoids running into memory reference code in compute_avail by
    properly classifying unfolded reference trees on constants.

    2021-01-04  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/98282
            * tree-ssa-sccvn.c (vn_get_stmt_kind): Classify tcc_reference on
            invariants as VN_NARY.

            * g++.dg/opt/pr98282.C: New testcase.

    (cherry picked from commit edb7dbc25de455300ce066a2ebe728256ea46e3a)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug tree-optimization/98282] [8 Regression] Segmentation fault when compiling with optimization >= 2
  2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
                   ` (12 preceding siblings ...)
  2021-03-17 10:20 ` [Bug tree-optimization/98282] [8 " cvs-commit at gcc dot gnu.org
@ 2021-03-17 10:21 ` rguenth at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-03-17 10:21 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
      Known to work|                            |8.4.1
             Status|ASSIGNED                    |RESOLVED
      Known to fail|                            |8.4.0

--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-03-17 10:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 19:25 [Bug c++/98282] New: Segmentation fault when compiling with optimization >= 2 bengilgit at gmail dot com
2020-12-14 19:33 ` [Bug c++/98282] " bengilgit at gmail dot com
2020-12-14 22:06 ` jakub at gcc dot gnu.org
2020-12-14 23:30 ` jakub at gcc dot gnu.org
2020-12-14 23:34 ` [Bug c++/98282] [8/9/10/11 Regression] " jakub at gcc dot gnu.org
2020-12-15 10:05 ` jakub at gcc dot gnu.org
2020-12-16  9:03 ` [Bug tree-optimization/98282] " rguenth at gcc dot gnu.org
2020-12-16  9:14 ` jakub at gcc dot gnu.org
2021-01-04 10:40 ` rguenth at gcc dot gnu.org
2021-01-04 11:59 ` cvs-commit at gcc dot gnu.org
2021-01-04 12:05 ` [Bug tree-optimization/98282] [8/9/10 " rguenth at gcc dot gnu.org
2021-01-12 14:51 ` cvs-commit at gcc dot gnu.org
2021-03-17  9:35 ` [Bug tree-optimization/98282] [8/9 " cvs-commit at gcc dot gnu.org
2021-03-17 10:20 ` [Bug tree-optimization/98282] [8 " cvs-commit at gcc dot gnu.org
2021-03-17 10:21 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).