[PATCH] D155600: [AIX][TLS] Produce a faster local-exec access sequence with -maix-small-local-exec-tls (And optimize when load/store offsets are 0)

Digger Lin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 08:18:59 PDT 2023

DiggerLin added a comment.

according to https://www.ibm.com/docs/en/aix/7.2?topic=program-using-thread-local-storage

both 32-bit and 64-bit support faster access sequence for the local-exec TLS model. Do you want to modify the summary Since the patch only support 64-bit.

Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:3366
+      if (HasAIXSmallLocalExecTLS &&
+          (GVTypeSize < (AIXTLSUpperDisplacement - 8)))
+        return DAG.getNode(PPCISD::Lo, dl, PtrVT, VariableOffsetTGA, TLSReg);
nemanjai wrote:
> hubert.reinterpretcast wrote:
> > What does `AIXTLSUpperDisplacement` represent? It is already given a value of 32K - 8. Should the hard coded subtraction be here, should the value of `AIXTLSUpperDisplacement` be further adjusted instead, or is there unintentional double adjustment happening?
> > 
> > For reference, I encountered no issues linking the result of assembly that performs `la` (using the subject access pattern) for the past-the-end address of a 32K - 1 local-exec TLS variable.
> I agree. We shouldn't be doing any arithmetic here on `AIXTLSUpperDisplacement`. We should set it to what we want it and only perform comparisons.
according to https://www.ibm.com/docs/en/aix/7.2?topic=program-using-thread-local-storage

`The local-dynamic and local-exec access methods have a faster code sequence that can be used if the total size of thread-local variables is smaller than 62 KB (I think it is typo here). If the total size of the region is too large, the link-editor will patch the code by generating extra instructions, negating the benefit of using the faster code sequence.`

we need to calculate sum of ` the total size of thread-local variables` somewhere and check whether the value is less than 32K. 
does the `AIXTLSUpperDisplacement` want to express  sum of ` the total size of thread-local variables` ? if it the calculation is not correct.


  rG LLVM Github Monorepo



More information about the llvm-commits mailing list