[lld] [lld] Add target support for SystemZ (s390x) (PR #75643)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 16:07:01 PST 2024


================
@@ -1374,8 +1379,8 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
             R_LOONGARCH_GOT_PAGE_PC, R_GOT_OFF, R_TLSIE_HINT>(expr)) {
     ctx.hasTlsIe.store(true, std::memory_order_relaxed);
     // Initial-Exec relocs can be optimized to Local-Exec if the symbol is
-    // locally defined.
-    if (execOptimize && isLocalInExecutable) {
+    // locally defined.  This is not supported on SystemZ.
+    if (execOptimize && isLocalInExecutable && config->emachine != EM_S390) {
----------------
MaskRay wrote:

Thanks for the explanation. I've rewritten the paragraph to:

Optimizing the code sequence to local-exec is straightforward: changing the first instruction to `lgfi %r1, a at NTPOFF`.
However, LGFI (Load Immediate) is part of the extended-immediate facility (September 2005), introduced with System z9 109, unavailable when the ABI was defined.


> B.t.w. are we certain that TLS offsets on a 64-bit platform can be restricted to 32 bits?

We can. A 2GiB static TLS block almost assuredly won't work. It means that the dynamic loader needs to allocate 2GiB thread stack upfront for each new thread. The memory use is just not affordable.
https://github.com/llvm/llvm-project/issues/77128

https://github.com/llvm/llvm-project/pull/75643


More information about the llvm-commits mailing list