aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-20 21:16:14 +0000
committerChris Lattner <sabre@nondot.org>2010-01-20 21:16:14 +0000
commitd3ec0b5446441f39988db4107cd37f6e7349f399 (patch)
tree0a25eea2c70bfb5945c8fdcda8edb9666289fa5f
parent0e94facb5f59fe326ea00f00aaf53b7273e7d7ce (diff)
eliminate the GVStubs and HiddenGVStubs maps, and use
MachineModuleInfoMachO instead. This eliminates two sources of nondeterministic output in the ppc backend, but function stubs are still bad. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94029 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp62
1 files changed, 39 insertions, 23 deletions
diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
index f0906c2783..bee5c11cb1 100644
--- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
@@ -27,10 +27,10 @@
#include "llvm/Assembly/Writer.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DwarfWriter.h"
-#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSectionMachO.h"
@@ -95,7 +95,7 @@ namespace {
};
DenseMap<const MCSymbol*, FnStubInfo> FnStubs;
- DenseMap<const MCSymbol*, const MCSymbol*> GVStubs, HiddenGVStubs, TOC;
+ DenseMap<const MCSymbol*, const MCSymbol*> TOC;
const PPCSubtarget &Subtarget;
uint64_t LabelID;
public:
@@ -424,15 +424,19 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
return;
case MachineOperand::MO_ExternalSymbol: {
// Computing the address of an external symbol, not calling it.
- const MCSymbol *SymName = GetExternalSymbolSymbol(MO.getSymbolName());
if (TM.getRelocationModel() == Reloc::Static) {
- O << *SymName;
+ O << *GetExternalSymbolSymbol(MO.getSymbolName());
return;
}
+
const MCSymbol *NLPSym =
OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+
MO.getSymbolName()+"$non_lazy_ptr");
- GVStubs[SymName] = NLPSym;
+ const MCSymbol *&StubSym =
+ MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(NLPSym);
+ if (StubSym == 0)
+ StubSym = GetExternalSymbolSymbol(MO.getSymbolName());
+
O << *NLPSym;
return;
}
@@ -446,11 +450,19 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
(GV->isDeclaration() || GV->isWeakForLinker())) {
if (!GV->hasHiddenVisibility()) {
SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
- GVStubs[GetGlobalValueSymbol(GV)] = SymToPrint;
+ const MCSymbol *&StubSym =
+ MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(SymToPrint);
+ if (StubSym == 0)
+ StubSym = GetGlobalValueSymbol(GV);
} else if (GV->isDeclaration() || GV->hasCommonLinkage() ||
GV->hasAvailableExternallyLinkage()) {
SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
- HiddenGVStubs[GetGlobalValueSymbol(GV)] = SymToPrint;
+
+ const MCSymbol *&StubSym =
+ MMI->getObjFileInfo<MachineModuleInfoMachO>().
+ getHiddenGVStubEntry(SymToPrint);
+ if (StubSym == 0)
+ StubSym = GetGlobalValueSymbol(GV);
} else {
SymToPrint = GetGlobalValueSymbol(GV);
}
@@ -838,12 +850,12 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
// Darwin/PPC always uses mach-o.
TargetLoweringObjectFileMachO &TLOFMacho =
static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
-
+ MachineModuleInfoMachO &MMIMacho =
+ MMI->getObjFileInfo<MachineModuleInfoMachO>();
const MCSection *LSPSection = 0;
if (!FnStubs.empty()) // .lazy_symbol_pointer
LSPSection = TLOFMacho.getLazySymbolPointerSection();
-
// Output stubs for dynamically-linked functions
if (TM.getRelocationModel() == Reloc::PIC_ && !FnStubs.empty()) {
@@ -912,35 +924,39 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
const std::vector<Function *> &Personalities = MMI->getPersonalities();
for (std::vector<Function *>::const_iterator I = Personalities.begin(),
E = Personalities.end(); I != E; ++I) {
- if (*I)
- GVStubs[GetGlobalValueSymbol(*I)] =
+ if (*I) {
+ const MCSymbol *NLPSym =
GetSymbolWithGlobalValueBase(*I, "$non_lazy_ptr");
+ const MCSymbol *&StubSym = MMIMacho.getGVStubEntry(NLPSym);
+ StubSym = GetGlobalValueSymbol(*I);
+ }
}
}
+ // Output stubs for dynamically-linked functions.
+ MachineModuleInfoMachO::SymbolListTy Stubs = MMIMacho.GetGVStubList();
+
// Output macho stubs for external and common global variables.
- if (!GVStubs.empty()) {
+ if (!Stubs.empty()) {
// Switch with ".non_lazy_symbol_pointer" directive.
OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
EmitAlignment(isPPC64 ? 3 : 2);
- // FIXME: This is nondeterminstic.
- for (DenseMap<const MCSymbol *, const MCSymbol *>::iterator
- I = GVStubs.begin(), E = GVStubs.end(); I != E; ++I) {
- O << *I->second << ":\n";
- O << "\t.indirect_symbol " << *I->first << '\n';
+ for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
+ O << *Stubs[i].first << ":\n";
+ O << "\t.indirect_symbol " << *Stubs[i].second << '\n';
O << (isPPC64 ? "\t.quad\t0\n" : "\t.long\t0\n");
}
}
- if (!HiddenGVStubs.empty()) {
+ Stubs = MMIMacho.GetHiddenGVStubList();
+ if (!Stubs.empty()) {
OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
EmitAlignment(isPPC64 ? 3 : 2);
- // FIXME: This is nondeterminstic.
- for (DenseMap<const MCSymbol *, const MCSymbol *>::iterator
- I = HiddenGVStubs.begin(), E = HiddenGVStubs.end(); I != E; ++I) {
- O << *I->second << ":\n";
- O << (isPPC64 ? "\t.quad\t" : "\t.long\t") << *I->first << '\n';
+
+ for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
+ O << *Stubs[i].first << ":\n";
+ O << (isPPC64 ? "\t.quad\t" : "\t.long\t") << *Stubs[i].second << '\n';
}
}