Skip to content

Commit

Permalink
Simplify handling of hidden stubs on PowerPC.
Browse files Browse the repository at this point in the history
We now handle them just like non hidden ones. This was already the case
on x86 (r207518) and arm (r207517).

llvm-svn: 270205
  • Loading branch information
espindola committed May 20, 2016
1 parent ed28d41 commit 8571aa3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 42 deletions.
12 changes: 0 additions & 12 deletions llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
Expand Up @@ -32,12 +32,6 @@ class MachineModuleInfoMachO : public MachineModuleInfoImpl {
/// is true if this GV is external.
DenseMap<MCSymbol *, StubValueTy> 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<MCSymbol *, StubValueTy> 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.
Expand All @@ -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];
Expand All @@ -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);
}
Expand Down
21 changes: 1 addition & 20 deletions llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Expand Up @@ -214,7 +214,7 @@ void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
SymToPrint = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");

MachineModuleInfoImpl::StubValueTy &StubSym =
MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(
MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(
SymToPrint);
if (!StubSym.getPointer())
StubSym = MachineModuleInfoImpl::
Expand Down Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
Expand Up @@ -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::
Expand Down
8 changes: 3 additions & 5 deletions llvm/test/CodeGen/PowerPC/indirect-hidden.ll
Expand Up @@ -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

0 comments on commit 8571aa3

Please sign in to comment.