From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 364F53857BAC; Wed, 14 Sep 2022 13:58:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 364F53857BAC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663163923; bh=3r39pR8PoLoP3Ifkk42A15XsY1PmpIMhBKZ90Gi7iF4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=E77Sboo3CyW1ibo7SB/QAOQIQQjWFLyb23+vdpK18inW94iTzRcLsej1nEDD7SEXq 9e6bR7UM+giBpu/PRBnl07/Pfw8NIvZzcYMHuKyb3YM4+c/DCrblO5jMbN44UfVPLP tgzoJyN9SeCcRpia3/I01k8OAKa9jxBgODmStkCk= From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/106816] noreturn/pure attributes are not set correctly on multiversioned functions Date: Wed, 14 Sep 2022 13:58:43 +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: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin 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: 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=3D106816 --- Comment #6 from Martin Li=C5=A1ka --- (In reply to Richard Biener from comment #5) > The function should probably inherit all of the IPA pure/const/modref > analysis result, that is all "IPA" state should be copied. I think we wa= nt > some helper > here - IPA clone creation must have something, no? Well, in IPA clones utilize so-called function_summary that is a typical pl= ace where we store analysis results. And we don't typically create a new tree declarations when we clone cgraph_nodes (clones share the same FE declarati= on). However, I noticed we want to do likely something similar to what cp/decl.c does: static void merge_attribute_bits (tree newdecl, tree olddecl) { TREE_THIS_VOLATILE (newdecl) |=3D TREE_THIS_VOLATILE (olddecl); TREE_THIS_VOLATILE (olddecl) |=3D TREE_THIS_VOLATILE (newdecl); TREE_NOTHROW (newdecl) |=3D TREE_NOTHROW (olddecl); TREE_NOTHROW (olddecl) |=3D TREE_NOTHROW (newdecl); TREE_READONLY (newdecl) |=3D TREE_READONLY (olddecl); TREE_READONLY (olddecl) |=3D TREE_READONLY (newdecl); DECL_IS_MALLOC (newdecl) |=3D DECL_IS_MALLOC (olddecl); DECL_IS_MALLOC (olddecl) |=3D DECL_IS_MALLOC (newdecl); DECL_PURE_P (newdecl) |=3D DECL_PURE_P (olddecl); DECL_PURE_P (olddecl) |=3D DECL_PURE_P (newdecl); DECL_UNINLINABLE (newdecl) |=3D DECL_UNINLINABLE (olddecl); DECL_UNINLINABLE (olddecl) |=3D DECL_UNINLINABLE (newdecl); } ... /* Merge the noreturn bit. */ TREE_THIS_VOLATILE (olddecl) =3D TREE_THIS_VOLATILE (newdecl); TREE_READONLY (olddecl) =3D TREE_READONLY (newdecl); TREE_NOTHROW (olddecl) =3D TREE_NOTHROW (newdecl); DECL_IS_MALLOC (olddecl) =3D DECL_IS_MALLOC (newdecl); DECL_PURE_P (olddecl) =3D DECL_PURE_P (newdecl); I can see IPA passes doing similar declaration clonning for VAR_DECLs (gcc/ipa-param-manipulation.cc, gcc/tree-inline.c). @Martin: Do we have a declaration cloning code for functions somewhere?=