]> granicus.if.org Git - llvm/commitdiff
In preparation for removing getNameWithPrefix off of TargetMachine,
authorEric Christopher <echristo@gmail.com>
Fri, 14 Oct 2016 05:47:41 +0000 (05:47 +0000)
committerEric Christopher <echristo@gmail.com>
Fri, 14 Oct 2016 05:47:41 +0000 (05:47 +0000)
sink the current behavior into the callers and sink
TargetMachine::getNameWithPrefix into TargetMachine::getSymbol.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284203 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetLoweringObjectFileImpl.cpp
lib/Target/TargetMachine.cpp

index edaa778a6053139a9e56e58641827afe5bc48b3e..b8339eefd9c3093e5b06ec6ad04036d92eee0f76 100644 (file)
@@ -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<char> &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 =
index 792280af84dd2e7f4a20e0ccd6d1e3ababab1290..28c9f370fb5da1ac58916332ea45033a4f26571f 100644 (file)
@@ -203,19 +203,13 @@ TargetIRAnalysis TargetMachine::getTargetIRAnalysis() {
 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;
-  }
   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);
 }