From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A4C0E38555A4; Wed, 3 May 2023 15:22:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4C0E38555A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683127369; bh=mWnbzKJNVpjpgQRtU7tGNZd0Jb2oU4z9m4YuuXAKpJk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jm2CdFbixe3RQ7sA+TQNr+MpN4c6h/VSCD+ByiRaWNDvyd6hTBkeo4r5TNN9NL6nK gDjp4ktnqSHHqbDUMtovH7+vp8VzpmsqE43d8vSXrcRIidp4pwejDgNmnPMe9iKoY/ mYEJDrIaTUV2JLgu5RdYL6MWQdDpLV/iTu2ss7vY= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105554] [10 Regression] ICE: in emit_block_move_hints, at expr.cc:1829 since r9-5509-g5928bc2ec06dd4e7 Date: Wed, 03 May 2023 15:22:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 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=3D105554 --- Comment #27 from CVS Commits --- The releases/gcc-10 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:06b34c0d76153549fb83001c3d90b798066a1851 commit r10-11380-g06b34c0d76153549fb83001c3d90b798066a1851 Author: Jakub Jelinek Date: Fri Mar 17 18:59:56 2023 +0100 tree-inline: Fix up multiversioning with vector arguments [PR105554] The following testcase ICEs, because we call tree_function_versioning f= rom old_decl which has target attributes not supporting V4DImode and so DECL_MODE of DECL_ARGUMENTS is BLKmode, while new_decl supports those. tree_function_versioning initially copies DECL_RESULT and DECL_ARGUMENTS from old_decl to new_decl, then calls initialize_cfun to create cfun and only when the cfun is created it can later actually remap_decl DECL_RESULT and DECL_ARGUMENTS etc. The problem is that initialize_cfun -> push_struct_function -> allocate_struct_function calls relayout_decl on DECL_RESULT and DECL_ARGUMENTS, which clobbers DECL_MODE of old_decl and we then ICE because of it. In particular, allocate_struct_function does: if (!abstract_p) { /* Now that we have activated any function-specific attributes that might affect layout, particularly vector modes, relay= out each of the parameters and the result. */ relayout_decl (result); for (tree parm =3D DECL_ARGUMENTS (fndecl); parm; parm =3D DECL_CHAIN (parm)) relayout_decl (parm); /* Similarly relayout the function decl. */ targetm.target_option.relayout_function (fndecl); } if (!abstract_p && aggregate_value_p (result, fndecl)) { #ifdef PCC_STATIC_STRUCT_RETURN cfun->returns_pcc_struct =3D 1; #endif cfun->returns_struct =3D 1; } Now, in the case of tree_function_versioning, I believe all that we need from these is possibly the targetm.target_option.relayout_function (fndecl); call (arm only), we will remap DECL_RESULT and DECL_ARGUMENTS later on and copy_decl_for_dup_finish in that case will handle all we need: /* For vector typed decls make sure to update DECL_MODE according to the new function context. */ if (VECTOR_TYPE_P (TREE_TYPE (copy))) SET_DECL_MODE (copy, TYPE_MODE (TREE_TYPE (copy))); We don't need the cfun->returns_*struct either, because we override it in initialize_cfun a few lines later: /* Copy items we preserve during cloning. */ ... cfun->returns_struct =3D src_cfun->returns_struct; cfun->returns_pcc_struct =3D src_cfun->returns_pcc_struct; So, to avoid the clobbering of DECL_RESULT/DECL_ARGUMENTS of old_decl, the following patch arranges allocate_struct_function to be called with abstract_p true and calls targetm.target_option.relayout_function (fnde= cl); by hand. The removal of DECL_RESULT/DECL_ARGUMENTS copying at the start of initialize_cfun is removed because the only caller - tree_function_versioning, does that unconditionally before. 2023-03-17 Jakub Jelinek PR target/105554 * function.h (push_struct_function): Add ABSTRACT_P argument defaulted to false. * function.c (push_struct_function): Add ABSTRACT_P argument, p= ass it to allocate_struct_function instead of false. * tree-inline.c (initialize_cfun): Don't copy DECL_ARGUMENTS nor DECL_RESULT here. Pass true as ABSTRACT_P to push_struct_function. Call targetm.target_option.relayout_func= tion after it. (tree_function_versioning): Formatting fix. * gcc.target/i386/pr105554.c: New test. (cherry picked from commit 24c06560a7fa39049911eeb8777325d112e0deb9)=