mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
rename GetPrivateGlobalValueSymbolStub -> GetSymbolWithGlobalValueBase,
and add an explicit ForcePrivate argument. Switch FunctionEHFrameInfo to be MCSymbol based instead of string based. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93646 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -344,11 +344,12 @@ namespace llvm {
|
|||||||
/// value.
|
/// value.
|
||||||
MCSymbol *GetGlobalValueSymbol(const GlobalValue *GV) const;
|
MCSymbol *GetGlobalValueSymbol(const GlobalValue *GV) const;
|
||||||
|
|
||||||
/// GetPrivateGlobalValueSymbolStub - Return the MCSymbol for a symbol with
|
/// GetSymbolWithGlobalValueBase - Return the MCSymbol for a symbol with
|
||||||
/// global value name as its base, with the specified suffix, and where the
|
/// global value name as its base, with the specified suffix, and where the
|
||||||
/// symbol is forced to have private linkage.
|
/// symbol is forced to have private linkage if ForcePrivate is true.
|
||||||
MCSymbol *GetPrivateGlobalValueSymbolStub(const GlobalValue *GV,
|
MCSymbol *GetSymbolWithGlobalValueBase(const GlobalValue *GV,
|
||||||
StringRef Suffix) const;
|
StringRef Suffix,
|
||||||
|
bool ForcePrivate = true) const;
|
||||||
|
|
||||||
/// GetExternalSymbolSymbol - Return the MCSymbol for the specified
|
/// GetExternalSymbolSymbol - Return the MCSymbol for the specified
|
||||||
/// ExternalSymbol.
|
/// ExternalSymbol.
|
||||||
|
@ -1719,13 +1719,14 @@ MCSymbol *AsmPrinter::GetGlobalValueSymbol(const GlobalValue *GV) const {
|
|||||||
return OutContext.GetOrCreateSymbol(NameStr.str());
|
return OutContext.GetOrCreateSymbol(NameStr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GetPrivateGlobalValueSymbolStub - Return the MCSymbol for a symbol with
|
/// GetSymbolWithGlobalValueBase - Return the MCSymbol for a symbol with
|
||||||
/// global value name as its base, with the specified suffix, and where the
|
/// global value name as its base, with the specified suffix, and where the
|
||||||
/// symbol is forced to have private linkage.
|
/// symbol is forced to have private linkage if ForcePrivate is true.
|
||||||
MCSymbol *AsmPrinter::GetPrivateGlobalValueSymbolStub(const GlobalValue *GV,
|
MCSymbol *AsmPrinter::GetSymbolWithGlobalValueBase(const GlobalValue *GV,
|
||||||
StringRef Suffix) const {
|
StringRef Suffix,
|
||||||
|
bool ForcePrivate) const {
|
||||||
SmallString<60> NameStr;
|
SmallString<60> NameStr;
|
||||||
Mang->getNameWithPrefix(NameStr, GV, true);
|
Mang->getNameWithPrefix(NameStr, GV, ForcePrivate);
|
||||||
NameStr.append(Suffix.begin(), Suffix.end());
|
NameStr.append(Suffix.begin(), Suffix.end());
|
||||||
return OutContext.GetOrCreateSymbol(NameStr.str());
|
return OutContext.GetOrCreateSymbol(NameStr.str());
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCSection.h"
|
#include "llvm/MC/MCSection.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
|
#include "llvm/MC/MCSymbol.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetFrameInfo.h"
|
#include "llvm/Target/TargetFrameInfo.h"
|
||||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||||
@ -230,17 +231,26 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
|
|||||||
// Externally visible entry into the functions eh frame info. If the
|
// Externally visible entry into the functions eh frame info. If the
|
||||||
// corresponding function is static, this should not be externally visible.
|
// corresponding function is static, this should not be externally visible.
|
||||||
if (!TheFunc->hasLocalLinkage())
|
if (!TheFunc->hasLocalLinkage())
|
||||||
if (const char *GlobalEHDirective = MAI->getGlobalEHDirective())
|
if (const char *GlobalEHDirective = MAI->getGlobalEHDirective()) {
|
||||||
O << GlobalEHDirective << EHFrameInfo.FnName << '\n';
|
O << GlobalEHDirective;
|
||||||
|
EHFrameInfo.FunctionEHSym->print(O, MAI);
|
||||||
|
O << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
// If corresponding function is weak definition, this should be too.
|
// If corresponding function is weak definition, this should be too.
|
||||||
if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective())
|
if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective()) {
|
||||||
O << MAI->getWeakDefDirective() << EHFrameInfo.FnName << '\n';
|
O << MAI->getWeakDefDirective();
|
||||||
|
EHFrameInfo.FunctionEHSym->print(O, MAI);
|
||||||
|
O << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
// If corresponding function is hidden, this should be too.
|
// If corresponding function is hidden, this should be too.
|
||||||
if (TheFunc->hasHiddenVisibility())
|
if (TheFunc->hasHiddenVisibility())
|
||||||
if (const char *HiddenDirective = MAI->getHiddenDirective())
|
if (const char *HiddenDirective = MAI->getHiddenDirective()) {
|
||||||
O << HiddenDirective << EHFrameInfo.FnName << '\n' ;
|
O << HiddenDirective;
|
||||||
|
EHFrameInfo.FunctionEHSym->print(O, MAI);
|
||||||
|
O << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
// If there are no calls then you can't unwind. This may mean we can omit the
|
// If there are no calls then you can't unwind. This may mean we can omit the
|
||||||
// EH Frame, but some environments do not handle weak absolute symbols. If
|
// EH Frame, but some environments do not handle weak absolute symbols. If
|
||||||
@ -250,14 +260,19 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
|
|||||||
(!TheFunc->isWeakForLinker() ||
|
(!TheFunc->isWeakForLinker() ||
|
||||||
!MAI->getWeakDefDirective() ||
|
!MAI->getWeakDefDirective() ||
|
||||||
MAI->getSupportsWeakOmittedEHFrame())) {
|
MAI->getSupportsWeakOmittedEHFrame())) {
|
||||||
O << EHFrameInfo.FnName << " = 0\n";
|
EHFrameInfo.FunctionEHSym->print(O, MAI);
|
||||||
|
O << " = 0\n";
|
||||||
// This name has no connection to the function, so it might get
|
// This name has no connection to the function, so it might get
|
||||||
// dead-stripped when the function is not, erroneously. Prohibit
|
// dead-stripped when the function is not, erroneously. Prohibit
|
||||||
// dead-stripping unconditionally.
|
// dead-stripping unconditionally.
|
||||||
if (const char *UsedDirective = MAI->getUsedDirective())
|
if (const char *UsedDirective = MAI->getUsedDirective()) {
|
||||||
O << UsedDirective << EHFrameInfo.FnName << "\n\n";
|
O << UsedDirective;
|
||||||
|
EHFrameInfo.FunctionEHSym->print(O, MAI);
|
||||||
|
O << "\n\n";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
O << EHFrameInfo.FnName << ":\n";
|
EHFrameInfo.FunctionEHSym->print(O, MAI);
|
||||||
|
O << ":\n";
|
||||||
|
|
||||||
// EH frame header.
|
// EH frame header.
|
||||||
EmitDifference("eh_frame_end", EHFrameInfo.Number,
|
EmitDifference("eh_frame_end", EHFrameInfo.Number,
|
||||||
@ -328,8 +343,11 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
|
|||||||
// on unused functions (calling undefined externals) being dead-stripped to
|
// on unused functions (calling undefined externals) being dead-stripped to
|
||||||
// link correctly. Yes, there really is.
|
// link correctly. Yes, there really is.
|
||||||
if (MMI->isUsedFunction(EHFrameInfo.function))
|
if (MMI->isUsedFunction(EHFrameInfo.function))
|
||||||
if (const char *UsedDirective = MAI->getUsedDirective())
|
if (const char *UsedDirective = MAI->getUsedDirective()) {
|
||||||
O << UsedDirective << EHFrameInfo.FnName << "\n\n";
|
O << UsedDirective;
|
||||||
|
EHFrameInfo.FunctionEHSym->print(O, MAI);
|
||||||
|
O << "\n\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Asm->EOL();
|
Asm->EOL();
|
||||||
@ -928,7 +946,7 @@ void DwarfException::EmitExceptionTable() {
|
|||||||
PrintRelDirective();
|
PrintRelDirective();
|
||||||
|
|
||||||
if (GV) {
|
if (GV) {
|
||||||
O << Asm->Mang->getMangledName(GV);
|
Asm->GetGlobalValueSymbol(GV)->print(O, MAI);
|
||||||
} else {
|
} else {
|
||||||
O << "0x0";
|
O << "0x0";
|
||||||
}
|
}
|
||||||
@ -1019,12 +1037,12 @@ void DwarfException::EndFunction() {
|
|||||||
EmitLabel("eh_func_end", SubprogramCount);
|
EmitLabel("eh_func_end", SubprogramCount);
|
||||||
EmitExceptionTable();
|
EmitExceptionTable();
|
||||||
|
|
||||||
std::string FunctionEHName =
|
const MCSymbol *FunctionEHSym =
|
||||||
Asm->Mang->getMangledName(MF->getFunction(), ".eh",
|
Asm->GetSymbolWithGlobalValueBase(MF->getFunction(), ".eh",
|
||||||
Asm->MAI->is_EHSymbolPrivate());
|
Asm->MAI->is_EHSymbolPrivate());
|
||||||
|
|
||||||
// Save EH frame information
|
// Save EH frame information
|
||||||
EHFrames.push_back(FunctionEHFrameInfo(FunctionEHName, SubprogramCount,
|
EHFrames.push_back(FunctionEHFrameInfo(FunctionEHSym, SubprogramCount,
|
||||||
MMI->getPersonalityIndex(),
|
MMI->getPersonalityIndex(),
|
||||||
MF->getFrameInfo()->hasCalls(),
|
MF->getFrameInfo()->hasCalls(),
|
||||||
!MMI->getLandingPads().empty(),
|
!MMI->getLandingPads().empty(),
|
||||||
|
@ -34,19 +34,19 @@ class raw_ostream;
|
|||||||
///
|
///
|
||||||
class DwarfException : public Dwarf {
|
class DwarfException : public Dwarf {
|
||||||
struct FunctionEHFrameInfo {
|
struct FunctionEHFrameInfo {
|
||||||
std::string FnName;
|
const MCSymbol *FunctionEHSym; // L_foo.eh
|
||||||
unsigned Number;
|
unsigned Number;
|
||||||
unsigned PersonalityIndex;
|
unsigned PersonalityIndex;
|
||||||
bool hasCalls;
|
bool hasCalls;
|
||||||
bool hasLandingPads;
|
bool hasLandingPads;
|
||||||
std::vector<MachineMove> Moves;
|
std::vector<MachineMove> Moves;
|
||||||
const Function * function;
|
const Function *function;
|
||||||
|
|
||||||
FunctionEHFrameInfo(const std::string &FN, unsigned Num, unsigned P,
|
FunctionEHFrameInfo(const MCSymbol *EHSym, unsigned Num, unsigned P,
|
||||||
bool hC, bool hL,
|
bool hC, bool hL,
|
||||||
const std::vector<MachineMove> &M,
|
const std::vector<MachineMove> &M,
|
||||||
const Function *f):
|
const Function *f):
|
||||||
FnName(FN), Number(Num), PersonalityIndex(P),
|
FunctionEHSym(EHSym), Number(Num), PersonalityIndex(P),
|
||||||
hasCalls(hC), hasLandingPads(hL), Moves(M), function (f) { }
|
hasCalls(hC), hasLandingPads(hL), Moves(M), function (f) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ namespace {
|
|||||||
GetGlobalValueSymbol(GV)->print(O, MAI);
|
GetGlobalValueSymbol(GV)->print(O, MAI);
|
||||||
else {
|
else {
|
||||||
// FIXME: Remove this when Darwin transition to @GOT like syntax.
|
// FIXME: Remove this when Darwin transition to @GOT like syntax.
|
||||||
MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr");
|
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||||
Sym->print(O, MAI);
|
Sym->print(O, MAI);
|
||||||
|
|
||||||
MachineModuleInfoMachO &MMIMachO =
|
MachineModuleInfoMachO &MMIMachO =
|
||||||
|
@ -341,7 +341,7 @@ void SPUAsmPrinter::printOp(const MachineOperand &MO) {
|
|||||||
GlobalValue *GV = MO.getGlobal();
|
GlobalValue *GV = MO.getGlobal();
|
||||||
if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
|
if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
|
||||||
GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) {
|
GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) {
|
||||||
GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr")->print(O, MAI);
|
GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr")->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,9 +70,9 @@ namespace {
|
|||||||
if (Stub != 0) return;
|
if (Stub != 0) return;
|
||||||
|
|
||||||
// Get the names.
|
// Get the names.
|
||||||
Stub = Printer->GetPrivateGlobalValueSymbolStub(GV, "$stub");
|
Stub = Printer->GetSymbolWithGlobalValueBase(GV, "$stub");
|
||||||
LazyPtr = Printer->GetPrivateGlobalValueSymbolStub(GV, "$lazy_ptr");
|
LazyPtr = Printer->GetSymbolWithGlobalValueBase(GV, "$lazy_ptr");
|
||||||
AnonSymbol = Printer->GetPrivateGlobalValueSymbolStub(GV, "$stub$tmp");
|
AnonSymbol = Printer->GetSymbolWithGlobalValueBase(GV, "$stub$tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(StringRef GVName, Mangler *Mang, MCContext &Ctx) {
|
void Init(StringRef GVName, Mangler *Mang, MCContext &Ctx) {
|
||||||
@ -450,11 +450,11 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
|||||||
if (TM.getRelocationModel() != Reloc::Static &&
|
if (TM.getRelocationModel() != Reloc::Static &&
|
||||||
(GV->isDeclaration() || GV->isWeakForLinker())) {
|
(GV->isDeclaration() || GV->isWeakForLinker())) {
|
||||||
if (!GV->hasHiddenVisibility()) {
|
if (!GV->hasHiddenVisibility()) {
|
||||||
SymToPrint = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr");
|
SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||||
GVStubs[GetGlobalValueSymbol(GV)] = SymToPrint;
|
GVStubs[GetGlobalValueSymbol(GV)] = SymToPrint;
|
||||||
} else if (GV->isDeclaration() || GV->hasCommonLinkage() ||
|
} else if (GV->isDeclaration() || GV->hasCommonLinkage() ||
|
||||||
GV->hasAvailableExternallyLinkage()) {
|
GV->hasAvailableExternallyLinkage()) {
|
||||||
SymToPrint = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr");
|
SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||||
HiddenGVStubs[GetGlobalValueSymbol(GV)] = SymToPrint;
|
HiddenGVStubs[GetGlobalValueSymbol(GV)] = SymToPrint;
|
||||||
} else {
|
} else {
|
||||||
SymToPrint = GetGlobalValueSymbol(GV);
|
SymToPrint = GetGlobalValueSymbol(GV);
|
||||||
@ -1200,7 +1200,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
|
|||||||
E = Personalities.end(); I != E; ++I) {
|
E = Personalities.end(); I != E; ++I) {
|
||||||
if (*I)
|
if (*I)
|
||||||
GVStubs[GetGlobalValueSymbol(*I)] =
|
GVStubs[GetGlobalValueSymbol(*I)] =
|
||||||
GetPrivateGlobalValueSymbolStub(*I, "$non_lazy_ptr");
|
GetSymbolWithGlobalValueBase(*I, "$non_lazy_ptr");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,11 +238,11 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
|||||||
|
|
||||||
const MCSymbol *GVSym;
|
const MCSymbol *GVSym;
|
||||||
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
|
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
|
||||||
GVSym = GetPrivateGlobalValueSymbolStub(GV, "$stub");
|
GVSym = GetSymbolWithGlobalValueBase(GV, "$stub");
|
||||||
else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
||||||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
|
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
|
||||||
MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
|
MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
|
||||||
GVSym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr");
|
GVSym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||||
else
|
else
|
||||||
GVSym = GetGlobalValueSymbol(GV);
|
GVSym = GetGlobalValueSymbol(GV);
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
|||||||
|
|
||||||
if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
||||||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
|
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
|
||||||
MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr");
|
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||||
|
|
||||||
const MCSymbol *&StubSym =
|
const MCSymbol *&StubSym =
|
||||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
|
MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
|
||||||
@ -266,13 +266,13 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
|||||||
StubSym = GetGlobalValueSymbol(GV);
|
StubSym = GetGlobalValueSymbol(GV);
|
||||||
|
|
||||||
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
|
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
|
||||||
MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr");
|
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||||
const MCSymbol *&StubSym =
|
const MCSymbol *&StubSym =
|
||||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(Sym);
|
MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(Sym);
|
||||||
if (StubSym == 0)
|
if (StubSym == 0)
|
||||||
StubSym = GetGlobalValueSymbol(GV);
|
StubSym = GetGlobalValueSymbol(GV);
|
||||||
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
|
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
|
||||||
MCSymbol *Sym = GetPrivateGlobalValueSymbolStub(GV, "$stub");
|
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$stub");
|
||||||
const MCSymbol *&StubSym =
|
const MCSymbol *&StubSym =
|
||||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||||
if (StubSym == 0)
|
if (StubSym == 0)
|
||||||
|
Reference in New Issue
Block a user