From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 45C42384AB5B; Fri, 3 May 2024 09:01:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45C42384AB5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714726865; bh=AjmxnR5nyXhQXg0DTgKd4X+MBxDnBaRtVJO1JIG7rX0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=X6LbFPLk85sDf3SnuMbIcG+xi2bQRype7PXRu0QGRaqUgKXUnipXu91cue3r1+76z 0mXN9az13iUqc8/pEypHItQhszkWf76r1aaqglb++vmoH5MsapICzsLxAmRs6FqCk+ d9c1LjPQD1d7Kvl/k46kAqNa1UBu4WJW0gzZQBiY= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114931] [14/15 regression] ICE in get_alias_set when building tcl with -std=c23 Date: Fri, 03 May 2024 09:01:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114931 --- Comment #13 from Richard Biener --- (In reply to Jakub Jelinek from comment #12) > Anyway, such changes are a partial shift towards the model to update deri= ved > 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) =3D 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 =3D type_hash_canon_hash (t); > t =3D type_hash_canon (hash, t); >=20=20 > - /* Set up the canonical type. */ > - any_structural_p =3D TYPE_STRUCTURAL_EQUALITY_P (value_type); > - any_noncanonical_p =3D TYPE_CANONICAL (value_type) !=3D value_type; > - canon_argtypes =3D 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) =3D build_function_type (TYPE_CANONICAL (value_ty= pe), > - canon_argtypes); > + if (TYPE_CANONICAL (t) =3D=3D t) > + { > + /* Set up the canonical type. */ > + any_structural_p =3D TYPE_STRUCTURAL_EQUALITY_P (value_type); > + any_noncanonical_p =3D TYPE_CANONICAL (value_type) !=3D value_type; > + canon_argtypes =3D 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) > + =3D 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); > + } > + } >=20=20 > if (!COMPLETE_TYPE_P (t)) > layout_type (t);=