Remove the isImplicitlyPrivate argument of getNameWithPrefix.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 5 Dec 2013 05:53:12 +0000 (05:53 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 5 Dec 2013 05:53:12 +0000 (05:53 +0000)
getSymbolWithGlobalValueBase use is to create a name of a new symbol based
on the name of an existing GV. Assert that and then remove the last call
to pass true to isImplicitlyPrivate.

This gives the mangler API a 1:1 mapping from GV to names, which is what we
need to drop the mangler dependency on the target (and use an extended
datalayout instead).

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

include/llvm/Target/Mangler.h
lib/ExecutionEngine/MCJIT/MCJIT.cpp
lib/LTO/LTOCodeGenerator.cpp
lib/LTO/LTOModule.cpp
lib/Target/Mangler.cpp
lib/Target/PowerPC/PPCMCInstLower.cpp
lib/Target/TargetLoweringObjectFile.cpp
lib/Target/X86/X86MCInstLower.cpp

index fab41d2439ccc21c4750bb929d4dd73e56c4b0fb..3a8f32646f43f36bfb74e904d41cf9acd08eb458 100644 (file)
@@ -51,8 +51,7 @@ public:
   /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
   /// and the specified global variable's name.  If the global variable doesn't
   /// have a name, this fills in a unique name for the global.
   /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
   /// and the specified global variable's name.  If the global variable doesn't
   /// have a name, this fills in a unique name for the global.
-  void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
-                         bool isImplicitlyPrivate);
+  void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV);
 
   /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
   /// and the specified name as the global variable name.  GVName must not be
 
   /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
   /// and the specified name as the global variable name.  GVName must not be
index 5841d918de4add99f6f3a3385757dcda74e72586..8d9c33f49a3df7761c87d4020896f991758451b6 100644 (file)
@@ -325,7 +325,7 @@ void *MCJIT::getPointerToFunction(Function *F) {
   // load address of the symbol, not the local address.
   Mangler Mang(TM);
   SmallString<128> Name;
   // load address of the symbol, not the local address.
   Mangler Mang(TM);
   SmallString<128> Name;
-  Mang.getNameWithPrefix(Name, F, false);
+  Mang.getNameWithPrefix(Name, F);
   return (void*)Dyld.getSymbolLoadAddress(Name);
 }
 
   return (void*)Dyld.getSymbolLoadAddress(Name);
 }
 
index 2b3648e1f3bf03dc3bfd93c889afdfcc451c4bce..779b4a26174ca8d48a0b033792d079c4586be11a 100644 (file)
@@ -320,7 +320,7 @@ applyRestriction(GlobalValue &GV,
                  SmallPtrSet<GlobalValue*, 8> &AsmUsed,
                  Mangler &Mangler) {
   SmallString<64> Buffer;
                  SmallPtrSet<GlobalValue*, 8> &AsmUsed,
                  Mangler &Mangler) {
   SmallString<64> Buffer;
-  Mangler.getNameWithPrefix(Buffer, &GV, false);
+  Mangler.getNameWithPrefix(Buffer, &GV);
 
   if (GV.isDeclaration())
     return;
 
   if (GV.isDeclaration())
     return;
index 65416bed92773f4e5b156815cd47c5336bf0ed69..77eb3cae78bffc12da1d191c3e1bfadc03208552 100644 (file)
@@ -360,7 +360,7 @@ void LTOModule::addDefinedSymbol(const GlobalValue *def, bool isFunction) {
 
   // string is owned by _defines
   SmallString<64> Buffer;
 
   // string is owned by _defines
   SmallString<64> Buffer;
-  _mangler.getNameWithPrefix(Buffer, def, false);
+  _mangler.getNameWithPrefix(Buffer, def);
 
   // set alignment part log2() can have rounding errors
   uint32_t align = def->getAlignment();
 
   // set alignment part log2() can have rounding errors
   uint32_t align = def->getAlignment();
@@ -496,7 +496,7 @@ LTOModule::addPotentialUndefinedSymbol(const GlobalValue *decl, bool isFunc) {
     return;
 
   SmallString<64> name;
     return;
 
   SmallString<64> name;
-  _mangler.getNameWithPrefix(name, decl, false);
+  _mangler.getNameWithPrefix(name, decl);
 
   StringMap<NameAndAttributes>::value_type &entry =
     _undefines.GetOrCreateValue(name);
 
   StringMap<NameAndAttributes>::value_type &entry =
     _undefines.GetOrCreateValue(name);
index c41a0f3591bd9eef365f1a854fb444f2f697522f..f90cd7849a4607c41681c5396ee7391509b3b8d2 100644 (file)
@@ -81,10 +81,9 @@ static void AddFastCallStdCallSuffix(SmallVectorImpl<char> &OutName,
 /// and the specified global variable's name.  If the global variable doesn't
 /// have a name, this fills in a unique name for the global.
 void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
 /// and the specified global variable's name.  If the global variable doesn't
 /// have a name, this fills in a unique name for the global.
 void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
-                                const GlobalValue *GV,
-                                bool isImplicitlyPrivate) {
+                                const GlobalValue *GV) {
   ManglerPrefixTy PrefixTy = Mangler::Default;
   ManglerPrefixTy PrefixTy = Mangler::Default;
-  if (GV->hasPrivateLinkage() || isImplicitlyPrivate)
+  if (GV->hasPrivateLinkage())
     PrefixTy = Mangler::Private;
   else if (GV->hasLinkerPrivateLinkage() || GV->hasLinkerPrivateWeakLinkage())
     PrefixTy = Mangler::LinkerPrivate;
     PrefixTy = Mangler::Private;
   else if (GV->hasLinkerPrivateLinkage() || GV->hasLinkerPrivateWeakLinkage())
     PrefixTy = Mangler::LinkerPrivate;
index 1cbd268791d5e20f3e3029c33db19e23ee441430..56fa773433af687a23cb9503ad5c9255e0be582f 100644 (file)
@@ -51,7 +51,7 @@ static MCSymbol *GetSymbolFromOperand(const MachineOperand &MO, AsmPrinter &AP){
     AP.Mang->getNameWithPrefix(Name, MO.getSymbolName());
   } else {
     const GlobalValue *GV = MO.getGlobal();
     AP.Mang->getNameWithPrefix(Name, MO.getSymbolName());
   } else {
     const GlobalValue *GV = MO.getGlobal();
-    AP.Mang->getNameWithPrefix(Name, GV, false);
+    AP.Mang->getNameWithPrefix(Name, GV);
   }
 
   unsigned OrigLen = Name.size() - PrefixLen;
   }
 
   unsigned OrigLen = Name.size() - PrefixLen;
index 836edeb5a2ad728aaf7853b33a6e9481a87cedc2..66a52d6aa3c1db0e8a29391979ebd304dfe46181 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalVariable.h"
+#include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCStreamer.h"
@@ -102,14 +103,21 @@ static bool IsNullTerminatedString(const Constant *C) {
 MCSymbol *TargetLoweringObjectFile::getSymbol(Mangler &M, 
                                               const GlobalValue *GV) const {
   SmallString<60> NameStr;
 MCSymbol *TargetLoweringObjectFile::getSymbol(Mangler &M, 
                                               const GlobalValue *GV) const {
   SmallString<60> NameStr;
-  M.getNameWithPrefix(NameStr, GV, false);
+  M.getNameWithPrefix(NameStr, GV);
   return Ctx->GetOrCreateSymbol(NameStr.str());
 }
 
 MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
     Mangler &M, const GlobalValue *GV, StringRef Suffix) const {
   return Ctx->GetOrCreateSymbol(NameStr.str());
 }
 
 MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
     Mangler &M, const GlobalValue *GV, StringRef Suffix) const {
+  assert(!Suffix.empty());
+  assert(!GV->hasPrivateLinkage());
+  assert(!GV->hasLinkerPrivateLinkage());
+  assert(!GV->hasLinkerPrivateWeakLinkage());
+
+  const MCAsmInfo *MAI = Ctx->getAsmInfo();
   SmallString<60> NameStr;
   SmallString<60> NameStr;
-  M.getNameWithPrefix(NameStr, GV, true);
+  NameStr += MAI->getPrivateGlobalPrefix();
+  M.getNameWithPrefix(NameStr, GV);
   NameStr.append(Suffix.begin(), Suffix.end());
   return Ctx->GetOrCreateSymbol(NameStr.str());
 }
   NameStr.append(Suffix.begin(), Suffix.end());
   return Ctx->GetOrCreateSymbol(NameStr.str());
 }
index 305dc953928f9ac85ddf50f2e00fd0c36bed4cd4..78d45e882903299690228a83c491a2f34e867eb4 100644 (file)
@@ -97,7 +97,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
 
   if (MO.isGlobal()) {
     const GlobalValue *GV = MO.getGlobal();
 
   if (MO.isGlobal()) {
     const GlobalValue *GV = MO.getGlobal();
-    getMang()->getNameWithPrefix(Name, GV, false);
+    getMang()->getNameWithPrefix(Name, GV);
   } else if (MO.isSymbol()) {
     getMang()->getNameWithPrefix(Name, MO.getSymbolName());
   } else if (MO.isMBB()) {
   } else if (MO.isSymbol()) {
     getMang()->getNameWithPrefix(Name, MO.getSymbolName());
   } else if (MO.isMBB()) {