From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C41B53858D1E; Wed, 6 Apr 2022 07:10:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C41B53858D1E From: "peterz at infradead dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/105160] [12 regression] ipa modref marks functions with asm volatile as const or pure Date: Wed, 06 Apr 2022 07:10:50 +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.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: peterz at infradead dot org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: hubicka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2022 07:10:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105160 --- Comment #7 from peterz at infradead dot org --- (In reply to peterz from comment #6) > Happy accident; I've been wanting to allow doing something like: >=20 > static __always_inline __pure bool arch_static_branch(struct static_key * > const key) > { > asm_volatile_goto("1:" > ".byte " __stringify(BYTES_NOP5) "\n\t" > ".pushsection __jump_table, \"aw\" \n\t" > _ASM_ALIGN "\n\t" > ".long 1b - ., %l[l_yes] - . \n\t" > _ASM_PTR "%c0 - . \n\t" > ".popsecion \n\t" > : : "i" (key) : : l_yes); > return false; > l_yes: > return true; > } >=20 >=20 > Now, since asm-goto is implicitly volatile, and asm volatile (per this > thread) destroys __pure due to side-effects, this doesn't actually work. = But > I'd like to still have the explicit pure attribute override this. If the > programmer gets it wrong like this, he/she gets to keep the pieces. >=20 > Specifically in this case, he result of the function really only depends = on > the @key argument. Any call to this will have the exact same outcome and > merging multiple instances is *good*. >=20 > Also see this thread on linux-toolchains: >=20 >=20=20 > https://lore.kernel.org/all/YG80wg%2F2iZjXfCDJ@hirez.programming.kicks-as= s. > net/ Possible test case here: https://lore.kernel.org/all/YIb0vYQMEs9HRjPl@hirez.programming.kicks-ass.= net/=