[PATCH] powerpc: Use global register variable in <thread_pointer.h>
Mathieu Desnoyers
mathieu.desnoyers@efficios.com
Wed Dec 15 15:43:25 GMT 2021
----- On Dec 15, 2021, at 10:34 AM, Florian Weimer fweimer@redhat.com wrote:
> * Mathieu Desnoyers:
>
>> For instance, a library/application already defining its own global variable:
>>
>> register void *myvar asm ("r2");
>>
>> would not be able to include a header also declaring a global definition
>> for register "r2".
>
> This may be a good thing, though, if the uses are actually incompatible.
> Even local register variables (correctly used) could clash, see below.
Two headers independently trying to read the content of the ABI-defined
r2 register appear to be perfectly legitimate use-cases.
>
>> Do you see anything wrong with the following implementation ?
>>
>> static inline void *rseq_thread_pointer(void)
>> {
>> #ifdef __powerpc64__
>> register void *__result asm ("r13");
>> #else
>> register void *__result asm ("r2");
>> #endif
>> asm ("" : "=r" (__result));
>> return __result;
>> }
>
> If there is a global register variable in scope for r13/r2, it is
> unclear whether the compiler is expected to spill and restore it around
> the inline assembly. It's just a performance issue in this case, I
> think. It would still be annoying if it happened.
True. However, if both glibc and rseq agree on using local register
variables with the asm output operand rather than the global register
variable in public headers, we would not have to worry about this.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
More information about the Libc-alpha
mailing list