Skip to content

Commit f94f853

Browse files
committed
Revert "[AIX][TLS] Generate .extern and .ref references to __tls_get_addr for local-exec accesses."
This reverts commit f0b2f69. The implementation is incorrect and breaks compiling local-exec programs.
1 parent e0094ac commit f94f853

File tree

7 files changed

+108
-217
lines changed

7 files changed

+108
-217
lines changed

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ class PPCAsmPrinter : public AsmPrinter {
171171
TOCType_EHBlock
172172
};
173173

174-
// Controls whether or not to emit a .ref reference to __tls_get_addr.
175-
// This is currently used for TLS models that do not generate calls to
176-
// TLS functions, such as for the local-exec model on AIX 64-bit.
177-
bool HasRefGetTLSAddr = false;
178-
179174
MCSymbol *lookUpOrCreateTOCEntry(const MCSymbol *Sym, TOCEntryType Type,
180175
MCSymbolRefExpr::VariantKind Kind =
181176
MCSymbolRefExpr::VariantKind::VK_None);
@@ -620,17 +615,12 @@ void PPCAsmPrinter::LowerPATCHPOINT(StackMaps &SM, const MachineInstr &MI) {
620615
/// This helper function creates the TlsGetAddr MCSymbol for AIX. We will
621616
/// create the csect and use the qual-name symbol instead of creating just the
622617
/// external symbol.
623-
static MCSymbol *
624-
createMCSymbolForTlsGetAddr(MCContext &Ctx, unsigned MIOpc,
625-
XCOFF::StorageMappingClass SMC = XCOFF::XMC_PR) {
626-
StringRef SymName;
627-
if (MIOpc == PPC::GETtlsTpointer32AIX)
628-
SymName = ".__get_tpointer";
629-
else
630-
SymName = (SMC == XCOFF::XMC_DS) ? "__tls_get_addr" : ".__tls_get_addr";
618+
static MCSymbol *createMCSymbolForTlsGetAddr(MCContext &Ctx, unsigned MIOpc) {
619+
StringRef SymName =
620+
MIOpc == PPC::GETtlsTpointer32AIX ? ".__get_tpointer" : ".__tls_get_addr";
631621
return Ctx
632622
.getXCOFFSection(SymName, SectionKind::getText(),
633-
XCOFF::CsectProperties(SMC, XCOFF::XTY_ER))
623+
XCOFF::CsectProperties(XCOFF::XMC_PR, XCOFF::XTY_ER))
634624
->getQualNameSymbol();
635625
}
636626

@@ -842,11 +832,8 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
842832
if (MO.getTargetFlags() & PPCII::MO_TPREL_FLAG) {
843833
assert(MO.isGlobal() && "Only expecting a global MachineOperand here!\n");
844834
TLSModel::Model Model = TM.getTLSModel(MO.getGlobal());
845-
if (Model == TLSModel::LocalExec) {
846-
if (IsPPC64)
847-
HasRefGetTLSAddr = true;
835+
if (Model == TLSModel::LocalExec)
848836
return MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSLE;
849-
}
850837
if (Model == TLSModel::InitialExec)
851838
return MCSymbolRefExpr::VariantKind::VK_PPC_AIX_TLSIE;
852839
llvm_unreachable("Only expecting local-exec or initial-exec accesses!");
@@ -2875,22 +2862,6 @@ bool PPCAIXAsmPrinter::doFinalization(Module &M) {
28752862
OutStreamer->doFinalizationAtSectionEnd(
28762863
OutStreamer->getContext().getObjectFileInfo()->getTextSection());
28772864

2878-
// Add a single .ref reference to __tls_get_addr[DS] for the local-exec TLS
2879-
// model on AIX 64-bit. For TLS models that do not generate calls to TLS
2880-
// functions, this reference to __tls_get_addr helps generate a linker error
2881-
// to an undefined symbol to __tls_get_addr, which indicates to the user that
2882-
// compiling with -pthread is required for programs that use TLS variables.
2883-
if (HasRefGetTLSAddr) {
2884-
// Specifically for 64-bit AIX, a load from the TOC is generated to load
2885-
// the variable offset needed for local-exec accesses.
2886-
MCSymbol *TlsGetAddrDescriptor =
2887-
createMCSymbolForTlsGetAddr(OutContext, PPC::GETtlsADDR64AIX,
2888-
XCOFF::XMC_DS);
2889-
2890-
ExtSymSDNodeSymbols.insert(TlsGetAddrDescriptor);
2891-
OutStreamer->emitXCOFFRefDirective(TlsGetAddrDescriptor);
2892-
}
2893-
28942865
for (MCSymbol *Sym : ExtSymSDNodeSymbols)
28952866
OutStreamer->emitSymbolAttribute(Sym, MCSA_Extern);
28962867
return PPCAsmPrinter::doFinalization(M);

llvm/test/CodeGen/PowerPC/aix-tls-le-ldst-double.ll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -635,13 +635,6 @@ entry:
635635
ret double %add
636636
}
637637

638-
; (64-bit only) External symbol reference checks for __tls_get_addr[DS]
639-
640-
; SMALL64: .ref __tls_get_addr[DS]
641-
; SMALL64: .extern __tls_get_addr[DS]
642-
; LARGE64: .ref __tls_get_addr[DS]
643-
; LARGE64: .extern __tls_get_addr[DS]
644-
645638
; TOC Entry Checks.
646639

647640
; SMALL64-LABEL: .toc

llvm/test/CodeGen/PowerPC/aix-tls-le-ldst-float.ll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -635,13 +635,6 @@ entry:
635635
ret float %add
636636
}
637637

638-
; (64-bit only) External symbol reference checks for __tls_get_addr[DS]
639-
640-
; SMALL64: .ref __tls_get_addr[DS]
641-
; SMALL64: .extern __tls_get_addr[DS]
642-
; LARGE64: .ref __tls_get_addr[DS]
643-
; LARGE64: .extern __tls_get_addr[DS]
644-
645638
; TOC Entry Checks.
646639

647640
; SMALL64-LABEL: .toc

llvm/test/CodeGen/PowerPC/aix-tls-le-ldst-int.ll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,13 +651,6 @@ entry:
651651
ret i32 %add
652652
}
653653

654-
; (64-bit only) External symbol reference checks for __tls_get_addr[DS]
655-
656-
; SMALL64: .ref __tls_get_addr[DS]
657-
; SMALL64: .extern __tls_get_addr[DS]
658-
; LARGE64: .ref __tls_get_addr[DS]
659-
; LARGE64: .extern __tls_get_addr[DS]
660-
661654
; TOC Entry Checks.
662655

663656
; SMALL64-LABEL: .toc

llvm/test/CodeGen/PowerPC/aix-tls-le-ldst-longlong.ll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,6 @@ entry:
707707
ret i64 %add
708708
}
709709

710-
; (64-bit only) External symbol reference checks for __tls_get_addr[DS]
711-
712-
; SMALL64: .ref __tls_get_addr[DS]
713-
; SMALL64: .extern __tls_get_addr[DS]
714-
; LARGE64: .ref __tls_get_addr[DS]
715-
; LARGE64: .extern __tls_get_addr[DS]
716-
717710
; TOC Entry Checks.
718711

719712
; SMALL64-LABEL: .toc

0 commit comments

Comments
 (0)