From 2bd52b5d91f7f560f86eb60a7852e5c2f44aefa3 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 14 Oct 2016 05:47:41 +0000 Subject: [PATCH] In preparation for removing getNameWithPrefix off of TargetMachine, sink the current behavior into the callers and sink TargetMachine::getNameWithPrefix into TargetMachine::getSymbol. llvm-svn: 284203 --- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 9 ++++++++- llvm/lib/Target/TargetMachine.cpp | 8 +------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index edaa778..b8339ee 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -301,7 +301,7 @@ selectELFSectionForGlobal(MCContext &Ctx, const GlobalValue *GV, if (EmitUniqueSection && UniqueSectionNames) { Name.push_back('.'); - TM.getNameWithPrefix(Name, GV, Mang, true); + Mang.getNameWithPrefix(Name, GV, false); } unsigned UniqueID = MCContext::GenericSectionID; if (EmitUniqueSection && !UniqueSectionNames) { @@ -817,6 +817,13 @@ static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo, void TargetLoweringObjectFileMachO::getNameWithPrefix( SmallVectorImpl &OutName, const GlobalValue *GV, const TargetMachine &TM) const { + if (!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. + getMangler().getNameWithPrefix(OutName, GV, false); + return; + } + SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM); const MCSection *TheSection = SectionForGlobal(GV, GVKind, TM); bool CannotUsePrivateLabel = diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 792280a..28c9f37 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -203,19 +203,13 @@ TargetIRAnalysis TargetMachine::getTargetIRAnalysis() { void TargetMachine::getNameWithPrefix(SmallVectorImpl &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; - } const TargetLoweringObjectFile *TLOF = getObjFileLowering(); TLOF->getNameWithPrefix(Name, GV, *this); } MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV, Mangler &Mang) const { SmallString<128> NameStr; - getNameWithPrefix(NameStr, GV, Mang); const TargetLoweringObjectFile *TLOF = getObjFileLowering(); + TLOF->getNameWithPrefix(NameStr, GV, *this); return TLOF->getContext().getOrCreateSymbol(NameStr); } -- 2.7.4