[lld] [llvm] [X86] Use a large-model call for __tls_get_addr (PR #216195)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 14 10:50:44 PDT 2026
================
@@ -595,6 +595,47 @@ void X86AsmPrinter::LowerTlsAddr(X86MCInstLower &MCInstLowering,
.addReg(0));
} else if (Is64Bits) {
bool NeedsPadding = Specifier == X86::S_TLSGD;
+ const MCSymbol *TlsGetAddr = Ctx.getOrCreateSymbol("__tls_get_addr");
+ if (Is64BitsLP64 && getSubtarget().isTargetELF() &&
+ TM.getCodeModel() == CodeModel::Large && TM.isPositionIndependent()) {
----------------
MaskRay wrote:
Agreed that no PIC check is needed.
`__tls_get_addr` is needed when the translation unit can be used by a dlopen shared object. Only `-fpic` may need TLS GD. -fno-pic/-fpie don't. However, the PIC check may not be needed in this context.
https://github.com/llvm/llvm-project/pull/216195
More information about the llvm-commits
mailing list