From 8571aa3d5d9302c119541f0b56205f6a4ad33ca2 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 20 May 2016 12:00:52 +0000 Subject: [PATCH] Simplify handling of hidden stubs on PowerPC. We now handle them just like non hidden ones. This was already the case on x86 (r207518) and arm (r207517). llvm-svn: 270205 --- .../llvm/CodeGen/MachineModuleInfoImpls.h | 12 ----------- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 21 +------------------ llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 8 +++---- llvm/test/CodeGen/PowerPC/indirect-hidden.ll | 8 +++---- 4 files changed, 7 insertions(+), 42 deletions(-) diff --git a/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h b/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h index 0561ef5c0c017..52721fab88b59 100644 --- a/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h +++ b/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h @@ -32,12 +32,6 @@ class MachineModuleInfoMachO : public MachineModuleInfoImpl { /// is true if this GV is external. DenseMap GVStubs; - /// HiddenGVStubs - Darwin '$non_lazy_ptr' stubs. The key is something like - /// "Lfoo$non_lazy_ptr", the value is something like "_foo". Unlike GVStubs - /// these are for things with hidden visibility. The extra bit is true if - /// this GV is external. - DenseMap HiddenGVStubs; - /// ThreadLocalGVStubs - Darwin '$non_lazy_ptr' stubs. The key is something /// like "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra /// bit is true if this GV is external. @@ -57,11 +51,6 @@ class MachineModuleInfoMachO : public MachineModuleInfoImpl { return GVStubs[Sym]; } - StubValueTy &getHiddenGVStubEntry(MCSymbol *Sym) { - assert(Sym && "Key cannot be null"); - return HiddenGVStubs[Sym]; - } - StubValueTy &getThreadLocalGVStubEntry(MCSymbol *Sym) { assert(Sym && "Key cannot be null"); return ThreadLocalGVStubs[Sym]; @@ -70,7 +59,6 @@ class MachineModuleInfoMachO : public MachineModuleInfoImpl { /// Accessor methods to return the set of stubs in sorted order. SymbolListTy GetFnStubList() { return getSortedStubs(FnStubs); } SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); } - SymbolListTy GetHiddenGVStubList() { return getSortedStubs(HiddenGVStubs); } SymbolListTy GetThreadLocalGVStubList() { return getSortedStubs(ThreadLocalGVStubs); } diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index ecf184e4b0dfa..bb1ab2e98891f 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -214,7 +214,7 @@ void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, SymToPrint = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); MachineModuleInfoImpl::StubValueTy &StubSym = - MMI->getObjFileInfo().getHiddenGVStubEntry( + MMI->getObjFileInfo().getGVStubEntry( SymToPrint); if (!StubSym.getPointer()) StubSym = MachineModuleInfoImpl:: @@ -1574,25 +1574,6 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { OutStreamer->AddBlankLine(); } - Stubs = MMIMacho.GetHiddenGVStubList(); - if (!Stubs.empty()) { - OutStreamer->SwitchSection(getObjFileLowering().getDataSection()); - EmitAlignment(isPPC64 ? 3 : 2); - - for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { - // L_foo$stub: - OutStreamer->EmitLabel(Stubs[i].first); - // .long _foo - OutStreamer->EmitValue(MCSymbolRefExpr:: - create(Stubs[i].second.getPointer(), - OutContext), - isPPC64 ? 8 : 4/*size*/); - } - - Stubs.clear(); - OutStreamer->AddBlankLine(); - } - // Funny Darwin hack: This flag tells the linker that no global symbols // contain code that falls through to other global symbols (e.g. the obvious // implementation of multiple entry points). If this doesn't occur, the diff --git a/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp b/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp index 44a692d4bb42d..1fcff52f1c90d 100644 --- a/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp +++ b/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp @@ -94,11 +94,9 @@ static MCSymbol *GetSymbolFromOperand(const MachineOperand &MO, AsmPrinter &AP){ // then add the suffix. if (MO.getTargetFlags() & PPCII::MO_NLP_FLAG) { MachineModuleInfoMachO &MachO = getMachOMMI(AP); - - MachineModuleInfoImpl::StubValueTy &StubSym = - (MO.getTargetFlags() & PPCII::MO_NLP_HIDDEN_FLAG) ? - MachO.getHiddenGVStubEntry(Sym) : MachO.getGVStubEntry(Sym); - + + MachineModuleInfoImpl::StubValueTy &StubSym = MachO.getGVStubEntry(Sym); + if (!StubSym.getPointer()) { assert(MO.isGlobal() && "Extern symbol not handled yet"); StubSym = MachineModuleInfoImpl:: diff --git a/llvm/test/CodeGen/PowerPC/indirect-hidden.ll b/llvm/test/CodeGen/PowerPC/indirect-hidden.ll index eba46c2fa7f84..5ef8b6df4b092 100644 --- a/llvm/test/CodeGen/PowerPC/indirect-hidden.ll +++ b/llvm/test/CodeGen/PowerPC/indirect-hidden.ll @@ -13,11 +13,9 @@ define i32* @get_b() { ; CHECK: .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers ; CHECK-NEXT: .p2align 2 +; CHECK-NEXT: L_a$non_lazy_ptr: +; CHECK-NEXT: .indirect_symbol _a +; CHECK-NEXT: .long 0 ; CHECK-NEXT: L_b$non_lazy_ptr: ; CHECK-NEXT: .indirect_symbol _b ; CHECK-NEXT: .long 0 - -; CHECK: .section __DATA,__data -; CHECK-NEXT: .p2align 2 -; CHECK-NEXT: L_a$non_lazy_ptr: -; CHECK-NEXT: .long _a