mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-21 13:33:26 +00:00
make MachineModuleInfoMachO hold non-const MCSymbol*'s instead
of const ones. non-const ones aren't very useful, because you can't even, say, emit them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95205 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5669e30097
commit
d269a6e460
@ -25,39 +25,38 @@ namespace llvm {
|
||||
class MachineModuleInfoMachO : public MachineModuleInfoImpl {
|
||||
/// FnStubs - Darwin '$stub' stubs. The key is something like "Lfoo$stub",
|
||||
/// the value is something like "_foo".
|
||||
DenseMap<const MCSymbol*, const MCSymbol*> FnStubs;
|
||||
DenseMap<MCSymbol*, MCSymbol*> FnStubs;
|
||||
|
||||
/// GVStubs - Darwin '$non_lazy_ptr' stubs. The key is something like
|
||||
/// "Lfoo$non_lazy_ptr", the value is something like "_foo".
|
||||
DenseMap<const MCSymbol*, const MCSymbol*> GVStubs;
|
||||
DenseMap<MCSymbol*, MCSymbol*> 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.
|
||||
DenseMap<const MCSymbol*, const MCSymbol*> HiddenGVStubs;
|
||||
DenseMap<MCSymbol*, MCSymbol*> HiddenGVStubs;
|
||||
|
||||
virtual void Anchor(); // Out of line virtual method.
|
||||
public:
|
||||
MachineModuleInfoMachO(const MachineModuleInfo &) {}
|
||||
|
||||
const MCSymbol *&getFnStubEntry(const MCSymbol *Sym) {
|
||||
MCSymbol *&getFnStubEntry(MCSymbol *Sym) {
|
||||
assert(Sym && "Key cannot be null");
|
||||
return FnStubs[Sym];
|
||||
}
|
||||
|
||||
const MCSymbol *&getGVStubEntry(const MCSymbol *Sym) {
|
||||
MCSymbol *&getGVStubEntry(MCSymbol *Sym) {
|
||||
assert(Sym && "Key cannot be null");
|
||||
return GVStubs[Sym];
|
||||
}
|
||||
|
||||
const MCSymbol *&getHiddenGVStubEntry(const MCSymbol *Sym) {
|
||||
MCSymbol *&getHiddenGVStubEntry(MCSymbol *Sym) {
|
||||
assert(Sym && "Key cannot be null");
|
||||
return HiddenGVStubs[Sym];
|
||||
}
|
||||
|
||||
/// Accessor methods to return the set of stubs in sorted order.
|
||||
typedef std::vector<std::pair<const MCSymbol*, const MCSymbol*> >
|
||||
SymbolListTy;
|
||||
typedef std::vector<std::pair<MCSymbol*, MCSymbol*> > SymbolListTy;
|
||||
|
||||
SymbolListTy GetFnStubList() const {
|
||||
return GetSortedStubs(FnStubs);
|
||||
@ -71,7 +70,7 @@ namespace llvm {
|
||||
|
||||
private:
|
||||
static SymbolListTy
|
||||
GetSortedStubs(const DenseMap<const MCSymbol*, const MCSymbol*> &Map);
|
||||
GetSortedStubs(const DenseMap<MCSymbol*, MCSymbol*> &Map);
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -26,17 +26,17 @@ void MachineModuleInfoMachO::Anchor() {}
|
||||
|
||||
static int SortSymbolPair(const void *LHS, const void *RHS) {
|
||||
const MCSymbol *LHSS =
|
||||
((const std::pair<const MCSymbol*, const MCSymbol*>*)LHS)->first;
|
||||
((const std::pair<MCSymbol*, MCSymbol*>*)LHS)->first;
|
||||
const MCSymbol *RHSS =
|
||||
((const std::pair<const MCSymbol*, const MCSymbol*>*)RHS)->first;
|
||||
((const std::pair<MCSymbol*, MCSymbol*>*)RHS)->first;
|
||||
return LHSS->getName().compare(RHSS->getName());
|
||||
}
|
||||
|
||||
/// GetSortedStubs - Return the entries from a DenseMap in a deterministic
|
||||
/// sorted orer.
|
||||
MachineModuleInfoMachO::SymbolListTy
|
||||
MachineModuleInfoMachO::GetSortedStubs(const DenseMap<const MCSymbol*,
|
||||
const MCSymbol*> &Map) {
|
||||
MachineModuleInfoMachO::GetSortedStubs(const DenseMap<MCSymbol*,
|
||||
MCSymbol*> &Map) {
|
||||
MachineModuleInfoMachO::SymbolListTy List(Map.begin(), Map.end());
|
||||
if (!List.empty())
|
||||
qsort(&List[0], List.size(), sizeof(List[0]), SortSymbolPair);
|
||||
|
@ -200,7 +200,7 @@ namespace {
|
||||
|
||||
MachineModuleInfoMachO &MMIMachO =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>();
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *&StubSym =
|
||||
GV->hasHiddenVisibility() ? MMIMachO.getHiddenGVStubEntry(Sym) :
|
||||
MMIMachO.getGVStubEntry(Sym);
|
||||
if (StubSym == 0)
|
||||
|
@ -198,7 +198,7 @@ namespace {
|
||||
if (GV->isDeclaration() || GV->isWeakForLinker()) {
|
||||
// Dynamically-resolved functions need a stub for the function.
|
||||
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$stub");
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||
if (StubSym == 0)
|
||||
StubSym = GetGlobalValueSymbol(GV);
|
||||
@ -211,8 +211,8 @@ namespace {
|
||||
TempNameStr += StringRef(MO.getSymbolName());
|
||||
TempNameStr += StringRef("$stub");
|
||||
|
||||
const MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str());
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str());
|
||||
MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||
if (StubSym == 0)
|
||||
StubSym = GetExternalSymbolSymbol(MO.getSymbolName());
|
||||
@ -401,10 +401,10 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
||||
return;
|
||||
}
|
||||
|
||||
const MCSymbol *NLPSym =
|
||||
MCSymbol *NLPSym =
|
||||
OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+
|
||||
MO.getSymbolName()+"$non_lazy_ptr");
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(NLPSym);
|
||||
if (StubSym == 0)
|
||||
StubSym = GetExternalSymbolSymbol(MO.getSymbolName());
|
||||
@ -422,7 +422,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
||||
(GV->isDeclaration() || GV->isWeakForLinker())) {
|
||||
if (!GV->hasHiddenVisibility()) {
|
||||
SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(SymToPrint);
|
||||
if (StubSym == 0)
|
||||
StubSym = GetGlobalValueSymbol(GV);
|
||||
@ -430,7 +430,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
||||
GV->hasAvailableExternallyLinkage()) {
|
||||
SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().
|
||||
getHiddenGVStubEntry(SymToPrint);
|
||||
if (StubSym == 0)
|
||||
@ -780,9 +780,8 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
|
||||
for (std::vector<Function *>::const_iterator I = Personalities.begin(),
|
||||
E = Personalities.end(); I != E; ++I) {
|
||||
if (*I) {
|
||||
const MCSymbol *NLPSym =
|
||||
GetSymbolWithGlobalValueBase(*I, "$non_lazy_ptr");
|
||||
const MCSymbol *&StubSym = MMIMacho.getGVStubEntry(NLPSym);
|
||||
MCSymbol *NLPSym = GetSymbolWithGlobalValueBase(*I, "$non_lazy_ptr");
|
||||
MCSymbol *&StubSym = MMIMacho.getGVStubEntry(NLPSym);
|
||||
StubSym = GetGlobalValueSymbol(*I);
|
||||
}
|
||||
}
|
||||
|
@ -132,20 +132,20 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
||||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
|
||||
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
|
||||
if (StubSym == 0)
|
||||
StubSym = GetGlobalValueSymbol(GV);
|
||||
|
||||
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
|
||||
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(Sym);
|
||||
if (StubSym == 0)
|
||||
StubSym = GetGlobalValueSymbol(GV);
|
||||
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
|
||||
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$stub");
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||
if (StubSym == 0)
|
||||
StubSym = GetGlobalValueSymbol(GV);
|
||||
@ -167,8 +167,8 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
||||
TempNameStr += StringRef(MO.getSymbolName());
|
||||
TempNameStr += StringRef("$stub");
|
||||
|
||||
const MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str());
|
||||
const MCSymbol *&StubSym =
|
||||
MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str());
|
||||
MCSymbol *&StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||
if (StubSym == 0) {
|
||||
TempNameStr.erase(TempNameStr.end()-5, TempNameStr.end());
|
||||
|
@ -82,7 +82,7 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const {
|
||||
Name += "$non_lazy_ptr";
|
||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
||||
|
||||
const MCSymbol *&StubSym = getMachOMMI().getGVStubEntry(Sym);
|
||||
MCSymbol *&StubSym = getMachOMMI().getGVStubEntry(Sym);
|
||||
if (StubSym == 0)
|
||||
StubSym = AsmPrinter.GetGlobalValueSymbol(GV);
|
||||
return Sym;
|
||||
@ -90,7 +90,7 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const {
|
||||
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: {
|
||||
Name += "$non_lazy_ptr";
|
||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
||||
const MCSymbol *&StubSym = getMachOMMI().getHiddenGVStubEntry(Sym);
|
||||
MCSymbol *&StubSym = getMachOMMI().getHiddenGVStubEntry(Sym);
|
||||
if (StubSym == 0)
|
||||
StubSym = AsmPrinter.GetGlobalValueSymbol(GV);
|
||||
return Sym;
|
||||
@ -98,7 +98,7 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const {
|
||||
case X86II::MO_DARWIN_STUB: {
|
||||
Name += "$stub";
|
||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
||||
const MCSymbol *&StubSym = getMachOMMI().getFnStubEntry(Sym);
|
||||
MCSymbol *&StubSym = getMachOMMI().getFnStubEntry(Sym);
|
||||
if (StubSym == 0)
|
||||
StubSym = AsmPrinter.GetGlobalValueSymbol(GV);
|
||||
return Sym;
|
||||
@ -139,7 +139,7 @@ GetExternalSymbolSymbol(const MachineOperand &MO) const {
|
||||
case X86II::MO_DARWIN_STUB: {
|
||||
Name += "$stub";
|
||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
||||
const MCSymbol *&StubSym = getMachOMMI().getFnStubEntry(Sym);
|
||||
MCSymbol *&StubSym = getMachOMMI().getFnStubEntry(Sym);
|
||||
|
||||
if (StubSym == 0) {
|
||||
Name.erase(Name.end()-5, Name.end());
|
||||
|
@ -35,7 +35,7 @@ getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
// Add information about the stub reference to MachOMMI so that the stub gets
|
||||
// emitted by the asmprinter.
|
||||
MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str());
|
||||
const MCSymbol *&StubSym = MachOMMI.getGVStubEntry(Sym);
|
||||
MCSymbol *&StubSym = MachOMMI.getGVStubEntry(Sym);
|
||||
if (StubSym == 0) {
|
||||
Name.clear();
|
||||
Mang->getNameWithPrefix(Name, GV, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user