[PATCH] D151335: [AIX][TLS] Generate .extern and .ref references to __tls_get_addr for local-exec accesses.
Digger Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 8 13:32:22 PDT 2023
DiggerLin added inline comments.
================
Comment at: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:2785
+ case PPC::LDtoc:
+ case PPC::LDtocL: {
+ const MachineOperand &MO = MI->getOperand(1);
----------------
I do not think it is efficient to put the code here. if there are a lot of thread local variables or the variables are reference in a lot of places, the code run enter as many time as the the number of thread local variable reference place.
and each time do the same thing
```
MCSymbol *TlsGetAddrDescriptor =
createMCSymbolForTlsGetAddr(OutContext, XCOFF::XMC_DS);
ExtSymSDNodeSymbols.insert(TlsGetAddrDescriptor);
```
can we do it in the function PPCAIXAsmPrinter::doFinalization()
```
for (auto &I : TOC) {
// Add a single .ref reference to __tls_get_addr[DS] for the local-exec TLS
// model on AIX. For TLS models that do not generate calls to TLS functions,
// this .ref reference to __tls_get_addr helps generate a linker error to
// an undefined symbol to __tls_get_addr, which indicates to the user that
// compiling with -pthread is required for programs that use TLS variables.
if (Subtarget->isPPC64() &&
(I.first.second == MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSLE)) {
MCSymbol *TlsGetAddrDescriptor =
createMCSymbolForTlsGetAddr(OutContext, XCOFF::XMC_DS);
ExtSymSDNodeSymbols.insert(TlsGetAddrDescriptor);
OutStreamer->emitXCOFFRefDirective(TlsGetAddrDescriptor);
break;
}
}
for (MCSymbol *Sym : ExtSymSDNodeSymbols)
OutStreamer->emitSymbolAttribute(Sym, MCSA_Extern);
```
it will run only once.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151335/new/
https://reviews.llvm.org/D151335
More information about the llvm-commits
mailing list