From 3a373d544618593dc45a12fafe2a3f0ef460a46e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 17 May 2016 16:01:32 +0000 Subject: [PATCH] Simplify handling of hidden stub. Since r207518 they are printed exactly like non-hidden stubs on x86 and since r207517 on ARM. This means we can use a single set for all stubs in those platforms. llvm-svn: 269776 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 4 +-- lib/Target/ARM/ARMAsmPrinter.cpp | 18 ++------------ lib/Target/X86/MCTargetDesc/X86BaseInfo.h | 6 ----- lib/Target/X86/X86AsmPrinter.cpp | 26 +------------------- lib/Target/X86/X86InstrInfo.cpp | 1 - lib/Target/X86/X86InstrInfo.h | 2 -- lib/Target/X86/X86MCInstLower.cpp | 14 ----------- lib/Target/X86/X86Subtarget.cpp | 6 ++--- test/CodeGen/X86/indirect-hidden.ll | 4 +-- 9 files changed, 9 insertions(+), 72 deletions(-) diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 6664fb366ca..f7ba62ff231 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -686,9 +686,7 @@ const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference( // Add information about the stub reference to MachOMMI so that the stub // gets emitted by the asmprinter. - MachineModuleInfoImpl::StubValueTy &StubSym = - GV->hasHiddenVisibility() ? MachOMMI.getHiddenGVStubEntry(SSym) : - MachOMMI.getGVStubEntry(SSym); + MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym); if (!StubSym.getPointer()) { MCSymbol *Sym = TM.getSymbol(GV, Mang); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index 8e064714108..71823e47009 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -515,18 +515,6 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) { OutStreamer->AddBlankLine(); } - Stubs = MMIMacho.GetHiddenGVStubList(); - if (!Stubs.empty()) { - OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); - EmitAlignment(2); - - for (auto &Stub : Stubs) - emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second); - - Stubs.clear(); - OutStreamer->AddBlankLine(); - } - Stubs = MMIMacho.GetThreadLocalGVStubList(); if (!Stubs.empty()) { // Switch with ".non_lazy_symbol_pointer" directive. @@ -927,10 +915,8 @@ MCSymbol *ARMAsmPrinter::GetARMGVSymbol(const GlobalValue *GV, MachineModuleInfoMachO &MMIMachO = MMI->getObjFileInfo(); MachineModuleInfoImpl::StubValueTy &StubSym = - GV->isThreadLocal() - ? MMIMachO.getThreadLocalGVStubEntry(MCSym) - : (GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(MCSym) - : MMIMachO.getGVStubEntry(MCSym)); + GV->isThreadLocal() ? MMIMachO.getThreadLocalGVStubEntry(MCSym) + : MMIMachO.getGVStubEntry(MCSym); if (!StubSym.getPointer()) StubSym = MachineModuleInfoImpl::StubValueTy(getSymbol(GV), diff --git a/lib/Target/X86/MCTargetDesc/X86BaseInfo.h b/lib/Target/X86/MCTargetDesc/X86BaseInfo.h index a1fa6b79811..865efb37454 100644 --- a/lib/Target/X86/MCTargetDesc/X86BaseInfo.h +++ b/lib/Target/X86/MCTargetDesc/X86BaseInfo.h @@ -201,12 +201,6 @@ namespace X86II { /// a PIC-base-relative reference to a non-hidden dyld lazy pointer stub. MO_DARWIN_NONLAZY_PIC_BASE, - /// MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this - /// indicates that the reference is actually to "FOO$non_lazy_ptr -PICBASE", - /// which is a PIC-base-relative reference to a hidden dyld lazy pointer - /// stub. - MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE, - /// MO_TLVP - On a symbol operand this indicates that the immediate is /// some TLS offset. /// diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 0a00463f8bf..d0a8b61d88a 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -91,8 +91,7 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO, if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) GVSym = P.getSymbolWithGlobalValueBase(GV, "$stub"); else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || - MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE || - MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE) + MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) GVSym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); else GVSym = P.getSymbol(GV); @@ -110,14 +109,6 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO, if (!StubSym.getPointer()) StubSym = MachineModuleInfoImpl:: StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage()); - } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){ - MCSymbol *Sym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); - MachineModuleInfoImpl::StubValueTy &StubSym = - P.MMI->getObjFileInfo().getHiddenGVStubEntry( - Sym); - if (!StubSym.getPointer()) - StubSym = MachineModuleInfoImpl:: - StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage()); } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { MCSymbol *Sym = P.getSymbolWithGlobalValueBase(GV, "$stub"); MachineModuleInfoImpl::StubValueTy &StubSym = @@ -158,7 +149,6 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO, break; case X86II::MO_PIC_BASE_OFFSET: case X86II::MO_DARWIN_NONLAZY_PIC_BASE: - case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: O << '-'; P.MF->getPICBaseSymbol()->print(O, P.MAI); break; @@ -642,20 +632,6 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { OutStreamer->AddBlankLine(); } - Stubs = MMIMacho.GetHiddenGVStubList(); - if (!Stubs.empty()) { - MCSection *TheSection = OutContext.getMachOSection( - "__IMPORT", "__pointers", MachO::S_NON_LAZY_SYMBOL_POINTERS, - SectionKind::getMetadata()); - OutStreamer->SwitchSection(TheSection); - - for (auto &Stub : Stubs) - emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second); - - Stubs.clear(); - OutStreamer->AddBlankLine(); - } - SM.serializeToStackMapSection(); FM.serializeToFaultMapSection(); diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index acf042f242f..422c9de9bb3 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -7333,7 +7333,6 @@ X86InstrInfo::getSerializableDirectMachineOperandTargetFlags() const { {MO_DARWIN_STUB, "x86-darwin-stub"}, {MO_DARWIN_NONLAZY, "x86-darwin-nonlazy"}, {MO_DARWIN_NONLAZY_PIC_BASE, "x86-darwin-nonlazy-pic-base"}, - {MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE, "x86-darwin-hidden-nonlazy-pic-base"}, {MO_TLVP, "x86-tlvp"}, {MO_TLVP_PIC_BASE, "x86-tlvp-pic-base"}, {MO_SECREL, "x86-secrel"}}; diff --git a/lib/Target/X86/X86InstrInfo.h b/lib/Target/X86/X86InstrInfo.h index 5a82c161b27..cadfd9e23cc 100644 --- a/lib/Target/X86/X86InstrInfo.h +++ b/lib/Target/X86/X86InstrInfo.h @@ -90,7 +90,6 @@ inline static bool isGlobalStubReference(unsigned char TargetFlag) { case X86II::MO_GOT: // normal GOT reference. case X86II::MO_DARWIN_NONLAZY_PIC_BASE: // Normal $non_lazy_ptr ref. case X86II::MO_DARWIN_NONLAZY: // Normal $non_lazy_ptr ref. - case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: // Hidden $non_lazy_ptr ref. return true; default: return false; @@ -106,7 +105,6 @@ inline static bool isGlobalRelativeToPICBase(unsigned char TargetFlag) { case X86II::MO_GOT: // isPICStyleGOT: other global. case X86II::MO_PIC_BASE_OFFSET: // Darwin local global. case X86II::MO_DARWIN_NONLAZY_PIC_BASE: // Darwin/32 external global. - case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: // Darwin/32 hidden global. case X86II::MO_TLVP: // ??? Pretty sure.. return true; default: diff --git a/lib/Target/X86/X86MCInstLower.cpp b/lib/Target/X86/X86MCInstLower.cpp index 6e8b09f6db8..0111d7fbdc2 100644 --- a/lib/Target/X86/X86MCInstLower.cpp +++ b/lib/Target/X86/X86MCInstLower.cpp @@ -132,7 +132,6 @@ GetSymbolFromOperand(const MachineOperand &MO) const { break; case X86II::MO_DARWIN_NONLAZY: case X86II::MO_DARWIN_NONLAZY_PIC_BASE: - case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: Suffix = "$non_lazy_ptr"; break; } @@ -176,18 +175,6 @@ GetSymbolFromOperand(const MachineOperand &MO) const { } break; } - case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: { - MachineModuleInfoImpl::StubValueTy &StubSym = - getMachOMMI().getHiddenGVStubEntry(Sym); - if (!StubSym.getPointer()) { - assert(MO.isGlobal() && "Extern symbol not handled yet"); - StubSym = - MachineModuleInfoImpl:: - StubValueTy(AsmPrinter.getSymbol(MO.getGlobal()), - !MO.getGlobal()->hasInternalLinkage()); - } - break; - } case X86II::MO_DARWIN_STUB: { MachineModuleInfoImpl::StubValueTy &StubSym = getMachOMMI().getFnStubEntry(Sym); @@ -252,7 +239,6 @@ MCOperand X86MCInstLower::LowerSymbolOperand(const MachineOperand &MO, case X86II::MO_PLT: RefKind = MCSymbolRefExpr::VK_PLT; break; case X86II::MO_PIC_BASE_OFFSET: case X86II::MO_DARWIN_NONLAZY_PIC_BASE: - case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: Expr = MCSymbolRefExpr::create(Sym, Ctx); // Subtract the pic base. Expr = MCBinaryExpr::createSub(Expr, diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index 896856c3489..dde29a0c083 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -116,14 +116,14 @@ ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const { // Unless we have a symbol with hidden visibility, we have to go through a // normal $non_lazy_ptr stub because this symbol might be resolved late. - if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference. + if (!GV->hasHiddenVisibility()) // $non_lazy_ptr reference. return X86II::MO_DARWIN_NONLAZY_PIC_BASE; // If symbol visibility is hidden, we have a stub for common symbol // references and external declarations. if (GV->isDeclarationForLinker() || GV->hasCommonLinkage()) { - // Hidden $non_lazy_ptr reference. - return X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE; + // $non_lazy_ptr reference. + return X86II::MO_DARWIN_NONLAZY_PIC_BASE; } // Otherwise, no stub. diff --git a/test/CodeGen/X86/indirect-hidden.ll b/test/CodeGen/X86/indirect-hidden.ll index 9e1b7d37355..5f3885d00e5 100644 --- a/test/CodeGen/X86/indirect-hidden.ll +++ b/test/CodeGen/X86/indirect-hidden.ll @@ -35,9 +35,9 @@ declare i32 @__gxx_personality_v0(...) ; CHECK: .section __IMPORT,__pointers,non_lazy_symbol_pointers ; CHECK-NOT: __DATA,__data -; CHECK: .indirect_symbol _normal_typeid +; CHECK: .indirect_symbol _hidden_typeid ; CHECK-NEXT: .long 0 ; CHECK-NOT: __DATA,__data -; CHECK: .indirect_symbol _hidden_typeid +; CHECK: .indirect_symbol _normal_typeid ; CHECK-NEXT: .long 0