diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-19 20:30:41 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-19 20:30:41 +0000 |
| commit | b4aaffffd3473d7eff7fc63d022ed4e9549983ea (patch) | |
| tree | dd32d25e6cc282d929c1cf368af27ad9828b26ef /lib/Target | |
| parent | 737c9f6005594898eed4746cd310cd161ef209c6 (diff) | |
| download | llvm-b4aaffffd3473d7eff7fc63d022ed4e9549983ea.tar.gz llvm-b4aaffffd3473d7eff7fc63d022ed4e9549983ea.tar.bz2 llvm-b4aaffffd3473d7eff7fc63d022ed4e9549983ea.tar.xz | |
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
Diffstat (limited to 'lib/Target')
| -rw-r--r-- | lib/Target/ARM/ARMTargetObjectFile.cpp | 2 | ||||
| -rw-r--r-- | lib/Target/PowerPC/PPCMCInstLower.cpp | 2 | ||||
| -rw-r--r-- | lib/Target/Sparc/SparcTargetObjectFile.cpp | 2 | ||||
| -rw-r--r-- | lib/Target/TargetLoweringObjectFile.cpp | 7 | ||||
| -rw-r--r-- | lib/Target/TargetMachine.cpp | 30 | ||||
| -rw-r--r-- | lib/Target/X86/X86TargetObjectFile.cpp | 6 |
6 files changed, 39 insertions, 10 deletions
diff --git a/lib/Target/ARM/ARMTargetObjectFile.cpp b/lib/Target/ARM/ARMTargetObjectFile.cpp index 4e81fcdc3a..3379f85b4e 100644 --- a/lib/Target/ARM/ARMTargetObjectFile.cpp +++ b/lib/Target/ARM/ARMTargetObjectFile.cpp @@ -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()); } diff --git a/lib/Target/PowerPC/PPCMCInstLower.cpp b/lib/Target/PowerPC/PPCMCInstLower.cpp index cc40361cfc..029bb8a70a 100644 --- a/lib/Target/PowerPC/PPCMCInstLower.cpp +++ b/lib/Target/PowerPC/PPCMCInstLower.cpp @@ -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; diff --git a/lib/Target/Sparc/SparcTargetObjectFile.cpp b/lib/Target/Sparc/SparcTargetObjectFile.cpp index b732e18d81..f1630e0c31 100644 --- a/lib/Target/Sparc/SparcTargetObjectFile.cpp +++ b/lib/Target/Sparc/SparcTargetObjectFile.cpp @@ -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()); } diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index 9fff220d47..dea5247434 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -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); } diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index 8c99bffc00..f8a58ec292 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -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()); +} diff --git a/lib/Target/X86/X86TargetObjectFile.cpp b/lib/Target/X86/X86TargetObjectFile.cpp index 95fccba48a..0a88e984c8 100644 --- a/lib/Target/X86/X86TargetObjectFile.cpp +++ b/lib/Target/X86/X86TargetObjectFile.cpp @@ -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()); } |
