Add the private linkage.

llvm-svn: 62279
diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp
index bdc50b6..b59ec08 100644
--- a/llvm/lib/VMCore/AsmWriter.cpp
+++ b/llvm/lib/VMCore/AsmWriter.cpp
@@ -1149,6 +1149,7 @@
 
 static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) {
   switch (LT) {
+  case GlobalValue::PrivateLinkage:      Out << "private "; break;
   case GlobalValue::InternalLinkage:     Out << "internal "; break;
   case GlobalValue::LinkOnceLinkage:     Out << "linkonce "; break;
   case GlobalValue::WeakLinkage:         Out << "weak "; break;
diff --git a/llvm/lib/VMCore/Mangler.cpp b/llvm/lib/VMCore/Mangler.cpp
index 1488494..36cfbf7 100644
--- a/llvm/lib/VMCore/Mangler.cpp
+++ b/llvm/lib/VMCore/Mangler.cpp
@@ -147,14 +147,20 @@
     Name = "__unnamed_" + utostr(TypeUniqueID) + "_" + utostr(GlobalID++);
   } else {
     Name = makeNameProper(GV->getName() + Suffix, Prefix);
+    std::string prefix;
+    if (GV->hasPrivateLinkage())
+      prefix = PrivatePrefix;
+    else
+      prefix = "";
+    Name = prefix + Name;
   }
 
   return Name;
 }
 
-Mangler::Mangler(Module &M, const char *prefix)
-  : Prefix(prefix), UseQuotes(false), PreserveAsmNames(false),
-    Count(0), TypeCounter(0) {
+Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix)
+  : Prefix(prefix), PrivatePrefix (privatePrefix), UseQuotes(false),
+    PreserveAsmNames(false), Count(0), TypeCounter(0) {
   std::fill(AcceptableChars, array_endof(AcceptableChars), 0);
 
   // Letters and numbers are acceptable.
diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp
index d5b48c0..ef94796 100644
--- a/llvm/lib/VMCore/Module.cpp
+++ b/llvm/lib/VMCore/Module.cpp
@@ -153,7 +153,7 @@
   }
 
   // Okay, the function exists.  Does it have externally visible linkage?
-  if (F->hasInternalLinkage()) {
+  if (F->hasLocalLinkage()) {
     // Clear the function's name.
     F->setName("");
     // Retry, now there won't be a conflict.
@@ -238,14 +238,14 @@
 /// symbol table.  If it does not exist, return null.  The type argument
 /// should be the underlying type of the global, i.e., it should not have
 /// the top-level PointerType, which represents the address of the global.
-/// If AllowInternal is set to true, this function will return types that
-/// have InternalLinkage. By default, these types are not returned.
+/// If AllowLocal is set to true, this function will return types that
+/// have an local. By default, these types are not returned.
 ///
 GlobalVariable *Module::getGlobalVariable(const std::string &Name,
-                                          bool AllowInternal) const {
+                                          bool AllowLocal) const {
   if (Value *V = ValSymTab->lookup(Name)) {
     GlobalVariable *Result = dyn_cast<GlobalVariable>(V);
-    if (Result && (AllowInternal || !Result->hasInternalLinkage()))
+    if (Result && (AllowLocal || !Result->hasLocalLinkage()))
       return Result;
   }
   return 0;
@@ -376,4 +376,3 @@
       return;
     }
 }
-
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp
index 4744103..790a994 100644
--- a/llvm/lib/VMCore/Verifier.cpp
+++ b/llvm/lib/VMCore/Verifier.cpp
@@ -350,7 +350,7 @@
           GV.hasExternalWeakLinkage() ||
           GV.hasGhostLinkage() ||
           (isa<GlobalAlias>(GV) &&
-           (GV.hasInternalLinkage() || GV.hasWeakLinkage())),
+           (GV.hasLocalLinkage() || GV.hasWeakLinkage())),
   "Global is external, but doesn't have external or dllimport or weak linkage!",
           &GV);
 
@@ -384,7 +384,7 @@
 void Verifier::visitGlobalAlias(GlobalAlias &GA) {
   Assert1(!GA.getName().empty(),
           "Alias name cannot be empty!", &GA);
-  Assert1(GA.hasExternalLinkage() || GA.hasInternalLinkage() ||
+  Assert1(GA.hasExternalLinkage() || GA.hasLocalLinkage() ||
           GA.hasWeakLinkage(),
           "Alias should have external or external weak linkage!", &GA);
   Assert1(GA.getAliasee(),