public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/116497] New: Need no_caller_saved_registers with SSE support
@ 2024-08-27  5:42 andi-gcc at firstfloor dot org
  2024-08-27  5:49 ` [Bug target/116497] " andi-gcc at firstfloor dot org
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: andi-gcc at firstfloor dot org @ 2024-08-27  5:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116497

            Bug ID: 116497
           Summary: Need no_caller_saved_registers with SSE support
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andi-gcc at firstfloor dot org
                CC: hjl.tools at gmail dot com
  Target Milestone: ---
            Target: x86_64-linux

When writing threaded code interpreters by chaining functions with musttail the
normal ABI behavior of some caller saved registers can cause unnecessary spills
and fills compared to using indirect goto.

In principle this could be avoided by using no_caller_saved_registers on the
musttail called function, and perhaps no_callee_saved_registers on the function
that starts the interpretation chain to maintain the ABI on the interpreter
entry point.

But these attributes were designed for interrupt handlers and require disabling
SSE because an interrupt handler needs to really preserve all registers. While
for the interpreter case which interacts with the normal ABI it is fine to
clobber the SSE registers, as specified by the x86_64 SYSV ABI

So disabling SSE can be done (and it is done in some real code today, see [1]
below) it is very inconvenient for an interpreter that may want to use SSE for
floating point etc.

So what we really need for the efficient musttail interpreters is
no_caller_saved_registers, but allow using SSE.

clang has a special ABI for this case (preserve_most[2]), but that seems
overkill.

There are two ways around this:

- We just remove the code that enforces no SSE for (see below patch). The
interrupt handlers would need to disable SSE without error and trust that 
it doesn't happen by mistake.

I'm not sure there is much code that uses this (I couldn't find any).
Presumably they would rather use the interrupt attribute anyways.

- We define a new attribute like no_caller_saved_registers except that it
allows using SSE.

[1] 
https://github.com/swoole/swoole-cli/blob/94ab97fbcfe39be8f5a985da82575bfb4c2319db/Zend/zend_string.c#L376

[2]
https://clang.llvm.org/docs/AttributeReference.html#preserve-most

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2024-08-27 17:50 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-27  5:42 [Bug target/116497] New: Need no_caller_saved_registers with SSE support andi-gcc at firstfloor dot org
2024-08-27  5:49 ` [Bug target/116497] " andi-gcc at firstfloor dot org
2024-08-27  5:50 ` pinskia at gcc dot gnu.org
2024-08-27  5:58 ` [Bug target/116497] static functions ABI should be improved for SSE caller saved registers pinskia at gcc dot gnu.org
2024-08-27  6:03 ` pinskia at gcc dot gnu.org
2024-08-27  6:17 ` andi at firstfloor dot org
2024-08-27  6:25 ` [Bug target/116497] Need no_caller_saved_registers with SSE support pinskia at gcc dot gnu.org
2024-08-27  7:58 ` liuhongt at gcc dot gnu.org
2024-08-27  8:02 ` rguenth at gcc dot gnu.org
2024-08-27  8:10 ` andi at firstfloor dot org
2024-08-27  8:14 ` andi at firstfloor dot org
2024-08-27  8:26 ` xry111 at gcc dot gnu.org
2024-08-27 13:27 ` hjl.tools at gmail dot com
2024-08-27 14:21 ` andi at firstfloor dot org
2024-08-27 14:33 ` andi at firstfloor dot org
2024-08-27 14:47 ` pinskia at gcc dot gnu.org
2024-08-27 15:19 ` hjl.tools at gmail dot com
2024-08-27 15:53 ` andi-gcc at firstfloor dot org
2024-08-27 16:25 ` hjl.tools at gmail dot com
2024-08-27 17:06 ` andi at firstfloor dot org
2024-08-27 17:12 ` hjl.tools at gmail dot com
2024-08-27 17:49 ` andi at firstfloor dot org
2024-08-27 17:50 ` andi-gcc at firstfloor dot org
2024-08-27 17:50 ` andi-gcc at firstfloor dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).