Skip to content
This repository was archived by the owner on Dec 20, 2019. It is now read-only.

Commit 5a67f67

Browse files
committed
LDC: Revert old Android TLS patches.
1 parent e8183ac commit 5a67f67

10 files changed

+28
-89
lines changed

lib/CodeGen/TargetLoweringObjectFileImpl.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,8 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
232232
MMI, Streamer);
233233
}
234234

235-
static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K,
236-
const Triple &TargetTriple) {
237-
// N.B.: The defaults used in here are no the same ones used in MC.
235+
static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) {
236+
// N.B.: The defaults used in here are not the same ones used in MC.
238237
// We follow gcc, MC follows gas. For example, given ".section .eh_frame",
239238
// both gas and MC will produce a section with no flags. Given
240239
// section(".eh_frame") gcc will produce:
@@ -265,7 +264,6 @@ static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K,
265264
return SectionKind::getThreadData();
266265

267266
if (Name == ".tbss" ||
268-
(TargetTriple.isAndroid() && Name == ".tcommon") || // LDC
269267
Name.startswith(".tbss.") ||
270268
Name.startswith(".gnu.linkonce.tb.") ||
271269
Name.startswith(".llvm.linkonce.tb."))
@@ -296,7 +294,7 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) {
296294
return ELF::SHT_PROGBITS;
297295
}
298296

299-
static unsigned getELFSectionFlags(SectionKind K, const Triple &TargetTriple) {
297+
static unsigned getELFSectionFlags(SectionKind K) {
300298
unsigned Flags = 0;
301299

302300
if (!K.isMetadata())
@@ -311,7 +309,7 @@ static unsigned getELFSectionFlags(SectionKind K, const Triple &TargetTriple) {
311309
if (K.isWriteable())
312310
Flags |= ELF::SHF_WRITE;
313311

314-
if (K.isThreadLocal() && !TargetTriple.isAndroid()) // LDC
312+
if (K.isThreadLocal())
315313
Flags |= ELF::SHF_TLS;
316314

317315
if (K.isMergeableCString() || K.isMergeableConst())
@@ -377,10 +375,10 @@ MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
377375
}
378376

379377
// Infer section flags from the section name if we can.
380-
Kind = getELFKindForNamedSection(SectionName, Kind, getTargetTriple());
378+
Kind = getELFKindForNamedSection(SectionName, Kind);
381379

382380
StringRef Group = "";
383-
unsigned Flags = getELFSectionFlags(Kind, getTargetTriple());
381+
unsigned Flags = getELFSectionFlags(Kind);
384382
if (const Comdat *C = getELFComdat(GO)) {
385383
Group = C->getName();
386384
Flags |= ELF::SHF_GROUP;
@@ -504,7 +502,7 @@ static MCSectionELF *selectELFSectionForGlobal(
504502

505503
MCSection *TargetLoweringObjectFileELF::SelectSectionForGlobal(
506504
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
507-
unsigned Flags = getELFSectionFlags(Kind, getTargetTriple());
505+
unsigned Flags = getELFSectionFlags(Kind);
508506

509507
// If we have -ffunction-section or -fdata-section then we should emit the
510508
// global value to a uniqued section specifically for it.

lib/MC/MCELFStreamer.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,7 @@ void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
448448
break;
449449
}
450450
getAssembler().registerSymbol(symRef.getSymbol());
451-
// LDC
452-
{
453-
auto ofi = getContext().getObjectFileInfo();
454-
if (!(ofi && ofi->getTargetTriple().isAndroid()))
455-
cast<MCSymbolELF>(symRef.getSymbol()).setType(ELF::STT_TLS);
456-
}
451+
cast<MCSymbolELF>(symRef.getSymbol()).setType(ELF::STT_TLS);
457452
break;
458453
}
459454

lib/MC/MCObjectFileInfo.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,12 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
497497
ReadOnlySection =
498498
Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
499499

500-
// LDC
501-
const auto tlsFlag = (!getTargetTriple().isAndroid() ? ELF::SHF_TLS : 0);
500+
TLSDataSection =
501+
Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
502+
ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
502503

503-
TLSDataSection = Ctx->getELFSection(
504-
".tdata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | tlsFlag | ELF::SHF_WRITE);
505-
506-
TLSBSSSection = Ctx->getELFSection(".tbss", ELF::SHT_NOBITS,
507-
ELF::SHF_ALLOC | tlsFlag | ELF::SHF_WRITE);
504+
TLSBSSSection = Ctx->getELFSection(
505+
".tbss", ELF::SHT_NOBITS, ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
508506

509507
DataRelROSection = Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
510508
ELF::SHF_ALLOC | ELF::SHF_WRITE);

lib/Target/AArch64/AArch64ISelLowering.cpp

+2-31
Original file line numberDiff line numberDiff line change
@@ -4149,31 +4149,6 @@ AArch64TargetLowering::LowerELFGlobalTLSAddress(SDValue Op,
41494149
return DAG.getNode(ISD::ADD, DL, PtrVT, ThreadBase, TPOff);
41504150
}
41514151

4152-
SDValue
4153-
AArch64TargetLowering::LowerAndroidGlobalTLSAddress(SDValue Op,
4154-
SelectionDAG &DAG) const {
4155-
assert(Subtarget->isTargetELF() && "This function expects an ELF target");
4156-
SDLoc DL(Op);
4157-
SDValue Result = LowerGlobalAddress(Op, DAG);
4158-
SDValue Chain = DAG.getEntryNode();
4159-
ArgListTy Args;
4160-
ArgListEntry Entry;
4161-
Type *Ty = (Type *)Type::getInt64Ty(*DAG.getContext());
4162-
Entry.Node = Result;
4163-
Entry.Ty = Ty;
4164-
Args.push_back(Entry);
4165-
4166-
// copied, modified from ARMTargetLowering::LowerToTLSGeneralDynamicModel
4167-
TargetLowering::CallLoweringInfo CLI(DAG);
4168-
CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
4169-
CallingConv::C, Ty,
4170-
DAG.getExternalSymbol("__tls_get_addr",
4171-
getPointerTy(DAG.getDataLayout())),
4172-
std::move(Args));
4173-
std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
4174-
return CallResult.first;
4175-
}
4176-
41774152
SDValue
41784153
AArch64TargetLowering::LowerWindowsGlobalTLSAddress(SDValue Op,
41794154
SelectionDAG &DAG) const {
@@ -4241,12 +4216,8 @@ SDValue AArch64TargetLowering::LowerGlobalTLSAddress(SDValue Op,
42414216

42424217
if (Subtarget->isTargetDarwin())
42434218
return LowerDarwinGlobalTLSAddress(Op, DAG);
4244-
if (Subtarget->isTargetELF()) {
4245-
if (Subtarget->isTargetAndroid())
4246-
return LowerAndroidGlobalTLSAddress(Op, DAG); // LDC
4247-
else
4248-
return LowerELFGlobalTLSAddress(Op, DAG);
4249-
}
4219+
if (Subtarget->isTargetELF())
4220+
return LowerELFGlobalTLSAddress(Op, DAG);
42504221
if (Subtarget->isTargetWindows())
42514222
return LowerWindowsGlobalTLSAddress(Op, DAG);
42524223

lib/Target/AArch64/AArch64ISelLowering.h

-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@ class AArch64TargetLowering : public TargetLowering {
589589
SDValue LowerADDROFRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
590590
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
591591
SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
592-
SDValue LowerAndroidGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const; // LDC
593592
SDValue LowerDarwinGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
594593
SDValue LowerELFGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
595594
SDValue LowerELFTLSDescCallSeq(SDValue SymAddr, const SDLoc &DL,

lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#include "AArch64MCExpr.h"
16-
#include "llvm/MC/MCAssembler.h" // LDC
1716
#include "llvm/MC/MCContext.h"
18-
#include "llvm/MC/MCObjectFileInfo.h" // LDC
1917
#include "llvm/MC/MCStreamer.h"
2018
#include "llvm/MC/MCSymbolELF.h"
2119
#include "llvm/MC/MCValue.h"
@@ -124,12 +122,7 @@ static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
124122
// We're known to be under a TLS fixup, so any symbol should be
125123
// modified. There should be only one.
126124
const MCSymbolRefExpr &SymRef = *cast<MCSymbolRefExpr>(Expr);
127-
// LDC
128-
{
129-
auto ofi = Asm.getContext().getObjectFileInfo();
130-
if (!(ofi && ofi->getTargetTriple().isAndroid()))
131-
cast<MCSymbolELF>(SymRef.getSymbol()).setType(ELF::STT_TLS);
132-
}
125+
cast<MCSymbolELF>(SymRef.getSymbol()).setType(ELF::STT_TLS);
133126
break;
134127
}
135128

lib/Target/ARM/MCTargetDesc/ARMAsmBackendELF.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@ using namespace llvm;
1818

1919
namespace {
2020
class ARMAsmBackendELF : public ARMAsmBackend {
21-
// LDC
22-
const bool isAndroid;
23-
2421
public:
2522
uint8_t OSABI;
2623
ARMAsmBackendELF(const Target &T, const MCSubtargetInfo &STI, uint8_t OSABI,
2724
support::endianness Endian)
28-
: ARMAsmBackend(T, STI, Endian),
29-
isAndroid(STI.getTargetTriple().isAndroid()), OSABI(OSABI) {}
25+
: ARMAsmBackend(T, STI, Endian), OSABI(OSABI) {}
3026

3127
std::unique_ptr<MCObjectTargetWriter>
3228
createObjectTargetWriter() const override {
33-
return createARMELFObjectWriter(OSABI, isAndroid);
29+
return createARMELFObjectWriter(OSABI);
3430
}
3531
};
3632
}

lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,13 @@ using namespace llvm;
2525
namespace {
2626

2727
class ARMELFObjectWriter : public MCELFObjectTargetWriter {
28-
// LDC
29-
const bool isAndroid;
30-
3128
enum { DefaultEABIVersion = 0x05000000U };
3229

3330
unsigned GetRelocTypeInner(const MCValue &Target, const MCFixup &Fixup,
3431
bool IsPCRel, MCContext &Ctx) const;
3532

3633
public:
37-
ARMELFObjectWriter(uint8_t OSABI, bool IsAndroid);
34+
ARMELFObjectWriter(uint8_t OSABI);
3835

3936
~ARMELFObjectWriter() override = default;
4037

@@ -47,10 +44,10 @@ namespace {
4744

4845
} // end anonymous namespace
4946

50-
ARMELFObjectWriter::ARMELFObjectWriter(uint8_t OSABI, bool IsAndroid)
51-
: MCELFObjectTargetWriter(/*Is64Bit*/ false, OSABI, ELF::EM_ARM,
52-
/*HasRelocationAddend*/ false),
53-
isAndroid(IsAndroid) {}
47+
ARMELFObjectWriter::ARMELFObjectWriter(uint8_t OSABI)
48+
: MCELFObjectTargetWriter(/*Is64Bit*/ false, OSABI,
49+
ELF::EM_ARM,
50+
/*HasRelocationAddend*/ false) {}
5451

5552
bool ARMELFObjectWriter::needsRelocateWithSymbol(const MCSymbol &Sym,
5653
unsigned Type) const {
@@ -167,8 +164,7 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target,
167164
case MCSymbolRefExpr::VK_GOT:
168165
return ELF::R_ARM_GOT_BREL;
169166
case MCSymbolRefExpr::VK_TLSGD:
170-
// LDC
171-
return isAndroid ? ELF::R_ARM_GOT_PREL : ELF::R_ARM_TLS_GD32;
167+
return ELF::R_ARM_TLS_GD32;
172168
case MCSymbolRefExpr::VK_TPOFF:
173169
return ELF::R_ARM_TLS_LE32;
174170
case MCSymbolRefExpr::VK_GOTTPOFF:
@@ -241,6 +237,6 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target,
241237
}
242238

243239
std::unique_ptr<MCObjectTargetWriter>
244-
llvm::createARMELFObjectWriter(uint8_t OSABI, bool IsAndroid) {
245-
return llvm::make_unique<ARMELFObjectWriter>(OSABI, IsAndroid);
240+
llvm::createARMELFObjectWriter(uint8_t OSABI) {
241+
return llvm::make_unique<ARMELFObjectWriter>(OSABI);
246242
}

lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ MCStreamer *createARMWinCOFFStreamer(MCContext &Context,
8787
bool IncrementalLinkerCompatible);
8888

8989
/// Construct an ELF Mach-O object writer.
90-
std::unique_ptr<MCObjectTargetWriter> createARMELFObjectWriter(uint8_t OSABI,
91-
bool IsAndroid);
90+
std::unique_ptr<MCObjectTargetWriter> createARMELFObjectWriter(uint8_t OSABI);
9291

9392
/// Construct an ARM Mach-O object writer.
9493
std::unique_ptr<MCObjectTargetWriter>

lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "llvm/MC/MCELFObjectWriter.h"
1616
#include "llvm/MC/MCExpr.h"
1717
#include "llvm/MC/MCFixup.h"
18-
#include "llvm/MC/MCObjectFileInfo.h" // LDC
1918
#include "llvm/MC/MCObjectWriter.h"
2019
#include "llvm/MC/MCValue.h"
2120
#include "llvm/Support/ErrorHandling.h"
@@ -261,12 +260,7 @@ static unsigned getRelocType32(MCContext &Ctx,
261260
case MCSymbolRefExpr::VK_TLSGD:
262261
assert(Type == RT32_32);
263262
assert(!IsPCRel);
264-
// LDC
265-
{
266-
auto ofi = Ctx.getObjectFileInfo();
267-
return ofi && ofi->getTargetTriple().isAndroid() ? ELF::R_386_GOT32
268-
: ELF::R_386_TLS_GD;
269-
}
263+
return ELF::R_386_TLS_GD;
270264
case MCSymbolRefExpr::VK_GOTTPOFF:
271265
assert(Type == RT32_32);
272266
assert(!IsPCRel);

0 commit comments

Comments
 (0)