public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23
@ 2024-05-03  2:37 sjames at gcc dot gnu.org
  2024-05-03  2:38 ` [Bug rtl-optimization/114931] " sjames at gcc dot gnu.org
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-05-03  2:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114931
           Summary: ICE in get_alias_set when building tcl with -std=c23
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

Created attachment 58094
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58094&action=edit
tclStubLib.i.xz

```
# gcc -c tclStubLib.i -std=c23
during RTL pass: expand
/var/tmp/portage/dev-lang/tcl-8.6.14/work/tcl8.6.14/generic/tclStubLib.c: In
function ‘Tcl_InitStubs’:
/var/tmp/portage/dev-lang/tcl-8.6.14/work/tcl8.6.14/generic/tclStubLib.c:70:31:
internal compiler error: in get_alias_set, at alias.cc:954
   70 |     if (!stubsPtr || (stubsPtr->magic != TCL_STUB_MAGIC)) {
      |                       ~~~~~~~~^~~~~~~
0x55a6e9af0586 get_alias_set(tree_node*)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/alias.cc:954
0x55a6eb2865eb record_component_aliases(tree_node*, int)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/alias.cc:1306
0x55a6eb26bcdc record_component_aliases(tree_node*)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/alias.cc:1346
0x55a6eb26bcdc get_alias_set(tree_node*)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/alias.cc:1151
0x55a6eb28ee06 set_mem_attributes_minus_bitpos(rtx_def*, tree_node*, int,
poly_int<1u, long>)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/emit-rtl.cc:1976
0x55a6eb63832b set_mem_attributes(rtx_def*, tree_node*, int)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/emit-rtl.cc:2181
0x55a6eb63832b expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/expr.cc:11731
0x55a6eb638c29 expand_expr_real(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/expr.cc:9443
0x55a6eb638c29 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/expr.cc:11949
0x55a6eb63ba80 expand_expr_real(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/expr.cc:9443
0x55a6eb63ba80 store_expr(tree_node*, rtx_def*, int, bool, bool)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/expr.cc:6743
0x55a6eb6368a2 expand_assignment(tree_node*, tree_node*, bool)
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/expr.cc:6464
0x55a6eb631a1c expand_gimple_stmt
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/cfgexpand.cc:4077
0x55a6eb631a1c expand_gimple_basic_block
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/cfgexpand.cc:6133
0x55a6eb5daf76 execute
       
/usr/src/debug/sys-devel/gcc-14.0.1_pre20240430/gcc-14.1.0-RC-20240430/gcc/cfgexpand.cc:6872
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
```

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

* [Bug rtl-optimization/114931] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
@ 2024-05-03  2:38 ` sjames at gcc dot gnu.org
  2024-05-03  2:43 ` [Bug c/114931] " pinskia at gcc dot gnu.org
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-05-03  2:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
With -Wuninitialized, it dies in an earlier pass:
```
# gcc -c tclStubLib.i -std=c23 -Wuninitialized
during GIMPLE pass: early_uninit
/var/tmp/portage/dev-lang/tcl-8.6.14/work/tcl8.6.14/generic/tclStubLib.c: In
function ‘Tcl_InitStubs’:
/var/tmp/portage/dev-lang/tcl-8.6.14/work/tcl8.6.14/generic/tclStubLib.c:119:1:
internal compiler error: in get_alias_set, at alias.cc:954
  119 | }
      | ^
[...]
```

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

* [Bug c/114931] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
  2024-05-03  2:38 ` [Bug rtl-optimization/114931] " sjames at gcc dot gnu.org
@ 2024-05-03  2:43 ` pinskia at gcc dot gnu.org
  2024-05-03  2:52 ` pinskia at gcc dot gnu.org
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-03  2:43 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=114927

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect you find it is a similar pattern as the reduced testcase of pr 114927
...

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

* [Bug c/114931] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
  2024-05-03  2:38 ` [Bug rtl-optimization/114931] " sjames at gcc dot gnu.org
  2024-05-03  2:43 ` [Bug c/114931] " pinskia at gcc dot gnu.org
@ 2024-05-03  2:52 ` pinskia at gcc dot gnu.org
  2024-05-03  3:10 ` sjames at gcc dot gnu.org
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-03  2:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
It will involve the struct TclStubs too. I suspect it does not have its
aliasing set correctly.

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

* [Bug c/114931] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-05-03  2:52 ` pinskia at gcc dot gnu.org
@ 2024-05-03  3:10 ` sjames at gcc dot gnu.org
  2024-05-03  6:34 ` [Bug c/114931] [14/15 regression] " rguenth at gcc dot gnu.org
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-05-03  3:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Sam James <sjames at gcc dot gnu.org> ---
```
struct Tcl_Obj;
void(Tcl_FreeInternalRepProc)(struct Tcl_Obj *);
typedef struct Tcl_Obj {
} Tcl_Obj;
struct {
  void (*tclFreeObj)(Tcl_Obj *);
} Tcl_InitStubs;
```

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-05-03  3:10 ` sjames at gcc dot gnu.org
@ 2024-05-03  6:34 ` rguenth at gcc dot gnu.org
  2024-05-03  7:11 ` rguenth at gcc dot gnu.org
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-03  6:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
This means a canonical type has TYPE_STUCTURAL_EQUALITY_P set but a canonical
type should have itself as canonical type.

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-05-03  6:34 ` [Bug c/114931] [14/15 regression] " rguenth at gcc dot gnu.org
@ 2024-05-03  7:11 ` rguenth at gcc dot gnu.org
  2024-05-03  7:16 ` rguenth at gcc dot gnu.org
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-03  7:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
When we build the pointer type there's already

(gdb) p to_type
$18 = <function_type 0x7ffff6b7d930>
(gdb) p to_type->type_common.canonical 
$15 = <function_type 0x7ffff6b7d690>
(gdb) p to_type->type_common.canonical->type_common.canonical 
$17 = <tree 0x0>

the interesting bit is that build_function_type when doing

  else if (any_noncanonical_p)
    TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
                                              canon_argtypes);

to build the canonical type gets an already present function type through
type_has_canon that has TYPE_STRUCTURAL_EQUALITY_P set.  So somehow
it is inconsistent with itself here - at the time we build that function
type maybe_canonicalize_argtypes sets any_structural_p so it seems we
set TYPE_CANONICAL "late" on some types?  In particular both the
pointer and struct type have TYPE_STRUCTURAL_EQUALITY_P set.

It might be tempting to do the following which fixes the testcase but then
this simply means we'll never find types with structural equality in the
hash (note we insert those when they still have themselves as canonical type).
In some sense TYPE_STRUCTURAL_EQUALITY_P means we have not properly unified
types so unifying even less shouldn't make it much worse.  It would be still
interesting to see why we build the function type with original "incomplete"
argument types.

diff --git a/gcc/tree.cc b/gcc/tree.cc
index 83f3bf306af..35bb7713e1f 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -6109,6 +6109,10 @@ type_cache_hasher::equal (type_hash *a, type_hash *b)
          || TYPE_MODE (a->type) != TYPE_MODE (b->type)))
     return false;

+  if (TYPE_STRUCTURAL_EQUALITY_P (a->type)
+      != TYPE_STRUCTURAL_EQUALITY_P (b->type))
+    return false;
+
   switch (TREE_CODE (a->type))
     {
     case VOID_TYPE:


debugging patch:

diff --git a/gcc/tree.cc b/gcc/tree.cc
index 83f3bf306af..35bb7713e1f 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -7520,8 +7524,11 @@ build_function_type (tree value_type, tree arg_types,
   if (any_structural_p)
     SET_TYPE_STRUCTURAL_EQUALITY (t);
   else if (any_noncanonical_p)
+    {
     TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
                                              canon_argtypes);
+    gcc_assert (TYPE_CANONICAL (TYPE_CANONICAL (t)) == TYPE_CANONICAL (t));
+    }

   if (!COMPLETE_TYPE_P (t))
     layout_type (t);

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-05-03  7:11 ` rguenth at gcc dot gnu.org
@ 2024-05-03  7:16 ` rguenth at gcc dot gnu.org
  2024-05-03  7:25 ` rguenth at gcc dot gnu.org
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-03  7:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
I'll note that seeing code like the following which possibly mutates existing
hash entries looks quite broken.  But of course type_hash_canon is a fragile
bit of code (well, it shouldn't ...).  To me it looks like we should compute
and set the canonical type first and _then_ do the hash lookup (which should
include the canonical type).  And I'd make type_hash_canon take a tree * to
modify, making its return value a bool whether we found an existing type so
we can simply do if (type_hash_canon (hash, &t)) { ggc_free (orig_t); return t;
}

tree
build_function_type (tree value_type, tree arg_types,
                     bool no_named_args_stdarg_p)
{
  tree t;
  inchash::hash hstate;
  bool any_structural_p, any_noncanonical_p;
  tree canon_argtypes;

  gcc_assert (arg_types != error_mark_node);

  if (TREE_CODE (value_type) == FUNCTION_TYPE)
    {
      error ("function return type cannot be function");
      value_type = integer_type_node;
    }

  /* Make a node of the sort we want.  */
  t = make_node (FUNCTION_TYPE);
  TREE_TYPE (t) = value_type;
  TYPE_ARG_TYPES (t) = arg_types;
  if (no_named_args_stdarg_p)
    {
      gcc_assert (arg_types == NULL_TREE);
      TYPE_NO_NAMED_ARGS_STDARG_P (t) = 1;
    }

  /* If we already have such a type, use the old one.  */
  hashval_t hash = type_hash_canon_hash (t);
  t = type_hash_canon (hash, t);

  /* Set up the canonical type. */
  any_structural_p   = TYPE_STRUCTURAL_EQUALITY_P (value_type);
  any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
  canon_argtypes = maybe_canonicalize_argtypes (arg_types,
                                                &any_structural_p,
                                                &any_noncanonical_p);
  if (any_structural_p)
    SET_TYPE_STRUCTURAL_EQUALITY (t);
  else if (any_noncanonical_p)
    TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
                                              canon_argtypes);

  if (!COMPLETE_TYPE_P (t))
    layout_type (t);
  return t;
}

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-05-03  7:16 ` rguenth at gcc dot gnu.org
@ 2024-05-03  7:25 ` rguenth at gcc dot gnu.org
  2024-05-03  7:41 ` jakub at gcc dot gnu.org
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-03  7:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
So a real fix might look like the following (requiring changes in all other
type builders to first set/compute the canonical type of course).

diff --git a/gcc/tree.cc b/gcc/tree.cc
index 83f3bf306af..5dfe12f0e96 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -6012,6 +6012,9 @@ type_hash_canon_hash (tree type)

   hstate.add_int (TREE_CODE (type));

+  if (TYPE_CANONICAL (type))
+    hstate.add_object (TYPE_HASH (TYPE_CANONICAL (type)));
+
   if (TREE_TYPE (type))
     hstate.add_object (TYPE_HASH (TREE_TYPE (type)));

@@ -6109,6 +6112,9 @@ type_cache_hasher::equal (type_hash *a, type_hash *b)
          || TYPE_MODE (a->type) != TYPE_MODE (b->type)))
     return false;

+  if (TYPE_CANONICAL (a->type) != TYPE_CANONICAL (b->type))
+    return false;
+
   switch (TREE_CODE (a->type))
     {
     case VOID_TYPE:
@@ -7507,10 +7513,6 @@ build_function_type (tree value_type, tree arg_types,
       TYPE_NO_NAMED_ARGS_STDARG_P (t) = 1;
     }

-  /* If we already have such a type, use the old one.  */
-  hashval_t hash = type_hash_canon_hash (t);
-  t = type_hash_canon (hash, t);
-
   /* Set up the canonical type. */
   any_structural_p   = TYPE_STRUCTURAL_EQUALITY_P (value_type);
   any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
@@ -7523,6 +7525,16 @@ build_function_type (tree value_type, tree arg_types,
     TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
                                              canon_argtypes);

+  /* If we already have such a type, use the old one.  */
+  hashval_t hash = type_hash_canon_hash (t);
+  t = type_hash_canon (hash, t);
+
   if (!COMPLETE_TYPE_P (t))
     layout_type (t);
   return t;

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2024-05-03  7:25 ` rguenth at gcc dot gnu.org
@ 2024-05-03  7:41 ` jakub at gcc dot gnu.org
  2024-05-03  7:56 ` rguenth at gcc dot gnu.org
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-05-03  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Do you really need to hash it on TYPE_CANON, rather than just on whether the
type is
TYPE_STRUCTURAL_EQUALITY_P or not?
I'm worried that always computing the TYPE_CANON before calling type_hash_canon
is going to be quite expensive, while just figuring out if it should have
TYPE_STRUCTURAL_EQUALITY_P or not should be cheaper.  If it should have
TYPE_STRUCTURAL_EQUALITY_P, we'd SET_TYPE_STRUCTURAL_EQUALITY, otherwise set
TYPE_CANONICAL (t) = t; (I think that is what we generally get from make_node),
look up
and recompute TYPE_CANONICAL if TYPE_CANONICAL (t) == t.

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2024-05-03  7:41 ` jakub at gcc dot gnu.org
@ 2024-05-03  7:56 ` rguenth at gcc dot gnu.org
  2024-05-03  8:22 ` rguenth at gcc dot gnu.org
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-03  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #9)
> Do you really need to hash it on TYPE_CANON, rather than just on whether the
> type is
> TYPE_STRUCTURAL_EQUALITY_P or not?

It's enough for the testcases here, I didn't try to convince myself it's safe
but of course it's better than what we do right now.  So we can try that as
well.

> I'm worried that always computing the TYPE_CANON before calling
> type_hash_canon is going to be quite expensive, while just figuring out if
> it should have TYPE_STRUCTURAL_EQUALITY_P or not should be cheaper.  If it
> should have
> TYPE_STRUCTURAL_EQUALITY_P, we'd SET_TYPE_STRUCTURAL_EQUALITY, otherwise set
> TYPE_CANONICAL (t) = t; (I think that is what we generally get from
> make_node), look up
> and recompute TYPE_CANONICAL if TYPE_CANONICAL (t) == t.

I'd like to make it obvious at least that we only alter TYPE_CANONICAL if
we were the one building 't' in the first place.  The layouting of types
also seems to be redundant now as that's done by type_hash_canon.

Luckily there are not too many callers.

It's a bit late for 14.1, so we can refactor things on trunk and then backport
later.

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2024-05-03  7:56 ` rguenth at gcc dot gnu.org
@ 2024-05-03  8:22 ` rguenth at gcc dot gnu.org
  2024-05-03  8:25 ` jakub at gcc dot gnu.org
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-03  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2024-05-03

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Let me try to come up with a complete patch.

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2024-05-03  8:22 ` rguenth at gcc dot gnu.org
@ 2024-05-03  8:25 ` jakub at gcc dot gnu.org
  2024-05-03  9:01 ` rguenth at gcc dot gnu.org
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-05-03  8:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Anyway, such changes are a partial shift towards the model to update derived
types which you said you don't want; it doesn't actually update them, but
basically forces new types after the base type(s) is/are finalized.

Another possibility might be simply in all the spots where we set
TYPE_CANONICAL (t) = something; to add if (TYPE_STRUCTURAL_EQUALITY_P
(TYPE_CANONICAL (t))) SET_TYPE_STRUCTURAL_EQUALITY (t);

On the build_function_type it could be
--- gcc/tree.cc.jj      2024-04-16 09:56:16.463008446 +0200
+++ gcc/tree.cc 2024-05-03 10:21:04.119086667 +0200
@@ -7511,17 +7511,25 @@ build_function_type (tree value_type, tr
   hashval_t hash = type_hash_canon_hash (t);
   t = type_hash_canon (hash, t);

-  /* Set up the canonical type. */
-  any_structural_p   = TYPE_STRUCTURAL_EQUALITY_P (value_type);
-  any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
-  canon_argtypes = maybe_canonicalize_argtypes (arg_types,
-                                               &any_structural_p,
-                                               &any_noncanonical_p);
-  if (any_structural_p)
-    SET_TYPE_STRUCTURAL_EQUALITY (t);
-  else if (any_noncanonical_p)
-    TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
-                                             canon_argtypes);
+  if (TYPE_CANONICAL (t) == t)
+    {
+      /* Set up the canonical type. */
+      any_structural_p = TYPE_STRUCTURAL_EQUALITY_P (value_type);
+      any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
+      canon_argtypes = maybe_canonicalize_argtypes (arg_types,
+                                                   &any_structural_p,
+                                                   &any_noncanonical_p);
+      if (any_structural_p)
+       SET_TYPE_STRUCTURAL_EQUALITY (t);
+      else if (any_noncanonical_p)
+       {
+         TYPE_CANONICAL (t)
+           = build_function_type (TYPE_CANONICAL (value_type),
+                                  canon_argtypes);
+         if (TYPE_STRUCTURAL_EQUALITY_P (TYPE_CANONICAL (t)))
+           SET_TYPE_STRUCTURAL_EQUALITY (t);
+       }
+    }

   if (!COMPLETE_TYPE_P (t))
     layout_type (t);

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (11 preceding siblings ...)
  2024-05-03  8:25 ` jakub at gcc dot gnu.org
@ 2024-05-03  9:01 ` rguenth at gcc dot gnu.org
  2024-05-03  9:05 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-03  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #12)
> Anyway, such changes are a partial shift towards the model to update derived
> types which you said you don't want; it doesn't actually update them, but
> basically forces new types after the base type(s) is/are finalized.

Yes, I was wondering if when we make TYPE_STRUCTURAL_EQUALITY_P part of
the hash we're papering over the issue that we have recorded equal types
we didn't mark for structural compare.  Though that would only be a missed
optimization I think (setting TYPE_STRUCTURAL_EQUALITY_P is).

> Another possibility might be simply in all the spots where we set
> TYPE_CANONICAL (t) = something; to add if (TYPE_STRUCTURAL_EQUALITY_P
> (TYPE_CANONICAL (t))) SET_TYPE_STRUCTURAL_EQUALITY (t);

But if TYPE_STRUCTURAL_EQUALITY_P (TYPE_CANONICAL (t)) then that canonical
type is broken.  We should avoid (at all cost) creating such a type.

> On the build_function_type it could be
> --- gcc/tree.cc.jj	2024-04-16 09:56:16.463008446 +0200
> +++ gcc/tree.cc	2024-05-03 10:21:04.119086667 +0200
> @@ -7511,17 +7511,25 @@ build_function_type (tree value_type, tr
>    hashval_t hash = type_hash_canon_hash (t);
>    t = type_hash_canon (hash, t);
>  
> -  /* Set up the canonical type. */
> -  any_structural_p   = TYPE_STRUCTURAL_EQUALITY_P (value_type);
> -  any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
> -  canon_argtypes = maybe_canonicalize_argtypes (arg_types,
> -						&any_structural_p,
> -						&any_noncanonical_p);
> -  if (any_structural_p)
> -    SET_TYPE_STRUCTURAL_EQUALITY (t);
> -  else if (any_noncanonical_p)
> -    TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
> -					      canon_argtypes);
> +  if (TYPE_CANONICAL (t) == t)
> +    {
> +      /* Set up the canonical type. */
> +      any_structural_p = TYPE_STRUCTURAL_EQUALITY_P (value_type);
> +      any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
> +      canon_argtypes = maybe_canonicalize_argtypes (arg_types,
> +						    &any_structural_p,
> +						    &any_noncanonical_p);
> +      if (any_structural_p)
> +	SET_TYPE_STRUCTURAL_EQUALITY (t);
> +      else if (any_noncanonical_p)
> +	{
> +	  TYPE_CANONICAL (t)
> +	    = build_function_type (TYPE_CANONICAL (value_type),
> +				   canon_argtypes);

we shouldn't get a structual equality type here when !any_structural_p

Yes, ensuring this within type_hash_canon only papers over the issue in
different ways (to some extent).  But this is how things are.

I guess another option might be to have the FE set TYPE_STRUCTURAL_EQUALITY_P
on _all_ types that possibly get "finalized" only later and have a second
sweep over all those types after the unit is finished and recompute
TYPE_CANONICAL there, making sure to catch all derived types.  Like LTO
re-computes TYPE_CANONICAL.

> +	  if (TYPE_STRUCTURAL_EQUALITY_P (TYPE_CANONICAL (t)))
> +	    SET_TYPE_STRUCTURAL_EQUALITY (t);
> +	}
> +    }
>  
>    if (!COMPLETE_TYPE_P (t))
>      layout_type (t);

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (12 preceding siblings ...)
  2024-05-03  9:01 ` rguenth at gcc dot gnu.org
@ 2024-05-03  9:05 ` rguenth at gcc dot gnu.org
  2024-05-03  9:50 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-03  9:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 58097
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58097&action=edit
patch I am testing

So I'm testing this.  It definitely will "split brain" at the point the FE
mucks with TYPE_CANONICAL of any existing type (and it will break an existing
hash entry in the canonical type hash if it does so - looking it doesn't seem
to muck with
TYPE_CANONICAL of types that are possibly in the hash already though).

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (13 preceding siblings ...)
  2024-05-03  9:05 ` rguenth at gcc dot gnu.org
@ 2024-05-03  9:50 ` rguenth at gcc dot gnu.org
  2024-05-03 11:01 ` cvs-commit at gcc dot gnu.org
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-03  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 58098
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58098&action=edit
patch avoiding TYPE_CANONICAL tampering

This avoids messing with TYPE_CANONICAL on types already in the hash - it
doesn't fix the bug on its own but is a good thing anyway.

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (14 preceding siblings ...)
  2024-05-03  9:50 ` rguenth at gcc dot gnu.org
@ 2024-05-03 11:01 ` cvs-commit at gcc dot gnu.org
  2024-05-07  7:46 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-03 11:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from GCC 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:7a212ac678e13e0df5da2d090144b246a1262b64

commit r15-127-g7a212ac678e13e0df5da2d090144b246a1262b64
Author: Richard Biener <rguenther@suse.de>
Date:   Fri May 3 11:48:07 2024 +0200

    Avoid changing type in the type_hash_canon hash

    When building a type and type_hash_canon returns an existing type
    avoid changing it, in particular its TYPE_CANONICAL.

            PR middle-end/114931
            * tree.cc (build_array_type_1): Return early when type_hash_canon
            returned an older existing type.
            (build_function_type): Likewise.
            (build_method_type_directly): Likewise.
            (build_offset_type): Likewise.

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (15 preceding siblings ...)
  2024-05-03 11:01 ` cvs-commit at gcc dot gnu.org
@ 2024-05-07  7:46 ` rguenth at gcc dot gnu.org
  2024-05-07 11:05 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07  7:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |14.2

--- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.

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

* [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (16 preceding siblings ...)
  2024-05-07  7:46 ` rguenth at gcc dot gnu.org
@ 2024-05-07 11:05 ` cvs-commit at gcc dot gnu.org
  2024-05-07 11:07 ` [Bug c/114931] [14 " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-07 11:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from GCC 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:b09c2e9560648b0cf993c2ca9ad972c34e6bddfa

commit r15-271-gb09c2e9560648b0cf993c2ca9ad972c34e6bddfa
Author: Richard Biener <rguenther@suse.de>
Date:   Fri May 3 10:44:50 2024 +0200

    middle-end/114931 - type_hash_canon and structual equality types

    TYPE_STRUCTURAL_EQUALITY_P is part of our type system so we have
    to make sure to include that into the type unification done via
    type_hash_canon.  This requires the flag to be set before querying
    the hash which is the biggest part of the patch.

            PR middle-end/114931
    gcc/
            * tree.cc (type_hash_canon_hash): Hash TYPE_STRUCTURAL_EQUALITY_P.
            (type_cache_hasher::equal): Compare TYPE_STRUCTURAL_EQUALITY_P.
            (build_array_type_1): Set TYPE_STRUCTURAL_EQUALITY_P before
            probing with type_hash_canon.
            (build_function_type): Likewise.
            (build_method_type_directly): Likewise.
            (build_offset_type): Likewise.
            (build_complex_type): Likewise.
            * attribs.cc (build_type_attribute_qual_variant): Likewise.

    gcc/c-family/
            * c-common.cc (complete_array_type): Set TYPE_STRUCTURAL_EQUALITY_P
            before probing with type_hash_canon.

    gcc/testsuite/
            * gcc.dg/pr114931.c: New testcase.

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

* [Bug c/114931] [14 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (17 preceding siblings ...)
  2024-05-07 11:05 ` cvs-commit at gcc dot gnu.org
@ 2024-05-07 11:07 ` rguenth at gcc dot gnu.org
  2024-05-07 12:30 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07 11:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |15.0
           Priority|P3                          |P2
            Summary|[14/15 regression] ICE in   |[14 regression] ICE in
                   |get_alias_set when building |get_alias_set when building
                   |tcl with -std=c23           |tcl with -std=c23

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

* [Bug c/114931] [14 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (18 preceding siblings ...)
  2024-05-07 11:07 ` [Bug c/114931] [14 " rguenth at gcc dot gnu.org
@ 2024-05-07 12:30 ` rguenth at gcc dot gnu.org
  2024-05-07 18:10 ` sjames at gcc dot gnu.org
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07 12:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sezeroz at gmail dot com

--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 114973 has been marked as a duplicate of this bug. ***

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

* [Bug c/114931] [14 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (19 preceding siblings ...)
  2024-05-07 12:30 ` rguenth at gcc dot gnu.org
@ 2024-05-07 18:10 ` sjames at gcc dot gnu.org
  2024-05-15 16:09 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-05-07 18:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Sam James <sjames at gcc dot gnu.org> ---
*** Bug 114971 has been marked as a duplicate of this bug. ***

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

* [Bug c/114931] [14 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (20 preceding siblings ...)
  2024-05-07 18:10 ` sjames at gcc dot gnu.org
@ 2024-05-15 16:09 ` cvs-commit at gcc dot gnu.org
  2024-05-15 16:09 ` cvs-commit at gcc dot gnu.org
  2024-05-15 16:09 ` rguenth at gcc dot gnu.org
  23 siblings, 0 replies; 25+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-15 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:573e1df0ec8428e564c97af7c237a5e0c98c59bd

commit r14-10210-g573e1df0ec8428e564c97af7c237a5e0c98c59bd
Author: Richard Biener <rguenther@suse.de>
Date:   Fri May 3 11:48:07 2024 +0200

    Avoid changing type in the type_hash_canon hash

    When building a type and type_hash_canon returns an existing type
    avoid changing it, in particular its TYPE_CANONICAL.

            PR middle-end/114931
            * tree.cc (build_array_type_1): Return early when type_hash_canon
            returned an older existing type.
            (build_function_type): Likewise.
            (build_method_type_directly): Likewise.
            (build_offset_type): Likewise.

    (cherry picked from commit 7a212ac678e13e0df5da2d090144b246a1262b64)

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

* [Bug c/114931] [14 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (21 preceding siblings ...)
  2024-05-15 16:09 ` cvs-commit at gcc dot gnu.org
@ 2024-05-15 16:09 ` cvs-commit at gcc dot gnu.org
  2024-05-15 16:09 ` rguenth at gcc dot gnu.org
  23 siblings, 0 replies; 25+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-15 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:1d89cb43943e77d0bbb48fd5a58a352bdd3d82c7

commit r14-10211-g1d89cb43943e77d0bbb48fd5a58a352bdd3d82c7
Author: Richard Biener <rguenther@suse.de>
Date:   Fri May 3 10:44:50 2024 +0200

    middle-end/114931 - type_hash_canon and structual equality types

    TYPE_STRUCTURAL_EQUALITY_P is part of our type system so we have
    to make sure to include that into the type unification done via
    type_hash_canon.  This requires the flag to be set before querying
    the hash which is the biggest part of the patch.

            PR middle-end/114931
    gcc/
            * tree.cc (type_hash_canon_hash): Hash TYPE_STRUCTURAL_EQUALITY_P.
            (type_cache_hasher::equal): Compare TYPE_STRUCTURAL_EQUALITY_P.
            (build_array_type_1): Set TYPE_STRUCTURAL_EQUALITY_P before
            probing with type_hash_canon.
            (build_function_type): Likewise.
            (build_method_type_directly): Likewise.
            (build_offset_type): Likewise.
            (build_complex_type): Likewise.
            * attribs.cc (build_type_attribute_qual_variant): Likewise.

    gcc/c-family/
            * c-common.cc (complete_array_type): Set TYPE_STRUCTURAL_EQUALITY_P
            before probing with type_hash_canon.

    gcc/testsuite/
            * gcc.dg/pr114931.c: New testcase.

    (cherry picked from commit b09c2e9560648b0cf993c2ca9ad972c34e6bddfa)

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

* [Bug c/114931] [14 regression] ICE in get_alias_set when building tcl with -std=c23
  2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
                   ` (22 preceding siblings ...)
  2024-05-15 16:09 ` cvs-commit at gcc dot gnu.org
@ 2024-05-15 16:09 ` rguenth at gcc dot gnu.org
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-15 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
      Known to fail|                            |14.1.0

--- Comment #23 from Richard Biener <rguenth at gcc dot gnu.org> ---
Should be fixed also on the branch now.

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

end of thread, other threads:[~2024-05-15 16:09 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-03  2:37 [Bug rtl-optimization/114931] New: ICE in get_alias_set when building tcl with -std=c23 sjames at gcc dot gnu.org
2024-05-03  2:38 ` [Bug rtl-optimization/114931] " sjames at gcc dot gnu.org
2024-05-03  2:43 ` [Bug c/114931] " pinskia at gcc dot gnu.org
2024-05-03  2:52 ` pinskia at gcc dot gnu.org
2024-05-03  3:10 ` sjames at gcc dot gnu.org
2024-05-03  6:34 ` [Bug c/114931] [14/15 regression] " rguenth at gcc dot gnu.org
2024-05-03  7:11 ` rguenth at gcc dot gnu.org
2024-05-03  7:16 ` rguenth at gcc dot gnu.org
2024-05-03  7:25 ` rguenth at gcc dot gnu.org
2024-05-03  7:41 ` jakub at gcc dot gnu.org
2024-05-03  7:56 ` rguenth at gcc dot gnu.org
2024-05-03  8:22 ` rguenth at gcc dot gnu.org
2024-05-03  8:25 ` jakub at gcc dot gnu.org
2024-05-03  9:01 ` rguenth at gcc dot gnu.org
2024-05-03  9:05 ` rguenth at gcc dot gnu.org
2024-05-03  9:50 ` rguenth at gcc dot gnu.org
2024-05-03 11:01 ` cvs-commit at gcc dot gnu.org
2024-05-07  7:46 ` rguenth at gcc dot gnu.org
2024-05-07 11:05 ` cvs-commit at gcc dot gnu.org
2024-05-07 11:07 ` [Bug c/114931] [14 " rguenth at gcc dot gnu.org
2024-05-07 12:30 ` rguenth at gcc dot gnu.org
2024-05-07 18:10 ` sjames at gcc dot gnu.org
2024-05-15 16:09 ` cvs-commit at gcc dot gnu.org
2024-05-15 16:09 ` cvs-commit at gcc dot gnu.org
2024-05-15 16:09 ` 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).