diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 667d54373cdb..a01f4dbbf5b4 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -265,7 +265,7 @@ public: virtual bool targetSchedulesPostRAScheduling() const { return false; }; void getNameWithPrefix(SmallVectorImpl &Name, const GlobalValue *GV, - Mangler &Mang) const; + Mangler &Mang, bool MayAlwaysUsePrivate = false) const; MCSymbol *getSymbol(const GlobalValue *GV, Mangler &Mang) const; /// True if the target uses physical regs at Prolog/Epilog insertion diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index b8339eefd9c3..edaa778a6053 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('.'); - Mang.getNameWithPrefix(Name, GV, false); + TM.getNameWithPrefix(Name, GV, Mang, true); } unsigned UniqueID = MCContext::GenericSectionID; if (EmitUniqueSection && !UniqueSectionNames) { @@ -817,13 +817,6 @@ 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 aa1916bb2eb4..17caed973910 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -199,8 +199,16 @@ TargetIRAnalysis TargetMachine::getTargetIRAnalysis() { } void TargetMachine::getNameWithPrefix(SmallVectorImpl &Name, - const GlobalValue *GV, Mangler &Mang) const { - getObjFileLowering()->getNameWithPrefix(Name, GV, *this); + 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 {