mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-14 15:39:06 +00:00
move getNameWithPrefix and getSymbol to TargetMachine.
TargetLoweringBase is implemented in CodeGen, so before this patch we had a dependency fom Target to CodeGen. This would show up as a link failure of llvm-stress when building with -DBUILD_SHARED_LIBS=ON. This fixes pr18900. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201711 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
737c9f6005
commit
b4aaffffd3
@ -1345,10 +1345,6 @@ public:
|
||||
return LibcallCallingConvs[Call];
|
||||
}
|
||||
|
||||
void getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV,
|
||||
Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
|
||||
MCSymbol *getSymbol(const GlobalValue *GV, Mangler &Mang) const;
|
||||
|
||||
private:
|
||||
const TargetMachine &TM;
|
||||
const DataLayout *DL;
|
||||
|
@ -26,9 +26,11 @@ namespace llvm {
|
||||
class InstrItineraryData;
|
||||
class JITCodeEmitter;
|
||||
class GlobalValue;
|
||||
class Mangler;
|
||||
class MCAsmInfo;
|
||||
class MCCodeGenInfo;
|
||||
class MCContext;
|
||||
class MCSymbol;
|
||||
class Target;
|
||||
class DataLayout;
|
||||
class TargetLibraryInfo;
|
||||
@ -289,6 +291,10 @@ public:
|
||||
bool /*DisableVerify*/ = true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV,
|
||||
Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
|
||||
MCSymbol *getSymbol(const GlobalValue *GV, Mangler &Mang) const;
|
||||
};
|
||||
|
||||
/// LLVMTargetMachine - This class describes a target machine that is
|
||||
|
@ -313,11 +313,11 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const {
|
||||
|
||||
void AsmPrinter::getNameWithPrefix(SmallVectorImpl<char> &Name,
|
||||
const GlobalValue *GV) const {
|
||||
TM.getTargetLowering()->getNameWithPrefix(Name, GV, *Mang);
|
||||
TM.getNameWithPrefix(Name, GV, *Mang);
|
||||
}
|
||||
|
||||
MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const {
|
||||
return TM.getTargetLowering()->getSymbol(GV, *Mang);
|
||||
return TM.getSymbol(GV, *Mang);
|
||||
}
|
||||
|
||||
/// EmitGlobalVariable - Emit the specified global variable to the .s file.
|
||||
|
@ -1428,30 +1428,3 @@ bool TargetLoweringBase::isLegalAddressingMode(const AddrMode &AM,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TargetLoweringBase::getNameWithPrefix(SmallVectorImpl<char> &Name,
|
||||
const GlobalValue *GV,
|
||||
Mangler &Mang,
|
||||
bool MayAlwaysUsePrivate) const {
|
||||
if (MayAlwaysUsePrivate || !GV->hasPrivateLinkage()) {
|
||||
// Simple case: If GV is not private, it is not important to find out if
|
||||
// private labels are legal in this case or not.
|
||||
Mang.getNameWithPrefix(Name, GV, false);
|
||||
return;
|
||||
}
|
||||
SectionKind GVKind =
|
||||
TargetLoweringObjectFile::getKindForGlobal(GV, getTargetMachine());
|
||||
const TargetLoweringObjectFile &TLOF = getObjFileLowering();
|
||||
const MCSection *TheSection =
|
||||
TLOF.SectionForGlobal(GV, GVKind, Mang, getTargetMachine());
|
||||
bool CannotUsePrivateLabel = TLOF.isSectionAtomizableBySymbols(*TheSection);
|
||||
Mang.getNameWithPrefix(Name, GV, CannotUsePrivateLabel);
|
||||
}
|
||||
|
||||
MCSymbol *TargetLoweringBase::getSymbol(const GlobalValue *GV,
|
||||
Mangler &Mang) const {
|
||||
SmallString<60> NameStr;
|
||||
getNameWithPrefix(NameStr, GV, Mang);
|
||||
const TargetLoweringObjectFile &TLOF = getObjFileLowering();
|
||||
return TLOF.getContext().GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
|
@ -52,10 +52,10 @@ MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol(
|
||||
default:
|
||||
report_fatal_error("We do not support this DWARF encoding yet!");
|
||||
case dwarf::DW_EH_PE_absptr:
|
||||
return TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
return TM.getSymbol(GV, Mang);
|
||||
case dwarf::DW_EH_PE_pcrel: {
|
||||
return getContext().GetOrCreateSymbol(StringRef("DW.ref.") +
|
||||
TM.getTargetLowering()->getSymbol(GV, Mang)->getName());
|
||||
TM.getSymbol(GV, Mang)->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,7 +101,7 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
|
||||
// gets emitted by the asmprinter.
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
MCSymbol *Sym = TM.getSymbol(GV, Mang);
|
||||
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||
Prefix = getSectionPrefixForGlobal(Kind);
|
||||
|
||||
SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
|
||||
TM.getTargetLowering()->getNameWithPrefix(Name, GV, Mang, true);
|
||||
TM.getNameWithPrefix(Name, GV, Mang, true);
|
||||
|
||||
StringRef Group = "";
|
||||
unsigned Flags = getELFSectionFlags(Kind);
|
||||
@ -651,7 +651,7 @@ bool TargetLoweringObjectFileMachO::shouldEmitUsedDirectiveFor(
|
||||
// FIXME: ObjC metadata is currently emitted as internal symbols that have
|
||||
// \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and
|
||||
// this horrible hack can go away.
|
||||
MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
MCSymbol *Sym = TM.getSymbol(GV, Mang);
|
||||
if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l')
|
||||
return false;
|
||||
}
|
||||
@ -678,7 +678,7 @@ const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference(
|
||||
GV->hasHiddenVisibility() ? MachOMMI.getHiddenGVStubEntry(SSym) :
|
||||
MachOMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
MCSymbol *Sym = TM.getSymbol(GV, Mang);
|
||||
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
||||
}
|
||||
|
||||
@ -704,7 +704,7 @@ MCSymbol *TargetLoweringObjectFileMachO::getCFIPersonalitySymbol(
|
||||
// gets emitted by the asmprinter.
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
MCSymbol *Sym = TM.getSymbol(GV, Mang);
|
||||
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
||||
}
|
||||
|
||||
@ -760,7 +760,7 @@ const MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(
|
||||
if (GV->isWeakForLinker()) {
|
||||
Selection = COFF::IMAGE_COMDAT_SELECT_ANY;
|
||||
Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
|
||||
MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
MCSymbol *Sym = TM.getSymbol(GV, Mang);
|
||||
COMDATSymName = Sym->getName();
|
||||
}
|
||||
return getContext().getCOFFSection(Name,
|
||||
@ -794,7 +794,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||
unsigned Characteristics = getCOFFSectionFlags(Kind);
|
||||
|
||||
Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
|
||||
MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
MCSymbol *Sym = TM.getSymbol(GV, Mang);
|
||||
return getContext().getCOFFSection(Name, Characteristics,
|
||||
Kind, Sym->getName(),
|
||||
COFF::IMAGE_COMDAT_SELECT_ANY);
|
||||
|
@ -372,7 +372,7 @@ void *MCJIT::getPointerToFunction(Function *F) {
|
||||
// load address of the symbol, not the local address.
|
||||
Mangler Mang(TM->getDataLayout());
|
||||
SmallString<128> Name;
|
||||
TM->getTargetLowering()->getNameWithPrefix(Name, F, Mang);
|
||||
TM->getNameWithPrefix(Name, F, Mang);
|
||||
return (void*)Dyld.getSymbolLoadAddress(Name);
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ applyRestriction(GlobalValue &GV,
|
||||
return;
|
||||
|
||||
SmallString<64> Buffer;
|
||||
TargetMach->getTargetLowering()->getNameWithPrefix(Buffer, &GV, Mangler);
|
||||
TargetMach->getNameWithPrefix(Buffer, &GV, Mangler);
|
||||
|
||||
if (MustPreserveSymbols.count(Buffer))
|
||||
MustPreserveList.push_back(GV.getName().data());
|
||||
|
@ -391,7 +391,7 @@ void LTOModule::addDefinedSymbol(const GlobalValue *def, bool isFunction) {
|
||||
|
||||
// string is owned by _defines
|
||||
SmallString<64> Buffer;
|
||||
_target->getTargetLowering()->getNameWithPrefix(Buffer, def, _mangler);
|
||||
_target->getNameWithPrefix(Buffer, def, _mangler);
|
||||
|
||||
// set alignment part log2() can have rounding errors
|
||||
uint32_t align = def->getAlignment();
|
||||
@ -527,7 +527,7 @@ LTOModule::addPotentialUndefinedSymbol(const GlobalValue *decl, bool isFunc) {
|
||||
return;
|
||||
|
||||
SmallString<64> name;
|
||||
_target->getTargetLowering()->getNameWithPrefix(name, decl, _mangler);
|
||||
_target->getNameWithPrefix(name, decl, _mangler);
|
||||
|
||||
StringMap<NameAndAttributes>::value_type &entry =
|
||||
_undefines.GetOrCreateValue(name);
|
||||
|
@ -47,7 +47,7 @@ const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference(
|
||||
MCStreamer &Streamer) const {
|
||||
assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
|
||||
|
||||
return MCSymbolRefExpr::Create(TM.getTargetLowering()->getSymbol(GV, Mang),
|
||||
return MCSymbolRefExpr::Create(TM.getSymbol(GV, Mang),
|
||||
MCSymbolRefExpr::VK_ARM_TARGET2, getContext());
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ static MCSymbol *GetSymbolFromOperand(const MachineOperand &MO, AsmPrinter &AP){
|
||||
Mang->getNameWithPrefix(Name, MO.getSymbolName());
|
||||
} else {
|
||||
const GlobalValue *GV = MO.getGlobal();
|
||||
TM.getTargetLowering()->getNameWithPrefix(Name, GV, *Mang);
|
||||
TM.getNameWithPrefix(Name, GV, *Mang);
|
||||
}
|
||||
|
||||
unsigned OrigLen = Name.size() - PrefixLen;
|
||||
|
@ -29,7 +29,7 @@ const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
|
||||
// gets emitted by the asmprinter.
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
MCSymbol *Sym = TM.getSymbol(GV, Mang);
|
||||
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
|
||||
|
||||
SmallString<60> NameStr;
|
||||
NameStr += DL->getPrivateGlobalPrefix();
|
||||
TM.getTargetLowering()->getNameWithPrefix(NameStr, GV, Mang);
|
||||
TM.getNameWithPrefix(NameStr, GV, Mang);
|
||||
NameStr.append(Suffix.begin(), Suffix.end());
|
||||
return Ctx->GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
@ -115,7 +115,7 @@ MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
|
||||
MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol(
|
||||
const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
|
||||
MachineModuleInfo *MMI) const {
|
||||
return TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
return TM.getSymbol(GV, Mang);
|
||||
}
|
||||
|
||||
void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
|
||||
@ -312,8 +312,7 @@ const MCExpr *TargetLoweringObjectFile::getTTypeGlobalReference(
|
||||
const TargetMachine &TM, MachineModuleInfo *MMI,
|
||||
MCStreamer &Streamer) const {
|
||||
const MCSymbolRefExpr *Ref =
|
||||
MCSymbolRefExpr::Create(TM.getTargetLowering()->getSymbol(GV, Mang),
|
||||
getContext());
|
||||
MCSymbolRefExpr::Create(TM.getSymbol(GV, Mang), getContext());
|
||||
|
||||
return getTTypeReference(Ref, Encoding, Streamer);
|
||||
}
|
||||
|
@ -17,9 +17,14 @@
|
||||
#include "llvm/IR/GlobalAlias.h"
|
||||
#include "llvm/IR/GlobalValue.h"
|
||||
#include "llvm/IR/GlobalVariable.h"
|
||||
#include "llvm/IR/Mangler.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCCodeGenInfo.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/SectionKind.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
using namespace llvm;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@ -192,3 +197,28 @@ void TargetMachine::setFunctionSections(bool V) {
|
||||
void TargetMachine::setDataSections(bool V) {
|
||||
DataSections = V;
|
||||
}
|
||||
|
||||
void TargetMachine::getNameWithPrefix(SmallVectorImpl<char> &Name,
|
||||
const GlobalValue *GV, Mangler &Mang,
|
||||
bool MayAlwaysUsePrivate) const {
|
||||
if (MayAlwaysUsePrivate || !GV->hasPrivateLinkage()) {
|
||||
// Simple case: If GV is not private, it is not important to find out if
|
||||
// private labels are legal in this case or not.
|
||||
Mang.getNameWithPrefix(Name, GV, false);
|
||||
return;
|
||||
}
|
||||
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, *this);
|
||||
const TargetLoweringObjectFile &TLOF =
|
||||
getTargetLowering()->getObjFileLowering();
|
||||
const MCSection *TheSection = TLOF.SectionForGlobal(GV, GVKind, Mang, *this);
|
||||
bool CannotUsePrivateLabel = TLOF.isSectionAtomizableBySymbols(*TheSection);
|
||||
Mang.getNameWithPrefix(Name, GV, CannotUsePrivateLabel);
|
||||
}
|
||||
|
||||
MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV, Mangler &Mang) const {
|
||||
SmallString<60> NameStr;
|
||||
getNameWithPrefix(NameStr, GV, Mang);
|
||||
const TargetLoweringObjectFile &TLOF =
|
||||
getTargetLowering()->getObjFileLowering();
|
||||
return TLOF.getContext().GetOrCreateSymbol(NameStr.str());
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ const MCExpr *X86_64MachoTargetObjectFile::getTTypeGlobalReference(
|
||||
// On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
|
||||
// is an indirect pc-relative reference.
|
||||
if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
|
||||
const MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
const MCSymbol *Sym = TM.getSymbol(GV, Mang);
|
||||
const MCExpr *Res =
|
||||
MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
|
||||
const MCExpr *Four = MCConstantExpr::Create(4, getContext());
|
||||
@ -41,7 +41,7 @@ const MCExpr *X86_64MachoTargetObjectFile::getTTypeGlobalReference(
|
||||
MCSymbol *X86_64MachoTargetObjectFile::getCFIPersonalitySymbol(
|
||||
const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
|
||||
MachineModuleInfo *MMI) const {
|
||||
return TM.getTargetLowering()->getSymbol(GV, Mang);
|
||||
return TM.getSymbol(GV, Mang);
|
||||
}
|
||||
|
||||
void
|
||||
@ -102,7 +102,7 @@ const MCExpr *X86WindowsTargetObjectFile::getExecutableRelativeSymbol(
|
||||
if (GVLHS->isThreadLocal())
|
||||
return 0;
|
||||
|
||||
return MCSymbolRefExpr::Create(TM.getTargetLowering()->getSymbol(GVLHS, Mang),
|
||||
return MCSymbolRefExpr::Create(TM.getSymbol(GVLHS, Mang),
|
||||
MCSymbolRefExpr::VK_COFF_IMGREL32,
|
||||
getContext());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user