From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 320B63858D33; Tue, 8 Aug 2023 08:59:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 320B63858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691485195; bh=a7Ci6k66X9Ilr/1HGSpF/i4dffBZyFhzQemjzmzuYig=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AFhWdJ6ZvOdHgL5M34IrVQ+DgkY2d3IeShWF4fqH956B1RJrLPt0BeIDp9I3oIEPu C6isV1KhtTc0EfCKacr39sH6GcnLMNp0C7JD15jtEaJiRhQvK+SQ/hxeadzGfBmQsF /9HxBX0gjrZlcxHRcKeVk8+SOpLD4OxpHgBOCjaQ= From: "fw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/110899] RFE: Attributes preserve_most and preserve_all Date: Tue, 08 Aug 2023 08:59:54 +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: 14.0 X-Bugzilla-Keywords: ABI X-Bugzilla-Severity: enhancement X-Bugzilla-Who: fw at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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=3D110899 --- Comment #10 from Florian Weimer --- (In reply to Michael Matz from comment #9) > > > I don't see how that helps. Imagine a preserve_all function foo that= calls > > > printf. How do you propose that 'foo' saves all parts of the SSE reg= isters, > > > even those that aren't invented yet, or those that can't be touched b= y the > > > current ISA? (printf might clobber all of these) > >=20 > > Vector registers are out of scope for this. >=20 > Why do you say that? From clang: "Furthermore it also preserves all > floating-point registers (XMMs/YMMs)." (for preserve_all, but this > bugreport does include that variant of the attribute). Ugh, I preferred not to look at it because it's likely that the Clang implementation is broken (not future-proof). > > But lets look at APX. If printf is recompiled to use APX, then it will > > clobber the extended register file. If we define __preserve_most__ the = way > > we do in my psABI proposal (i.e., *not* as everything but %r11), the > > extended APX registers are still caller-saved. >=20 > Right, for preserve_most _with your wording_ it works out. preserve_all > or preserve_most with clang wording doesn't. In glibc, we already use a full context switch with XSAVE for the dynamic loader trampoline. As far as I understand it, it's not future-proof. The ke= rnel could provide an interface that is guaranteed to work because it only enabl= es those parts of the register file that it can context-switch. I can probably= get the userspace-only implementation into glibc, but the kernel interface seems unlikely. We'd also have to work out the interaction of preserve_all and unwinding, setjmp etc.; not sure if there is a proper solution for that.=