[compiler-rt] [llvm] [JITLink] Add initial TLS support for SystemZ (PR #170706)

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 5 09:24:18 PST 2025


================
@@ -0,0 +1,84 @@
+// RUN: %clang -c -o %t %s
+// RUN: %llvm_jitlink %t
+//
+// Test that basic ELF TLS work by adding together TLSs with values
+// 0, 1, and -1, and returning the result (0 for success). This setup
+// tests both zero-initialized (.tbss) and non-zero-initialized
+// (.tdata) sections.
+
+        .section        .data.rel.ro,"aw", at progbits
+        .p2align        3, 0x0                          # -- Begin function main
+.LCPI0_0:
+        .quad   x at TLSGD
+.LCPI0_1:
+        .quad   y at TLSGD
+.LCPI0_2:
+        .quad   z at TLSGD
+
+        .text
+        .globl  main
+        .p2align        4
+        .type   main, at function
+main:                                   # @main
+# %bb.0:                                # %entry
+        stmg    %r11, %r15, 88(%r15)
+        aghi    %r15, -192
+        lgr     %r11, %r15
+        mvhi    188(%r11), 0
+        lgrl    %r2, .LCPI0_0 
+        larl    %r12, _GLOBAL_OFFSET_TABLE_
+        stg     %r12, 160(%r11)                 # 8-byte Spill
+        brasl   %r14, __tls_get_offset at PLT:tls_gdcall:x
+        lg      %r12, 160(%r11)                 # 8-byte Reload
----------------
uweigand wrote:

This shouldn't be needed, r12 will be preserved by the call.  In general, there's quite a bit of unnecessary stuff in this test case.  Was this created by compiling something with `-O0` or the like?

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


More information about the llvm-commits mailing list