[llvm] [AIX][TLS] Optimize the small local-exec access sequence for non-zero offsets (PR #71485)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 12 14:01:52 PST 2024
================
@@ -2749,6 +2879,21 @@ bool PPCAIXAsmPrinter::doInitialization(Module &M) {
Csect->ensureMinAlignment(GOAlign);
};
+ // For all TLS variables, calculate their corresponding addresses and store
+ // them into TLSVarsToAddressMapping, which will be used to determine whether
+ // or not local-exec TLS variables require special assembly printing.
+ uint64_t Address = 0;
+ uint64_t TLSVarAddress = 0;
+ auto DL = M.getDataLayout();
+ for (const auto &G : M.globals()) {
+ if (G.isThreadLocal() && !G.isDeclaration()) {
+ TLSVarAddress = alignTo(Address, getGVAlignment(&G, DL));
+ unsigned GVSize = DL.getTypeAllocSize(G.getValueType());
+ Address = TLSVarAddress + GVSize;
+ TLSVarsToAddressMapping[&G] = TLSVarAddress;
----------------
diggerlin wrote:
I think we do not need a `uint64_t Address = 0;` and `unsigned GVSize`
can we change the code to
```
TLSVarAddress = alignTo(TLSVarAddress , getGVAlignment(&G, DL));
TLSVarsToAddressMapping[&G] = TLSVarAddress;
TLSVarAddress += DL.getTypeAllocSize(G.getValueType());
```
?
https://github.com/llvm/llvm-project/pull/71485
More information about the llvm-commits
mailing list