From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 42EF8385841F; Mon, 22 Jan 2024 09:38:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42EF8385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705916329; bh=pED0sULR6mQirONWiuUiNOblOrWl0TFATOZfEpcrqkk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Gy4mjc07BX60ouiAUGiYmC8l0dkkEZHj94G66SSZK4qMkeGEO8nL4O5OlWM5uG7gJ 2ZEH6M8JpkmegR8n4DDa+rJ3zGI4HRNgSCae+Mi47D9j8F+eqZp9U28Fk5El6qkfcu 6WbwuP1fttKVN13kY1+KapvYEOXbWwTMOjiK+G5M= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/113520] ICE with mismatched types with LTO (tree check: expected array_type, have integer_type in array_ref_low_bound) Date: Mon, 22 Jan 2024 09:38:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: lto X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on component everconfirmed bug_status cc keywords 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=3D113520 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2024-01-22 Component|tree-optimization |ipa Ever confirmed|0 |1 Status|UNCONFIRMED |NEW CC| |hubicka at gcc dot gnu.org, | |jamborm at gcc dot gnu.org, | |rguenth at gcc dot gnu.org Keywords| |lto --- Comment #6 from Richard Biener --- Hmm, we are supposed to "handle" this during in-streaming. This seems to w= ork but then for some reason it gets fiddled with again... Ah, so this is reading of IPA CP summaries where it seems that we do not apply these "tricks", gimple-streamer-out.cc has /* Wrap all uses of non-automatic variables inside MEM_REFs so that we do not have to deal with type mismatches on merged symbols during IL read in. The first operand of GIMPLE_DEBUG must be a decl, not MEM_REF, though. */ if (!flag_wpa && op && (i || !is_gimple_debug (stmt))) { basep =3D &op; if (TREE_CODE (*basep) =3D=3D ADDR_EXPR) basep =3D &TREE_OPERAND (*basep, 0); while (handled_component_p (*basep)) basep =3D &TREE_OPERAND (*basep, 0); if (VAR_P (*basep) && !auto_var_in_fn_p (*basep, fn->decl) && !DECL_REGISTER (*basep))=20 { bool volatilep =3D TREE_THIS_VOLATILE (*basep); tree ptrtype =3D build_pointer_type (TREE_TYPE (*basep)); *basep =3D build2 (MEM_REF, TREE_TYPE (*basep), build1 (ADDR_EXPR, ptrtype, *basep), build_int_cst (ptrtype, 0)); TREE_THIS_VOLATILE (*basep) =3D volatilep; ... and gimple-streamer-in.cc undoes this when the prevailing decls are compati= ble: /* At LTO output time we wrap all global decls in MEM_REFs to allow seamless replacement with prevailing decls. Undo this here if the prevailing decl allows for this. ??? Maybe we should simply fold all stmts. */ if (TREE_CODE (*opp) =3D=3D MEM_REF && TREE_CODE (TREE_OPERAND (*opp, 0)) =3D=3D ADDR_EXPR && integer_zerop (TREE_OPERAND (*opp, 1)) && (TREE_THIS_VOLATILE (*opp) =3D=3D TREE_THIS_VOLATILE (TREE_OPERAND (TREE_OPERAND (*opp, 0), 0))) && !TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (*opp, 1)= )) && (TREE_TYPE (*opp) =3D=3D TREE_TYPE (TREE_TYPE (TREE_OPERAND (*opp, 1)))) && (TREE_TYPE (*opp) =3D=3D TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*opp, 0), 0= )))) *opp =3D TREE_OPERAND (TREE_OPERAND (*opp, 0), 0); I suppose we might want to split these out so summary streaming can apply this to streamed trees as well?=