LLVM assumes that __tls_get_addr() clobbers only r0, r4-r12, LR, CTR,
CR0, CR1 and CR5-CR7 (the GETtlsADDR pseudo in PPCInstr64Bit.td), as
glibc's implementation guarantees, and keeps live values in the other
registers across the call. Our slow path, which runs on the first
access to the TLS block of a dlopen()ed object, copies the TLS
initialization image with the generic memcpy() and memset(), which
clang vectorizes: for a 130-byte block they clobber vs0, vs1, v0, v2,
v3 and v5 on powerpc64le and v2, v4 and v5 in a POWER9 powerpc64 build.
Qt's QBindingStorage constructor zeroes vs0, calls __tls_get_addr() and
then stores vs0 into the object, so the first QObject created by a
process that dlopen()ed libQt6Core gets 0xffffffff in its binding
storage pointer and crashes on destruction; this is why devel/pyside6
cannot generate QtGui.pyi on powerpc64le.
Keep the fast path as it is and run the slow path through a trampoline
that saves and restores the volatile floating-point and vector
registers: f0-f13, with AltiVec also v0-v19, and with VSX vs0-vs51 since
the high halves of vs14-vs31 are volatile as well.
Tested on powerpc64le and powerpc64 16.0-CURRENT and on 15.1 powerpc64le
with a reproducer that zeroes vs0-vs51 around the first TLS access to a
dlopen()ed library (it fails with the stock loader on all three and
passes with the patched one), with a unit test of the trampoline in all
three modes against a callee that overwrites every VSX register, and on
15.1 powerpc64le the patched loader lets pyside6 generate QtGui.pyi.