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