summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-02-19 20:30:41 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-02-19 20:30:41 +0000
commitb4aaffffd3473d7eff7fc63d022ed4e9549983ea (patch)
treedd32d25e6cc282d929c1cf368af27ad9828b26ef
parent737c9f6005594898eed4746cd310cd161ef209c6 (diff)
downloadllvm-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
-rw-r--r--include/llvm/Target/TargetLowering.h4
-rw-r--r--include/llvm/Target/TargetMachine.h6
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp4
-rw-r--r--lib/CodeGen/TargetLoweringBase.cpp27
-rw-r--r--lib/CodeGen/TargetLoweringObjectFileImpl.cpp18
-rw-r--r--lib/ExecutionEngine/MCJIT/MCJIT.cpp2
-rw-r--r--lib/LTO/LTOCodeGenerator.cpp2
-rw-r--r--lib/LTO/LTOModule.cpp4
-rw-r--r--lib/Target/ARM/ARMTargetObjectFile.cpp2
-rw-r--r--lib/Target/PowerPC/PPCMCInstLower.cpp2
-rw-r--r--lib/Target/Sparc/SparcTargetObjectFile.cpp2
-rw-r--r--lib/Target/TargetLoweringObjectFile.cpp7
-rw-r--r--lib/Target/TargetMachine.cpp30
-rw-r--r--lib/Target/X86/X86TargetObjectFile.cpp6
14 files changed, 60 insertions, 56 deletions
diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h
index 0b3428ed7a..ddcb27cadf 100644
--- a/include/llvm/Target/TargetLowering.h
+++ b/include/llvm/Target/TargetLowering.h
@@ -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;
diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h
index 5bf8d01d63..85b009afe8 100644
--- a/include/llvm/Target/TargetMachine.h
+++ b/include/llvm/Target/TargetMachine.h
@@ -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
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 6c4cddc3f6..6ed2991ded 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -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.
diff --git a/lib/CodeGen/TargetLoweringBase.cpp b/lib/CodeGen/TargetLoweringBase.cpp
index d3c42be5e6..47a86d601b 100644
--- a/lib/CodeGen/TargetLoweringBase.cpp
+++ b/lib/CodeGen/TargetLoweringBase.cpp
@@ -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());
-}
diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index bd54a871ca..0f3fb4924b 100644
--- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -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);
diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 4d5723a7a1..f94185d4a4 100644
--- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -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);
}
diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp
index b03b1da01a..2b37802efc 100644
--- a/lib/LTO/LTOCodeGenerator.cpp
+++ b/lib/LTO/LTOCodeGenerator.cpp
@@ -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());
diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp
index 86b67ef205..fb20806634 100644
--- a/lib/LTO/LTOModule.cpp
+++ b/lib/LTO/LTOModule.cpp
@@ -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);
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());
}