[PATCH] powerpc: Use global register variable in <thread_pointer.h>
Florian Weimer
fweimer@redhat.com
Wed Dec 15 15:34:27 GMT 2021
* 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.
> 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.
Thanks,
Florian
More information about the Libc-alpha
mailing list