This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: RFC: Should x86-64 support arbitrary calling conventions?


H.J. is correct. The __regcall calling convention may use up to 16 vector
registers for passing arguments. And when not used for passing arguments,
registers xmm8-xmm15 are callee-save. The convention doesn't pass arguments
in mask registers nor treat them as callee-save, but there still might be
situations where it would be useful to pass arguments in mask registers for
performance reasons.

Ideally, _dl_runtime_resolve should preserve any registers that it uses,
similar to an interrupt handler.

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5ed3cc7b66af4758f7849ed6f65f4365be8223be

It is not strictly necessary to use xsave/xrstor for this purpose, though that
is a convenient way to do it. An alternative if xsave/xrstor is deemed too
costly is to avoid using vector registers at all within _dl_runtime_resolve.

Otherwise, we leave significant performance potential on the table in
situations where the "one size fits all" calling convention is inefficient.

Dave Kreitzer
Intel Compilers

-----Original Message-----
From: H.J. Lu [mailto:hjl.tools@gmail.com] 
Sent: Friday, March 17, 2017 11:51 AM
To: GNU C Library <libc-alpha@sourceware.org>; Kreitzer, David L <david.l.kreitzer@intel.com>
Subject: Re: RFC: Should x86-64 support arbitrary calling conventions?

On Thu, Mar 16, 2017 at 4:27 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 16 Mar 2017 15:07, H.J. Lu wrote:
>> According to x86-64 psABI, xmm0-xmm7 can be used to pass function 
>> parameters.  But ICC also uses xmm8-xmm15 to pass function parameters.
>> This doesn't work with newer glibc since _dl_runtime_resolve only 
>> preserves the first 8 vector registers:
>>
>> https://sourceware.org/bugzilla/show_bug.cgi?id=21236
>>
>> We can use xsave/xrstor to preserve all vector registers to support 
>> arbitrary calling conventions.  But xsave/restor is about 8X slower, 
>> comparing against saving/restoring the first 8 vector registers.
>
> seems like an obvious "no" then ? :)
>
> where does the line stop with "arbitrary calling conventions" ?  do we 
> save every single register/state in case someone might try to use it 
> to pass values ?  or do we only do it for projects that are "big enough" ?
> seems like the whole point of having a psABI is so that everyone 
> agrees in one place and we don't have to waste time (buth in 
> development and in
> runtime) supporting non-standard stuff.
> -mike

Arbitrary calling conventions may be too strong.   Support all vector and mask
registers is sufficient.   Intel C++ __regcall calling convention for
x86-64 uses
the first 16 vector registers:

https://sourceware.org/bugzilla/show_bug.cgi?id=21265

David can provide more details.

--
H.J.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]