[llvm-commits] [llvm] r62279 - in /llvm/trunk: docs/ include/llvm/ include/llvm/Support/ lib/Analysis/IPA/ lib/Archive/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/CodeGen/ lib/CodeGen/AsmPrinter/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/ lib/ExecutionEngine/JIT/ lib/Linker/ lib/Target/ lib/Target/ARM/ lib/Target/ARM/AsmPrinter/ lib/Target/Alpha/ lib/Target/Alpha/AsmPrinter/ lib/Target/CBackend/ lib/Target/CellSPU/AsmPrinter/ lib/Target/CppBackend/ lib/Target/IA64/ lib/Target/MSIL/ lib/Target/Mips/ ...

Rafael Espindola rafael.espindola at gmail.com
Thu Jan 15 12:18:42 PST 2009


Author: rafael
Date: Thu Jan 15 14:18:42 2009
New Revision: 62279

URL: http://llvm.org/viewvc/llvm-project?rev=62279&view=rev
Log:
Add the private linkage.


Added:
    llvm/trunk/test/Assembler/private.ll
    llvm/trunk/test/CodeGen/ARM/private.ll
    llvm/trunk/test/CodeGen/Alpha/private.ll
    llvm/trunk/test/CodeGen/CellSPU/private.ll
    llvm/trunk/test/CodeGen/IA64/private.ll
    llvm/trunk/test/CodeGen/Mips/private.ll
    llvm/trunk/test/CodeGen/PowerPC/private.ll
    llvm/trunk/test/CodeGen/SPARC/private.ll
    llvm/trunk/test/CodeGen/X86/private.ll
    llvm/trunk/test/CodeGen/XCore/private.ll
Modified:
    llvm/trunk/docs/LangRef.html
    llvm/trunk/include/llvm/GlobalValue.h
    llvm/trunk/include/llvm/Module.h
    llvm/trunk/include/llvm/Support/Mangler.h
    llvm/trunk/lib/Analysis/IPA/Andersens.cpp
    llvm/trunk/lib/Analysis/IPA/CallGraph.cpp
    llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp
    llvm/trunk/lib/Archive/Archive.cpp
    llvm/trunk/lib/AsmParser/LLLexer.cpp
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/AsmParser/LLToken.h
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
    llvm/trunk/lib/CodeGen/ELFWriter.cpp
    llvm/trunk/lib/CodeGen/MachOWriter.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
    llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
    llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
    llvm/trunk/lib/Linker/LinkArchives.cpp
    llvm/trunk/lib/Linker/LinkModules.cpp
    llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
    llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
    llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp
    llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
    llvm/trunk/lib/Target/CBackend/CBackend.cpp
    llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
    llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
    llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
    llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
    llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp
    llvm/trunk/lib/Target/MSIL/MSILWriter.cpp
    llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
    llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
    llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
    llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
    llvm/trunk/lib/Target/X86/X86Subtarget.cpp
    llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
    llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
    llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp
    llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
    llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
    llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp
    llvm/trunk/lib/Transforms/IPO/Inliner.cpp
    llvm/trunk/lib/Transforms/IPO/Internalize.cpp
    llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
    llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp
    llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
    llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
    llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp
    llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
    llvm/trunk/lib/VMCore/AsmWriter.cpp
    llvm/trunk/lib/VMCore/Mangler.cpp
    llvm/trunk/lib/VMCore/Module.cpp
    llvm/trunk/lib/VMCore/Verifier.cpp
    llvm/trunk/tools/bugpoint/ExtractFunction.cpp
    llvm/trunk/tools/llvm-nm/llvm-nm.cpp

Modified: llvm/trunk/docs/LangRef.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/docs/LangRef.html (original)
+++ llvm/trunk/docs/LangRef.html Thu Jan 15 14:18:42 2009
@@ -480,13 +480,20 @@
 
 <dl>
 
-  <dt><tt><b><a name="linkage_internal">internal</a></b></tt>: </dt>
+  <dt><tt><b><a name="linkage_private">private</a></b></tt>: </dt>
 
-  <dd>Global values with internal linkage are only directly accessible by
+  <dd>Global values with private linkage are only directly accessible by
   objects in the current module.  In particular, linking code into a module with
-  an internal global value may cause the internal to be renamed as necessary to
-  avoid collisions.  Because the symbol is internal to the module, all
-  references can be updated.  This corresponds to the notion of the
+  an private global value may cause the private to be renamed as necessary to
+  avoid collisions.  Because the symbol is private to the module, all
+  references can be updated. This doesn't show up in any symbol table in the
+  object file.
+  </dd>
+
+  <dt><tt><b><a name="linkage_internal">internal</a></b></tt>: </dt>
+
+  <dd> Similar to private, but the value show as a local symbol (STB_LOCAL in
+  the case of ELF) in the object file. This corresponds to the notion of the
   '<tt>static</tt>' keyword in C.
   </dd>
 

Modified: llvm/trunk/include/llvm/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalValue.h?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/include/llvm/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/GlobalValue.h Thu Jan 15 14:18:42 2009
@@ -35,6 +35,7 @@
     WeakLinkage,        ///< Keep one copy of named function when linking (weak)
     AppendingLinkage,   ///< Special purpose, only applies to global arrays
     InternalLinkage,    ///< Rename collisions when linking (static functions)
+    PrivateLinkage,     ///< Like Internal, but omit from symbol table
     DLLImportLinkage,   ///< Function to be imported from DLL
     DLLExportLinkage,   ///< Function to be accessible from DLL
     ExternalWeakLinkage,///< ExternalWeak linkage description
@@ -104,6 +105,10 @@
   bool hasCommonLinkage()     const { return Linkage == CommonLinkage; }
   bool hasAppendingLinkage()  const { return Linkage == AppendingLinkage; }
   bool hasInternalLinkage()   const { return Linkage == InternalLinkage; }
+  bool hasPrivateLinkage()    const { return Linkage == PrivateLinkage; }
+  bool hasLocalLinkage()      const {
+    return Linkage == InternalLinkage || Linkage == PrivateLinkage;
+  }
   bool hasDLLImportLinkage()  const { return Linkage == DLLImportLinkage; }
   bool hasDLLExportLinkage()  const { return Linkage == DLLExportLinkage; }
   bool hasExternalWeakLinkage() const { return Linkage == ExternalWeakLinkage; }

Modified: llvm/trunk/include/llvm/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Module.h (original)
+++ llvm/trunk/include/llvm/Module.h Thu Jan 15 14:18:42 2009
@@ -188,7 +188,7 @@
   /// getOrInsertFunction - Look up the specified function in the module symbol
   /// table.  Four possibilities:
   ///   1. If it does not exist, add a prototype for the function and return it.
-  ///   2. If it exists, and has internal linkage, the existing function is
+  ///   2. If it exists, and has a local linkage, the existing function is
   ///      renamed and a new one is inserted.
   ///   3. Otherwise, if the existing function has the correct prototype, return
   ///      the existing function.

Modified: llvm/trunk/include/llvm/Support/Mangler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/Mangler.h (original)
+++ llvm/trunk/include/llvm/Support/Mangler.h Thu Jan 15 14:18:42 2009
@@ -29,6 +29,7 @@
   /// symbol is marked as not needing this prefix.
   const char *Prefix;
   
+  const char *PrivatePrefix;
   /// UseQuotes - If this is set, the target accepts global names in quotes, 
   /// e.g. "foo bar" is a legal name.  This syntax is used instead of escaping
   /// the space character.  By default, this is false.
@@ -58,7 +59,7 @@
 
   // Mangler ctor - if a prefix is specified, it will be prepended onto all
   // symbols.
-  Mangler(Module &M, const char *Prefix = "");
+  Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "");
 
   /// setUseQuotes - If UseQuotes is set to true, this target accepts quoted
   /// strings for assembler labels.

Modified: llvm/trunk/lib/Analysis/IPA/Andersens.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/Andersens.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/IPA/Andersens.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/Andersens.cpp Thu Jan 15 14:18:42 2009
@@ -1084,7 +1084,7 @@
     // At some point we should just add constraints for the escaping functions
     // at solve time, but this slows down solving. For now, we simply mark
     // address taken functions as escaping and treat them as external.
-    if (!F->hasInternalLinkage() || AnalyzeUsesOfFunction(F))
+    if (!F->hasLocalLinkage() || AnalyzeUsesOfFunction(F))
       AddConstraintsForNonInternalLinkage(F);
 
     if (!F->isDeclaration()) {

Modified: llvm/trunk/lib/Analysis/IPA/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraph.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/IPA/CallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/CallGraph.cpp Thu Jan 15 14:18:42 2009
@@ -112,7 +112,7 @@
     CallGraphNode *Node = getOrInsertFunction(F);
 
     // If this function has external linkage, anything could call it.
-    if (!F->hasInternalLinkage()) {
+    if (!F->hasLocalLinkage()) {
       ExternalCallingNode->addCalledFunction(CallSite(), Node);
 
       // Found the entry point?

Modified: llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp Thu Jan 15 14:18:42 2009
@@ -164,7 +164,7 @@
 void GlobalsModRef::AnalyzeGlobals(Module &M) {
   std::vector<Function*> Readers, Writers;
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
-    if (I->hasInternalLinkage()) {
+    if (I->hasLocalLinkage()) {
       if (!AnalyzeUsesOfPointer(I, Readers, Writers)) {
         // Remember that we are tracking this global.
         NonAddressTakenGlobals.insert(I);
@@ -175,7 +175,7 @@
 
   for (Module::global_iterator I = M.global_begin(), E = M.global_end();
        I != E; ++I)
-    if (I->hasInternalLinkage()) {
+    if (I->hasLocalLinkage()) {
       if (!AnalyzeUsesOfPointer(I, Readers, Writers)) {
         // Remember that we are tracking this global, and the mod/ref fns
         NonAddressTakenGlobals.insert(I);
@@ -504,7 +504,7 @@
   // If we are asking for mod/ref info of a direct call with a pointer to a
   // global we are tracking, return information if we have it.
   if (GlobalValue *GV = dyn_cast<GlobalValue>(P->getUnderlyingObject()))
-    if (GV->hasInternalLinkage())
+    if (GV->hasLocalLinkage())
       if (Function *F = CS.getCalledFunction())
         if (NonAddressTakenGlobals.count(GV))
           if (FunctionRecord *FR = getFunctionInfo(F))

Modified: llvm/trunk/lib/Archive/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/Archive.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Archive/Archive.cpp (original)
+++ llvm/trunk/lib/Archive/Archive.cpp Thu Jan 15 14:18:42 2009
@@ -188,13 +188,13 @@
 static void getSymbols(Module*M, std::vector<std::string>& symbols) {
   // Loop over global variables
   for (Module::global_iterator GI = M->global_begin(), GE=M->global_end(); GI != GE; ++GI)
-    if (!GI->isDeclaration() && !GI->hasInternalLinkage())
+    if (!GI->isDeclaration() && !GI->hasLocalLinkage())
       if (!GI->getName().empty())
         symbols.push_back(GI->getName());
   
   // Loop over functions
   for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI)
-    if (!FI->isDeclaration() && !FI->hasInternalLinkage())
+    if (!FI->isDeclaration() && !FI->hasLocalLinkage())
       if (!FI->getName().empty())
         symbols.push_back(FI->getName());
 

Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp Thu Jan 15 14:18:42 2009
@@ -453,6 +453,7 @@
   KEYWORD(declare); KEYWORD(define);
   KEYWORD(global);  KEYWORD(constant);
 
+  KEYWORD(private);
   KEYWORD(internal);
   KEYWORD(linkonce);
   KEYWORD(weak);

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Thu Jan 15 14:18:42 2009
@@ -113,6 +113,7 @@
     // optional leading prefixes, the production is:
     // GlobalVar ::= OptionalLinkage OptionalVisibility OptionalThreadLocal
     //               OptionalAddrSpace ('constant'|'global') ...
+    case lltok::kw_private:       // OptionalLinkage
     case lltok::kw_internal:      // OptionalLinkage
     case lltok::kw_weak:          // OptionalLinkage
     case lltok::kw_linkonce:      // OptionalLinkage
@@ -375,7 +376,8 @@
 
   if (Linkage != GlobalValue::ExternalLinkage &&
       Linkage != GlobalValue::WeakLinkage &&
-      Linkage != GlobalValue::InternalLinkage)
+      Linkage != GlobalValue::InternalLinkage &&
+      Linkage != GlobalValue::PrivateLinkage)
     return Error(LinkageLoc, "invalid linkage type for alias");
   
   Constant *Aliasee;
@@ -738,6 +740,7 @@
 
 /// ParseOptionalLinkage
 ///   ::= /*empty*/
+///   ::= 'private'
 ///   ::= 'internal'
 ///   ::= 'weak'
 ///   ::= 'linkonce'
@@ -751,6 +754,7 @@
   HasLinkage = false;
   switch (Lex.getKind()) {
   default:                    Res = GlobalValue::ExternalLinkage; return false;
+  case lltok::kw_private:     Res = GlobalValue::PrivateLinkage; break;
   case lltok::kw_internal:    Res = GlobalValue::InternalLinkage; break;
   case lltok::kw_weak:        Res = GlobalValue::WeakLinkage; break;
   case lltok::kw_linkonce:    Res = GlobalValue::LinkOnceLinkage; break;
@@ -2065,6 +2069,7 @@
     if (isDefine)
       return Error(LinkageLoc, "invalid linkage for function definition");
     break;
+  case GlobalValue::PrivateLinkage:
   case GlobalValue::InternalLinkage:
   case GlobalValue::LinkOnceLinkage:
   case GlobalValue::WeakLinkage:

Modified: llvm/trunk/lib/AsmParser/LLToken.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLToken.h (original)
+++ llvm/trunk/lib/AsmParser/LLToken.h Thu Jan 15 14:18:42 2009
@@ -36,7 +36,7 @@
     kw_declare, kw_define,
     kw_global,  kw_constant,
 
-    kw_internal, kw_linkonce, kw_weak, kw_appending, kw_dllimport,
+    kw_private, kw_internal, kw_linkonce, kw_weak, kw_appending, kw_dllimport,
     kw_dllexport, kw_common, kw_default, kw_hidden, kw_protected,
     kw_extern_weak,
     kw_external, kw_thread_local,

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu Jan 15 14:18:42 2009
@@ -67,6 +67,7 @@
   case 6: return GlobalValue::DLLExportLinkage;
   case 7: return GlobalValue::ExternalWeakLinkage;
   case 8: return GlobalValue::CommonLinkage;
+  case 9: return GlobalValue::PrivateLinkage;
   }
 }
 

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Thu Jan 15 14:18:42 2009
@@ -284,6 +284,7 @@
   case GlobalValue::DLLExportLinkage:    return 6;
   case GlobalValue::ExternalWeakLinkage: return 7;
   case GlobalValue::CommonLinkage:       return 8;
+  case GlobalValue::PrivateLinkage:      return 9;
   }
 }
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -139,7 +139,7 @@
 }
 
 bool AsmPrinter::doInitialization(Module &M) {
-  Mang = new Mangler(M, TAI->getGlobalPrefix());
+  Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix());
   
   GCModuleInfo *MI = getAnalysisToUpdate<GCModuleInfo>();
   assert(MI && "AsmPrinter didn't require GCModuleInfo?");
@@ -199,7 +199,7 @@
         O << "\t.globl\t" << Name << '\n';
       else if (I->hasWeakLinkage())
         O << TAI->getWeakRefDirective() << Name << '\n';
-      else if (!I->hasInternalLinkage())
+      else if (!I->hasLocalLinkage())
         assert(0 && "Invalid alias linkage");
 
       printVisibility(Name, I->getVisibility());

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Thu Jan 15 14:18:42 2009
@@ -3272,7 +3272,8 @@
     // Externally visible entry into the functions eh frame info.
     // If the corresponding function is static, this should not be
     // externally visible.
-    if (linkage != Function::InternalLinkage) {
+    if (linkage != Function::InternalLinkage &&
+	linkage != Function::PrivateLinkage) {
       if (const char *GlobalEHDirective = TAI->getGlobalEHDirective())
         O << GlobalEHDirective << EHFrameInfo.FnName << "\n";
     }

Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ELFWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/ELFWriter.cpp Thu Jan 15 14:18:42 2009
@@ -174,6 +174,8 @@
   case GlobalValue::WeakLinkage:
     FnSym.SetBind(ELFWriter::ELFSym::STB_WEAK);
     break;
+  case GlobalValue::PrivateLinkage:
+    assert (0 && "PrivateLinkage should not be in the symbol table.");
   case GlobalValue::InternalLinkage:
     FnSym.SetBind(ELFWriter::ELFSym::STB_LOCAL);
     break;
@@ -329,7 +331,8 @@
 
     // Set the idx of the .bss section
     BSSSym.SectionIdx = BSSSection.SectionIdx;
-    SymbolTable.push_back(BSSSym);
+    if (!GV->hasPrivateLinkage())
+      SymbolTable.push_back(BSSSym);
 
     // Reserve space in the .bss section for this symbol.
     BSSSection.Size += Size;

Modified: llvm/trunk/lib/CodeGen/MachOWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachOWriter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/MachOWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachOWriter.cpp Thu Jan 15 14:18:42 2009
@@ -371,7 +371,7 @@
       SecDataOut.outbyte(0);
   }
   // Globals without external linkage apparently do not go in the symbol table.
-  if (GV->getLinkage() != GlobalValue::InternalLinkage) {
+  if (!GV->hasLocalLinkage()) {
     MachOSym Sym(GV, Mang->getValueName(GV), Sec->Index, TM);
     Sym.n_value = Sec->size;
     SymbolTable.push_back(Sym);
@@ -959,6 +959,9 @@
     GVName = TAI->getGlobalPrefix() + name;
     n_type |= GV->hasHiddenVisibility() ? N_PEXT : N_EXT;
     break;
+  case GlobalValue::PrivateLinkage:
+    GVName = TAI->getPrivateGlobalPrefix() + name;
+    break;
   case GlobalValue::InternalLinkage:
     GVName = TAI->getGlobalPrefix() + name;
     break;

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Thu Jan 15 14:18:42 2009
@@ -4276,7 +4276,7 @@
     // Check for well-known libc/libm calls.  If the function is internal, it
     // can't be a library call.
     unsigned NameLen = F->getNameLen();
-    if (!F->hasInternalLinkage() && NameLen) {
+    if (!F->hasLocalLinkage() && NameLen) {
       const char *NameStr = F->getNameStart();
       if (NameStr[0] == 'c' &&
           ((NameLen == 8 && !strcmp(NameStr, "copysign")) ||

Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Thu Jan 15 14:18:42 2009
@@ -249,7 +249,7 @@
  // an old-style (llvmgcc3) static ctor with __main linked in and in use.  If
  // this is the case, don't execute any of the global ctors, __main will do
  // it.
- if (!GV || GV->isDeclaration() || GV->hasInternalLinkage()) return;
+ if (!GV || GV->isDeclaration() || GV->hasLocalLinkage()) return;
  
  // Should be an array of '{ int, void ()* }' structs.  The first value is
  // the init priority, which we ignore.
@@ -893,7 +893,7 @@
       for (Module::const_global_iterator I = M.global_begin(),
            E = M.global_end(); I != E; ++I) {
         const GlobalValue *GV = I;
-        if (GV->hasInternalLinkage() || GV->isDeclaration() ||
+        if (GV->hasLocalLinkage() || GV->isDeclaration() ||
             GV->hasAppendingLinkage() || !GV->hasName())
           continue;// Ignore external globals and globals with internal linkage.
           

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Thu Jan 15 14:18:42 2009
@@ -554,7 +554,7 @@
     addGlobalMapping(GV, Ptr);
     }
   } else {
-    if (isGVCompilationDisabled() && !GV->hasInternalLinkage()) {
+    if (isGVCompilationDisabled() && !GV->hasLocalLinkage()) {
       cerr << "Compilation of non-internal GlobalValue is disabled!\n";
       abort();
     }

Modified: llvm/trunk/lib/Linker/LinkArchives.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkArchives.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Linker/LinkArchives.cpp (original)
+++ llvm/trunk/lib/Linker/LinkArchives.cpp Thu Jan 15 14:18:42 2009
@@ -50,7 +50,7 @@
     if (I->hasName()) {
       if (I->isDeclaration())
         UndefinedSymbols.insert(I->getName());
-      else if (!I->hasInternalLinkage()) {
+      else if (!I->hasLocalLinkage()) {
         assert(!I->hasDLLImportLinkage()
                && "Found dllimported non-external symbol!");
         DefinedSymbols.insert(I->getName());
@@ -62,7 +62,7 @@
     if (I->hasName()) {
       if (I->isDeclaration())
         UndefinedSymbols.insert(I->getName());
-      else if (!I->hasInternalLinkage()) {
+      else if (!I->hasLocalLinkage()) {
         assert(!I->hasDLLImportLinkage()
                && "Found dllimported non-external symbol!");
         DefinedSymbols.insert(I->getName());

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Thu Jan 15 14:18:42 2009
@@ -1,4 +1,4 @@
-//===- lib/Linker/LinkModules.cpp - Module Linker Implementation ----------===//
+ //===- lib/Linker/LinkModules.cpp - Module Linker Implementation ----------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -415,7 +415,7 @@
 
   // If there is a conflict, rename the conflict.
   if (GlobalValue *ConflictGV = cast_or_null<GlobalValue>(ST.lookup(Name))) {
-    assert(ConflictGV->hasInternalLinkage() &&
+    assert(ConflictGV->hasLocalLinkage() &&
            "Not conflicting with a static global, should link instead!");
     GV->takeName(ConflictGV);
     ConflictGV->setName(Name);    // This will cause ConflictGV to get renamed
@@ -444,7 +444,7 @@
 static bool GetLinkageResult(GlobalValue *Dest, const GlobalValue *Src,
                              GlobalValue::LinkageTypes &LT, bool &LinkFromSrc,
                              std::string *Err) {
-  assert((!Dest || !Src->hasInternalLinkage()) &&
+  assert((!Dest || !Src->hasLocalLinkage()) &&
          "If Src has internal linkage, Dest shouldn't be set!");
   if (!Dest) {
     // Linking something to nothing.
@@ -536,13 +536,13 @@
 
     // Check to see if may have to link the global with the global, alias or
     // function.
-    if (SGV->hasName() && !SGV->hasInternalLinkage())
+    if (SGV->hasName() && !SGV->hasLocalLinkage())
       DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SGV->getNameStart(),
                                                         SGV->getNameEnd()));
     
     // If we found a global with the same name in the dest module, but it has
     // internal linkage, we are really not doing any linkage here.
-    if (DGV && DGV->hasInternalLinkage())
+    if (DGV && DGV->hasLocalLinkage())
       DGV = 0;
     
     // If types don't agree due to opaque types, try to resolve them.
@@ -573,7 +573,7 @@
       // If the LLVM runtime renamed the global, but it is an externally visible
       // symbol, DGV must be an existing global with internal linkage.  Rename
       // it.
-      if (!NewDGV->hasInternalLinkage() && NewDGV->getName() != SGV->getName())
+      if (!NewDGV->hasLocalLinkage() && NewDGV->getName() != SGV->getName())
         ForceRenaming(NewDGV, SGV->getName());
 
       // Make sure to remember this mapping.
@@ -643,7 +643,7 @@
 
       // If the symbol table renamed the global, but it is an externally visible
       // symbol, DGV must be an existing global with internal linkage.  Rename.
-      if (NewDGV->getName() != SGV->getName() && !NewDGV->hasInternalLinkage())
+      if (NewDGV->getName() != SGV->getName() && !NewDGV->hasLocalLinkage())
         ForceRenaming(NewDGV, SGV->getName());
       
       // Inherit const as appropriate.
@@ -687,10 +687,12 @@
     return GlobalValue::ExternalLinkage;
   else if (SGV->hasWeakLinkage() || DGV->hasWeakLinkage())
     return GlobalValue::WeakLinkage;
-  else {
-    assert(SGV->hasInternalLinkage() && DGV->hasInternalLinkage() &&
-           "Unexpected linkage type");
+  else if (SGV->hasInternalLinkage() && DGV->hasInternalLinkage())
     return GlobalValue::InternalLinkage;
+  else {
+    assert (SGV->hasPrivateLinkage() && DGV->hasPrivateLinkage() &&
+	    "Unexpected linkage type");
+    return GlobalValue::PrivateLinkage;
   }
 }
 
@@ -715,7 +717,7 @@
     GlobalValue* DGV = NULL;
 
     // Try to find something 'similar' to SGA in destination module.
-    if (!DGV && !SGA->hasInternalLinkage()) {
+    if (!DGV && !SGA->hasLocalLinkage()) {
       DGV = Dest->getNamedAlias(SGA->getName());
 
       // If types don't agree due to opaque types, try to resolve them.
@@ -723,7 +725,7 @@
         RecursiveResolveTypes(SGA->getType(), DGV->getType());
     }
 
-    if (!DGV && !SGA->hasInternalLinkage()) {
+    if (!DGV && !SGA->hasLocalLinkage()) {
       DGV = Dest->getGlobalVariable(SGA->getName());
 
       // If types don't agree due to opaque types, try to resolve them.
@@ -731,7 +733,7 @@
         RecursiveResolveTypes(SGA->getType(), DGV->getType());
     }
 
-    if (!DGV && !SGA->hasInternalLinkage()) {
+    if (!DGV && !SGA->hasLocalLinkage()) {
       DGV = Dest->getFunction(SGA->getName());
 
       // If types don't agree due to opaque types, try to resolve them.
@@ -740,7 +742,7 @@
     }
 
     // No linking to be performed on internal stuff.
-    if (DGV && DGV->hasInternalLinkage())
+    if (DGV && DGV->hasLocalLinkage())
       DGV = NULL;
 
     if (GlobalAlias *DGA = dyn_cast_or_null<GlobalAlias>(DGV)) {
@@ -831,7 +833,7 @@
     // If the symbol table renamed the alias, but it is an externally visible
     // symbol, DGA must be an global value with internal linkage. Rename it.
     if (NewGA->getName() != SGA->getName() &&
-        !NewGA->hasInternalLinkage())
+        !NewGA->hasLocalLinkage())
       ForceRenaming(NewGA, SGA->getName());
 
     // Remember this mapping so uses in the source module get remapped
@@ -912,13 +914,13 @@
     
     // Check to see if may have to link the function with the global, alias or
     // function.
-    if (SF->hasName() && !SF->hasInternalLinkage())
+    if (SF->hasName() && !SF->hasLocalLinkage())
       DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SF->getNameStart(),
                                                         SF->getNameEnd()));
     
     // If we found a global with the same name in the dest module, but it has
     // internal linkage, we are really not doing any linkage here.
-    if (DGV && DGV->hasInternalLinkage())
+    if (DGV && DGV->hasLocalLinkage())
       DGV = 0;
 
     // If types don't agree due to opaque types, try to resolve them.
@@ -943,7 +945,7 @@
       // If the LLVM runtime renamed the function, but it is an externally
       // visible symbol, DF must be an existing function with internal linkage.
       // Rename it.
-      if (!NewDF->hasInternalLinkage() && NewDF->getName() != SF->getName())
+      if (!NewDF->hasLocalLinkage() && NewDF->getName() != SF->getName())
         ForceRenaming(NewDF, SF->getName());
       
       // ... and remember this mapping...
@@ -982,7 +984,7 @@
       // If the symbol table renamed the function, but it is an externally
       // visible symbol, DF must be an existing function with internal 
       // linkage.  Rename it.
-      if (NewDF->getName() != SF->getName() && !NewDF->hasInternalLinkage())
+      if (NewDF->getName() != SF->getName() && !NewDF->hasLocalLinkage())
         ForceRenaming(NewDF, SF->getName());
       
       // Remember this mapping so uses in the source module get remapped

Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Jan 15 14:18:42 2009
@@ -808,7 +808,7 @@
   GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
   Reloc::Model RelocM = getTargetMachine().getRelocationModel();
   if (RelocM == Reloc::PIC_) {
-    bool UseGOTOFF = GV->hasInternalLinkage() || GV->hasHiddenVisibility();
+    bool UseGOTOFF = GV->hasLocalLinkage() || GV->hasHiddenVisibility();
     ARMConstantPoolValue *CPV =
       new ARMConstantPoolValue(GV, ARMCP::CPValue, UseGOTOFF ? "GOTOFF":"GOT");
     SDValue CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 2);

Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -197,6 +197,7 @@
   const Function *F = MF.getFunction();
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
+  case Function::PrivateLinkage:
   case Function::InternalLinkage:
     SwitchToTextSection("\t.text", F);
     break;
@@ -847,11 +848,11 @@
       }
     }
 
-    if (GVar->hasInternalLinkage() || GVar->mayBeOverridden()) {
+    if (GVar->hasLocalLinkage() || GVar->mayBeOverridden()) {
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
       if (isDarwin) {
-        if (GVar->hasInternalLinkage()) {
+        if (GVar->hasLocalLinkage()) {
           O << TAI->getLCOMMDirective()  << name << "," << Size
             << ',' << Align;
         } else if (GVar->hasCommonLinkage()) {
@@ -869,7 +870,7 @@
           return;
         }
       } else if (TAI->getLCOMMDirective() != NULL) {
-        if (GVar->hasInternalLinkage()) {
+        if (GVar->hasLocalLinkage()) {
           O << TAI->getLCOMMDirective() << name << "," << Size;
         } else {
           O << TAI->getCOMMDirective()  << name << "," << Size;
@@ -878,7 +879,7 @@
         }
       } else {
         SwitchToSection(TAI->SectionForGlobal(GVar));
-        if (GVar->hasInternalLinkage())
+        if (GVar->hasLocalLinkage())
           O << "\t.local\t" << name << "\n";
         O << TAI->getCOMMDirective()  << name << "," << Size;
         if (TAI->getCOMMDirectiveTakesAlignment())
@@ -909,6 +910,7 @@
    case GlobalValue::ExternalLinkage:
     O << "\t.globl " << name << "\n";
     // FALL THROUGH
+   case GlobalValue::PrivateLinkage:
    case GlobalValue::InternalLinkage:
     break;
    default:

Modified: llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp Thu Jan 15 14:18:42 2009
@@ -513,7 +513,7 @@
     SDValue GA = DAG.getTargetGlobalAddress(GV, MVT::i64, GSDN->getOffset());
 
     //    if (!GV->hasWeakLinkage() && !GV->isDeclaration() && !GV->hasLinkOnceLinkage()) {
-    if (GV->hasInternalLinkage()) {
+    if (GV->hasLocalLinkage()) {
       SDValue Hi = DAG.getNode(AlphaISD::GPRelHi,  MVT::i64, GA,
                                 DAG.getNode(ISD::GLOBAL_OFFSET_TABLE, MVT::i64));
       SDValue Lo = DAG.getNode(AlphaISD::GPRelLo, MVT::i64, GA, Hi);

Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -169,6 +169,7 @@
 
   O << "\t.ent " << CurrentFnName << "\n";
 
+  assert (!F->hasPrivateLinkage() && "add private prefix.");
   O << CurrentFnName << ":\n";
 
   // Print out code for the function.

Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Thu Jan 15 14:18:42 2009
@@ -1910,7 +1910,7 @@
         if (getGlobalVariableClass(I))
           continue;
 
-        if (I->hasInternalLinkage())
+        if (I->hasLocalLinkage())
           Out << "static ";
         else
           Out << "extern ";
@@ -1946,7 +1946,7 @@
         if (getGlobalVariableClass(I))
           continue;
 
-        if (I->hasInternalLinkage())
+        if (I->hasLocalLinkage())
           Out << "static ";
         else if (I->hasDLLImportLinkage())
           Out << "__declspec(dllimport) ";
@@ -2190,7 +2190,7 @@
   /// isStructReturn - Should this function actually return a struct by-value?
   bool isStructReturn = F->hasStructRetAttr();
   
-  if (F->hasInternalLinkage()) Out << "static ";
+  if (F->hasLocalLinkage()) Out << "static ";
   if (F->hasDLLImportLinkage()) Out << "__declspec(dllimport) ";
   if (F->hasDLLExportLinkage()) Out << "__declspec(dllexport) ";  
   switch (F->getCallingConv()) {

Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -442,6 +442,7 @@
 
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
+  case Function::PrivateLinkage:
   case Function::InternalLinkage:  // Symbols default to internal.
     break;
   case Function::ExternalLinkage:
@@ -536,7 +537,7 @@
 
   if (C->isNullValue() && /* FIXME: Verify correct */
       !GVar->hasSection() &&
-      (GVar->hasInternalLinkage() || GVar->hasExternalLinkage() ||
+      (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
        GVar->mayBeOverridden())) {
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
@@ -545,7 +546,7 @@
         O << "\t.type " << name << ", @object\n";
         O << name << ":\n";
         O << "\t.zero " << Size << '\n';
-      } else if (GVar->hasInternalLinkage()) {
+      } else if (GVar->hasLocalLinkage()) {
         O << TAI->getLCOMMDirective() << name << ',' << Size;
       } else {
         O << ".comm " << name << ',' << Size;
@@ -573,6 +574,7 @@
     O << "\t.global " << name << '\n'
       << "\t.type " << name << ", @object\n";
     // FALL THROUGH
+   case GlobalValue::PrivateLinkage:
    case GlobalValue::InternalLinkage:
     break;
    default:
@@ -617,4 +619,3 @@
                                             SPUTargetMachine &tm) {
   return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo());
 }
-

Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original)
+++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Thu Jan 15 14:18:42 2009
@@ -292,6 +292,8 @@
     switch (LT) {
     case GlobalValue::InternalLinkage:
       Out << "GlobalValue::InternalLinkage"; break;
+    case GlobalValue::PrivateLinkage:
+      Out << "GlobalValue::PrivateLinkage"; break;
     case GlobalValue::LinkOnceLinkage:
       Out << "GlobalValue::LinkOnceLinkage "; break;
     case GlobalValue::WeakLinkage:

Modified: llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp Thu Jan 15 14:18:42 2009
@@ -61,7 +61,7 @@
                                           Mangler *Mang) const {
   if (GV==0)
     return false;
-  if (GV->hasInternalLinkage() && !isa<Function>(GV) &&
+  if (GV->hasLocalLinkage() && !isa<Function>(GV) &&
       ((strlen(getPrivateGlobalPrefix()) != 0 &&
         Mang->getValueName(GV).substr(0,strlen(getPrivateGlobalPrefix())) ==
           getPrivateGlobalPrefix()) ||

Modified: llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Thu Jan 15 14:18:42 2009
@@ -44,6 +44,7 @@
   if (const Function *F = dyn_cast<Function>(GV)) {
     switch (F->getLinkage()) {
      default: assert(0 && "Unknown linkage type!");
+     case Function::PrivateLinkage:
      case Function::InternalLinkage:
      case Function::DLLExportLinkage:
      case Function::ExternalLinkage:
@@ -184,4 +185,3 @@
 
   return Flags;
 }
-

Modified: llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/IA64/IA64AsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -275,10 +275,10 @@
 
   if (C->isNullValue() && !GVar->hasSection()) {
     if (!GVar->isThreadLocal() &&
-        (GVar->hasInternalLinkage() || GVar->mayBeOverridden())) {
+        (GVar->hasLocalLinkage() || GVar->mayBeOverridden())) {
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
-      if (GVar->hasInternalLinkage()) {
+      if (GVar->hasLocalLinkage()) {
         O << "\t.lcomm " << name << "#," << Size
           << ',' << (1 << Align);
         O << '\n';
@@ -307,6 +307,7 @@
     O << TAI->getGlobalDirective() << name << '\n';
     // FALL THROUGH
    case GlobalValue::InternalLinkage:
+   case GlobalValue::PrivateLinkage:
     break;
    case GlobalValue::GhostLinkage:
     cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n";

Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original)
+++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Thu Jan 15 14:18:42 2009
@@ -349,10 +349,10 @@
     return ArgumentVT;
   // Function
   else if (const Function* F = dyn_cast<Function>(V))
-    return F->hasInternalLinkage() ? InternalVT : GlobalVT;
+    return F->hasLocalLinkage() ? InternalVT : GlobalVT;
   // Variable
   else if (const GlobalVariable* G = dyn_cast<GlobalVariable>(V))
-    return G->hasInternalLinkage() ? InternalVT : GlobalVT;
+    return G->hasLocalLinkage() ? InternalVT : GlobalVT;
   // Constant
   else if (isa<Constant>(V))
     return isa<ConstantExpr>(V) ? ConstExprVT : ConstVT;
@@ -1401,7 +1401,7 @@
 void MSILWriter::printFunction(const Function& F) {
   bool isSigned = F.paramHasAttr(0, Attribute::SExt);
   Out << "\n.method static ";
-  Out << (F.hasInternalLinkage() ? "private " : "public ");
+  Out << (F.hasLocalLinkage() ? "private " : "public ");
   if (F.isVarArg()) Out << "vararg ";
   Out << getTypeName(F.getReturnType(),isSigned) << 
     getConvModopt(F.getCallingConv()) << getValueName(&F) << '\n';

Modified: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -275,9 +275,6 @@
 
   O << "\n\n";
 
-  // What's my mangled name?
-  CurrentFnName = Mang->getValueName(MF.getFunction());
-
   // Emit the function start directives
   emitFunctionStart(MF);
 
@@ -384,7 +381,10 @@
       return;
 
     case MachineOperand::MO_GlobalAddress:
-      O << Mang->getValueName(MO.getGlobal());
+      {
+        const GlobalValue *GV = MO.getGlobal();
+        O << Mang->getValueName(GV);
+      }
       break;
 
     case MachineOperand::MO_ExternalSymbol:
@@ -449,7 +449,7 @@
 bool MipsAsmPrinter::
 doInitialization(Module &M) 
 {
-  Mang = new Mangler(M);
+  Mang = new Mangler(M, "", TAI->getPrivateGlobalPrefix());
 
   // Tell the assembler which ABI we are using
   O << "\t.section .mdebug." << emitCurrentABIString() << '\n';
@@ -502,10 +502,10 @@
 
   if (C->isNullValue() && !GVar->hasSection()) {
     if (!GVar->isThreadLocal() &&
-        (GVar->hasInternalLinkage() || GVar->mayBeOverridden())) {
+        (GVar->hasLocalLinkage() || GVar->mayBeOverridden())) {
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
-      if (GVar->hasInternalLinkage())
+      if (GVar->hasLocalLinkage())
         O << "\t.local\t" << name << '\n';
 
       O << TAI->getCOMMDirective() << name << ',' << Size;
@@ -531,6 +531,7 @@
     // If external or appending, declare as a global symbol
     O << TAI->getGlobalDirective() << name << '\n';
     // Fall Through
+   case GlobalValue::PrivateLinkage:
    case GlobalValue::InternalLinkage:
     if (CVA && CVA->isCString())
       printSizeAndType = false;

Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Thu Jan 15 14:18:42 2009
@@ -216,7 +216,7 @@
 
   // if this is a internal constant string, there is a special
   // section for it, but not in small data/bss.
-  if (GVA->hasInitializer() && GV->hasInternalLinkage()) {
+  if (GVA->hasInitializer() && GV->hasLocalLinkage()) {
     Constant *C = GVA->getInitializer();
     const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
     if (CVA && CVA->isCString()) 
@@ -489,7 +489,7 @@
     SDValue ResNode = DAG.getLoad(MVT::i32, DAG.getEntryNode(), GA, NULL, 0);
     // On functions and global targets not internal linked only
     // a load from got/GP is necessary for PIC to work.
-    if (!GV->hasInternalLinkage() || isa<Function>(GV))
+    if (!GV->hasLocalLinkage() || isa<Function>(GV))
       return ResNode;
     SDValue Lo = DAG.getNode(MipsISD::Lo, MVT::i32, GA);
     return DAG.getNode(ISD::ADD, MVT::i32, ResNode, Lo);

Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -584,6 +584,7 @@
 
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
+  case Function::PrivateLinkage:
   case Function::InternalLinkage:  // Symbols default to internal.
     break;
   case Function::ExternalLinkage:
@@ -686,7 +687,7 @@
 
   if (C->isNullValue() && /* FIXME: Verify correct */
       !GVar->hasSection() &&
-      (GVar->hasInternalLinkage() || GVar->hasExternalLinkage() ||
+      (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
        GVar->mayBeOverridden())) {
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
@@ -695,7 +696,7 @@
         O << "\t.type " << name << ", @object\n";
         O << name << ":\n";
         O << "\t.zero " << Size << '\n';
-      } else if (GVar->hasInternalLinkage()) {
+      } else if (GVar->hasLocalLinkage()) {
         O << TAI->getLCOMMDirective() << name << ',' << Size;
       } else {
         O << ".comm " << name << ',' << Size;
@@ -723,6 +724,7 @@
       << "\t.type " << name << ", @object\n";
     // FALL THROUGH
    case GlobalValue::InternalLinkage:
+   case GlobalValue::PrivateLinkage:
     break;
    default:
     cerr << "Unknown linkage type!";
@@ -911,7 +913,7 @@
 
   if (C->isNullValue() && /* FIXME: Verify correct */
       !GVar->hasSection() &&
-      (GVar->hasInternalLinkage() || GVar->hasExternalLinkage() ||
+      (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
        GVar->mayBeOverridden())) {
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
@@ -919,7 +921,7 @@
       O << "\t.globl " << name << '\n';
       O << "\t.zerofill __DATA, __common, " << name << ", "
         << Size << ", " << Align;
-    } else if (GVar->hasInternalLinkage()) {
+    } else if (GVar->hasLocalLinkage()) {
       O << TAI->getLCOMMDirective() << name << ',' << Size << ',' << Align;
     } else if (!GVar->hasCommonLinkage()) {
       O << "\t.globl " << name << '\n'

Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -98,8 +98,6 @@
   static unsigned BBNumber = 0;
 
   O << "\n\n";
-  // What's my mangled name?
-  CurrentFnName = Mang->getValueName(MF.getFunction());
 
   // Print out the label for the function.
   const Function *F = MF.getFunction();
@@ -168,7 +166,10 @@
     printBasicBlockLabel(MO.getMBB());
     return;
   case MachineOperand::MO_GlobalAddress:
-    O << Mang->getValueName(MO.getGlobal());
+    {
+      const GlobalValue *GV = MO.getGlobal();
+      O << Mang->getValueName(GV);
+    }
     break;
   case MachineOperand::MO_ExternalSymbol:
     O << MO.getSymbolName();
@@ -218,7 +219,7 @@
 }
 
 bool SparcAsmPrinter::doInitialization(Module &M) {
-  Mang = new Mangler(M);
+  Mang = new Mangler(M, "", TAI->getPrivateGlobalPrefix());
   return false; // success
 }
 
@@ -255,10 +256,10 @@
 
   if (C->isNullValue() && !GVar->hasSection()) {
     if (!GVar->isThreadLocal() &&
-        (GVar->hasInternalLinkage() || GVar->mayBeOverridden())) {
+        (GVar->hasLocalLinkage() || GVar->mayBeOverridden())) {
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
-      if (GVar->hasInternalLinkage())
+      if (GVar->hasLocalLinkage())
         O << "\t.local " << name << '\n';
 
       O << TAI->getCOMMDirective() << name << ',' << Size;
@@ -284,6 +285,7 @@
     // If external or appending, declare as a global symbol
     O << TAI->getGlobalDirective() << name << '\n';
     // FALL THROUGH
+   case GlobalValue::PrivateLinkage:
    case GlobalValue::InternalLinkage:
     break;
    case GlobalValue::GhostLinkage:

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -159,6 +159,7 @@
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
   case Function::InternalLinkage:  // Symbols default to internal.
+  case Function::PrivateLinkage:
     EmitAlignment(FnAlign, F);
     break;
   case Function::DLLExportLinkage:
@@ -188,7 +189,7 @@
   else if (Subtarget->isTargetCygMing()) {
     O << "\t.def\t " << CurrentFnName
       << ";\t.scl\t" <<
-      (F->getLinkage() == Function::InternalLinkage ? COFF::C_STAT : COFF::C_EXT)
+      (F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT)
       << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
       << ";\t.endef\n";
   }
@@ -421,7 +422,7 @@
         if (shouldPrintPLT(TM, Subtarget)) {
           // Assemble call via PLT for externally visible symbols
           if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() &&
-              !GV->hasInternalLinkage())
+              !GV->hasLocalLinkage())
             O << "@PLT";
         }
         if (Subtarget->isTargetCygMing() && GV->isDeclaration())
@@ -789,11 +790,11 @@
     }
 
     if (!GVar->isThreadLocal() &&
-        (GVar->hasInternalLinkage() || GVar->mayBeOverridden())) {
+        (GVar->hasLocalLinkage() || GVar->mayBeOverridden())) {
       if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
       if (TAI->getLCOMMDirective() != NULL) {
-        if (GVar->hasInternalLinkage()) {
+        if (GVar->hasLocalLinkage()) {
           O << TAI->getLCOMMDirective() << name << ',' << Size;
           if (Subtarget->isTargetDarwin())
             O << ',' << Align;
@@ -813,7 +814,7 @@
         }
       } else {
         if (!Subtarget->isTargetCygMing()) {
-          if (GVar->hasInternalLinkage())
+          if (GVar->hasLocalLinkage())
             O << "\t.local\t" << name << '\n';
         }
         O << TAI->getCOMMDirective()  << name << ',' << Size;
@@ -849,6 +850,7 @@
     // If external or appending, declare as a global symbol
     O << "\t.globl " << name << '\n';
     // FALL THROUGH
+  case GlobalValue::PrivateLinkage:
   case GlobalValue::InternalLinkage:
      break;
   default:

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -145,6 +145,7 @@
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unsupported linkage type!");
+  case Function::PrivateLinkage:
   case Function::InternalLinkage:
     EmitAlignment(FnAlign);
     break;

Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Thu Jan 15 14:18:42 2009
@@ -56,7 +56,7 @@
       // Extra load is needed for all externally visible.
       if (isDirectCall)
         return false;
-      if (GV->hasInternalLinkage() || GV->hasHiddenVisibility())
+      if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
         return false;
       return true;
     } else if (isTargetCygMing() || isTargetWindows()) {
@@ -79,7 +79,7 @@
   // returns false.
   if (TM.getRelocationModel() == Reloc::PIC_)
     return !isDirectCall && 
-      (GV->hasInternalLinkage() || GV->hasExternalLinkage());
+      (GV->hasLocalLinkage() || GV->hasExternalLinkage());
   return false;
 }
 

Modified: llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Thu Jan 15 14:18:42 2009
@@ -198,6 +198,7 @@
       }
       // FALL THROUGH
     case GlobalValue::InternalLinkage:
+    case GlobalValue::PrivateLinkage:
       break;
     case GlobalValue::GhostLinkage:
       cerr << "Should not have any unmaterialized functions!\n";
@@ -259,6 +260,7 @@
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
   case Function::InternalLinkage:  // Symbols default to internal.
+  case Function::PrivateLinkage:
     break;
   case Function::ExternalLinkage:
     emitGlobalDirective(CurrentFnName);
@@ -299,9 +301,6 @@
   // Print out jump tables referenced by the function
   EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
 
-  // What's my mangled name?
-  CurrentFnName = Mang->getValueName(MF.getFunction());
-
   // Emit the function start directives
   emitFunctionStart(MF);
   
@@ -367,9 +366,12 @@
     printBasicBlockLabel(MO.getMBB());
     break;
   case MachineOperand::MO_GlobalAddress:
-    O << Mang->getValueName(MO.getGlobal());
-    if (MO.getGlobal()->hasExternalWeakLinkage())
-      ExtWeakSymbols.insert(MO.getGlobal());
+    {
+      const GlobalValue *GV = MO.getGlobal();
+      O << Mang->getValueName(GV);
+      if (GV->hasExternalWeakLinkage())
+        ExtWeakSymbols.insert(GV);
+    }
     break;
   case MachineOperand::MO_ExternalSymbol:
     O << MO.getSymbolName();

Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Thu Jan 15 14:18:42 2009
@@ -114,7 +114,7 @@
   Function *F = CGN->getFunction();
 
   // Make sure that it is local to this module.
-  if (!F || !F->hasInternalLinkage()) return false;
+  if (!F || !F->hasLocalLinkage()) return false;
 
   // First check: see if there are any pointer arguments!  If not, quick exit.
   SmallVector<std::pair<Argument*, unsigned>, 16> PointerArgs;

Modified: llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp Thu Jan 15 14:18:42 2009
@@ -72,7 +72,7 @@
       
       // If this GV is dead, remove it.
       GV->removeDeadConstantUsers();
-      if (GV->use_empty() && GV->hasInternalLinkage()) {
+      if (GV->use_empty() && GV->hasLocalLinkage()) {
         GV->eraseFromParent();
         continue;
       }
@@ -86,7 +86,7 @@
 
         if (Slot == 0) {    // Nope, add it to the map.
           Slot = GV;
-        } else if (GV->hasInternalLinkage()) {    // Yup, this is a duplicate!
+        } else if (GV->hasLocalLinkage()) {    // Yup, this is a duplicate!
           // Make all uses of the duplicate constant use the canonical version.
           Replacements.push_back(std::make_pair(GV, Slot));
         }

Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Thu Jan 15 14:18:42 2009
@@ -172,7 +172,7 @@
 /// llvm.vastart is never called, the varargs list is dead for the function.
 bool DAE::DeleteDeadVarargs(Function &Fn) {
   assert(Fn.getFunctionType()->isVarArg() && "Function isn't varargs!");
-  if (Fn.isDeclaration() || !Fn.hasInternalLinkage()) return false;
+  if (Fn.isDeclaration() || !Fn.hasLocalLinkage()) return false;
 
   // Ensure that the function is only directly called.
   for (Value::use_iterator I = Fn.use_begin(), E = Fn.use_end(); I != E; ++I) {
@@ -424,7 +424,7 @@
         return;
       }
 
-  if (!F.hasInternalLinkage() && (!ShouldHackArguments() || F.isIntrinsic())) {
+  if (!F.hasLocalLinkage() && (!ShouldHackArguments() || F.isIntrinsic())) {
     MarkLive(F);
     return;
   }

Modified: llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp Thu Jan 15 14:18:42 2009
@@ -63,7 +63,7 @@
                   I != E; ++I) {
                if (CallInst* callInst = dyn_cast<CallInst>(&*I)) {
                  Function* Callee = callInst->getCalledFunction();
-                 if (Callee && Callee->hasInternalLinkage())
+                 if (Callee && Callee->hasLocalLinkage())
                    Callee->setLinkage(GlobalValue::ExternalLinkage);
                }
              }
@@ -85,6 +85,7 @@
 
     bool isolateGV(Module &M) {
       // Mark all globals internal
+      // FIXME: what should we do with private linkage?
       for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
         if (!I->isDeclaration()) {
           I->setLinkage(GlobalValue::InternalLinkage);

Modified: llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalDCE.cpp Thu Jan 15 14:18:42 2009
@@ -63,7 +63,7 @@
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
     Changed |= RemoveUnusedGlobalValue(*I);
     // Functions with external linkage are needed if they have a body
-    if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) &&
+    if ((!I->hasLocalLinkage() && !I->hasLinkOnceLinkage()) &&
         !I->isDeclaration())
       GlobalIsNeeded(I);
   }
@@ -73,7 +73,7 @@
     Changed |= RemoveUnusedGlobalValue(*I);
     // Externally visible & appending globals are needed, if they have an
     // initializer.
-    if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) &&
+    if ((!I->hasLocalLinkage() && !I->hasLinkOnceLinkage()) &&
         !I->isDeclaration())
       GlobalIsNeeded(I);
   }

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Jan 15 14:18:42 2009
@@ -464,7 +464,7 @@
   if (!GlobalUsersSafeToSRA(GV))
     return 0;
   
-  assert(GV->hasInternalLinkage() && !GV->isConstant());
+  assert(GV->hasLocalLinkage() && !GV->isConstant());
   Constant *Init = GV->getInitializer();
   const Type *Ty = Init->getType();
 
@@ -1808,12 +1808,12 @@
   for (Module::iterator FI = M.begin(), E = M.end(); FI != E; ) {
     Function *F = FI++;
     F->removeDeadConstantUsers();
-    if (F->use_empty() && (F->hasInternalLinkage() ||
+    if (F->use_empty() && (F->hasLocalLinkage() ||
                            F->hasLinkOnceLinkage())) {
       M.getFunctionList().erase(F);
       Changed = true;
       ++NumFnDeleted;
-    } else if (F->hasInternalLinkage()) {
+    } else if (F->hasLocalLinkage()) {
       if (F->getCallingConv() == CallingConv::C && !F->isVarArg() &&
           OnlyCalledDirectly(F)) {
         // If this function has C calling conventions, is not a varargs
@@ -1843,7 +1843,7 @@
   for (Module::global_iterator GVI = M.global_begin(), E = M.global_end();
        GVI != E; ) {
     GlobalVariable *GV = GVI++;
-    if (!GV->isConstant() && GV->hasInternalLinkage() &&
+    if (!GV->isConstant() && GV->hasLocalLinkage() &&
         GV->hasInitializer())
       Changed |= ProcessInternalGlobal(GV, GVI);
   }
@@ -1982,7 +1982,7 @@
 /// globals.  This should be kept up to date with CommitValueTo.
 static bool isSimpleEnoughPointerToCommit(Constant *C) {
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
-    if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
+    if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage())
       return false;  // do not allow weak/linkonce/dllimport/dllexport linkage.
     return !GV->isDeclaration();  // reject external globals.
   }
@@ -1991,7 +1991,7 @@
     if (CE->getOpcode() == Instruction::GetElementPtr &&
         isa<GlobalVariable>(CE->getOperand(0))) {
       GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
-      if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
+      if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage())
         return false;  // do not allow weak/linkonce/dllimport/dllexport linkage.
       return GV->hasInitializer() &&
              ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE);

Modified: llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp Thu Jan 15 14:18:42 2009
@@ -63,7 +63,7 @@
       if (!I->isDeclaration()) {
         // Delete any klingons.
         I->removeDeadConstantUsers();
-        if (I->hasInternalLinkage())
+        if (I->hasLocalLinkage())
           LocalChange |= PropagateConstantsIntoArguments(*I);
         Changed |= PropagateConstantReturn(*I);
       }

Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Thu Jan 15 14:18:42 2009
@@ -68,7 +68,7 @@
 
   // If we inlined the last possible call site to the function, delete the
   // function body now.
-  if (Callee->use_empty() && Callee->hasInternalLinkage() &&
+  if (Callee->use_empty() && Callee->hasLocalLinkage() &&
       !SCCFunctions.count(Callee)) {
     DOUT << "    -> Deleting dead function: " << Callee->getName() << "\n";
     CallGraphNode *CalleeNode = CG[Callee];
@@ -240,7 +240,7 @@
       if (DNR && DNR->count(F))
         continue;
 
-      if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
+      if ((F->hasLinkOnceLinkage() || F->hasLocalLinkage()) &&
           F->use_empty()) {
 
         // Remove any call graph edges from the function to its callees.

Modified: llvm/trunk/lib/Transforms/IPO/Internalize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Internalize.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Internalize.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Internalize.cpp Thu Jan 15 14:18:42 2009
@@ -121,9 +121,10 @@
   bool Changed = false;
 
   // Mark all functions not in the api as internal.
+  // FIXME: maybe use private linkage?
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
     if (!I->isDeclaration() &&         // Function must be defined here
-        !I->hasInternalLinkage() &&  // Can't already have internal linkage
+        !I->hasLocalLinkage() &&  // Can't already have internal linkage
         !ExternalNames.count(I->getName())) {// Not marked to keep external?
       I->setLinkage(GlobalValue::InternalLinkage);
       // Remove a callgraph edge from the external node to this function.
@@ -149,9 +150,10 @@
 
   // Mark all global variables with initializers that are not in the api as
   // internal as well.
+  // FIXME: maybe use private linkage?
   for (Module::global_iterator I = M.global_begin(), E = M.global_end();
        I != E; ++I)
-    if (!I->isDeclaration() && !I->hasInternalLinkage() &&
+    if (!I->isDeclaration() && !I->hasLocalLinkage() &&
         !ExternalNames.count(I->getName())) {
       I->setLinkage(GlobalValue::InternalLinkage);
       Changed = true;

Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Thu Jan 15 14:18:42 2009
@@ -245,7 +245,7 @@
   Function *G = FnVec[j];
 
   if (!F->mayBeOverridden()) {
-    if (G->hasInternalLinkage()) {
+    if (G->hasLocalLinkage()) {
       F->setAlignment(std::max(F->getAlignment(), G->getAlignment()));
       G->replaceAllUsesWith(F);
       G->eraseFromParent();
@@ -329,7 +329,7 @@
     if (F->isDeclaration() || F->isIntrinsic())
       continue;
 
-    if (!F->hasInternalLinkage() && !F->hasExternalLinkage() &&
+    if (!F->hasLocalLinkage() && !F->hasExternalLinkage() &&
         !F->hasWeakLinkage())
       continue;
 

Modified: llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp Thu Jan 15 14:18:42 2009
@@ -95,7 +95,7 @@
         OnlyUsedBy(C->getOperand(i), C)) 
       Operands.insert(C->getOperand(i));
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
-    if (!GV->hasInternalLinkage()) return;   // Don't delete non static globals.
+    if (!GV->hasLocalLinkage()) return;   // Don't delete non static globals.
     GV->eraseFromParent();
   }
   else if (!isa<Function>(C))
@@ -114,7 +114,7 @@
   for (ValueSymbolTable::iterator VI = ST.begin(), VE = ST.end(); VI != VE; ) {
     Value *V = VI->getValue();
     ++VI;
-    if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasInternalLinkage()) {
+    if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasLocalLinkage()) {
       if (!PreserveDbgInfo || strncmp(V->getNameStart(), "llvm.dbg", 8))
         // Set name to "", removing from symbol table!
         V->setName("");
@@ -162,13 +162,13 @@
 
   for (Module::global_iterator I = M.global_begin(), E = M.global_end();
        I != E; ++I) {
-    if (I->hasInternalLinkage() && llvmUsedValues.count(I) == 0)
+    if (I->hasLocalLinkage() && llvmUsedValues.count(I) == 0)
       if (!PreserveDbgInfo || strncmp(I->getNameStart(), "llvm.dbg", 8))
         I->setName("");     // Internal symbols can't participate in linkage
   }
   
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
-    if (I->hasInternalLinkage() && llvmUsedValues.count(I) == 0)
+    if (I->hasLocalLinkage() && llvmUsedValues.count(I) == 0)
       if (!PreserveDbgInfo || strncmp(I->getNameStart(), "llvm.dbg", 8))
         I->setName("");     // Internal symbols can't participate in linkage
     StripSymtab(I->getValueSymbolTable(), PreserveDbgInfo);
@@ -268,6 +268,7 @@
 
   // llvm.dbg.compile_units and llvm.dbg.subprograms are marked as linkonce
   // but since we are removing all debug information, make them internal now.
+  // FIXME: Use private linkage maybe?
   if (Constant *C = M.getNamedGlobal("llvm.dbg.compile_units"))
     if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
       GV->setLinkage(GlobalValue::InternalLinkage);
@@ -299,7 +300,7 @@
     Constant *C = DeadConstants.back();
     DeadConstants.pop_back();
     if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
-      if (GV->hasInternalLinkage())
+      if (GV->hasLocalLinkage())
         RemoveDeadConstant(GV);
     }
     else
@@ -329,4 +330,3 @@
 bool StripNonDebugSymbols::runOnModule(Module &M) {
   return StripSymbolNames(M, true);
 }
-

Modified: llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StructRetPromotion.cpp Thu Jan 15 14:18:42 2009
@@ -82,7 +82,7 @@
 bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
   Function *F = CGN->getFunction();
 
-  if (!F || F->isDeclaration() || !F->hasInternalLinkage())
+  if (!F || F->isDeclaration() || !F->hasLocalLinkage())
     return false;
 
   // Make sure that function returns struct.

Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Thu Jan 15 14:18:42 2009
@@ -203,7 +203,7 @@
   /// and out of the specified function (which cannot have its address taken),
   /// this method must be called.
   void AddTrackedFunction(Function *F) {
-    assert(F->hasInternalLinkage() && "Can only track internal functions!");
+    assert(F->hasLocalLinkage() && "Can only track internal functions!");
     // Add an entry, F -> undef.
     if (const StructType *STy = dyn_cast<StructType>(F->getReturnType())) {
       for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
@@ -609,7 +609,7 @@
 
   Function *F = I.getParent()->getParent();
   // If we are tracking the return value of this function, merge it in.
-  if (!F->hasInternalLinkage())
+  if (!F->hasLocalLinkage())
     return;
 
   if (!TrackedRetVals.empty() && I.getNumOperands() == 1) {
@@ -1170,7 +1170,7 @@
   // The common case is that we aren't tracking the callee, either because we
   // are not doing interprocedural analysis or the callee is indirect, or is
   // external.  Handle these cases first.
-  if (F == 0 || !F->hasInternalLinkage()) {
+  if (F == 0 || !F->hasLocalLinkage()) {
 CallOverdefined:
     // Void return and not tracking callee, just bail.
     if (I->getType() == Type::VoidTy) return;
@@ -1656,7 +1656,7 @@
   // taken or that are external as overdefined.
   //
   for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
-    if (!F->hasInternalLinkage() || AddressIsTaken(F)) {
+    if (!F->hasLocalLinkage() || AddressIsTaken(F)) {
       if (!F->isDeclaration())
         Solver.MarkBlockExecutable(F->begin());
       for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end();
@@ -1671,7 +1671,7 @@
   // their addresses taken, we can propagate constants through them.
   for (Module::global_iterator G = M.global_begin(), E = M.global_end();
        G != E; ++G)
-    if (!G->isConstant() && G->hasInternalLinkage() && !AddressIsTaken(G))
+    if (!G->isConstant() && G->hasLocalLinkage() && !AddressIsTaken(G))
       Solver.TrackValueOfGlobalVariable(G);
 
   // Solve for constants.

Modified: llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BasicInliner.cpp Thu Jan 15 14:18:42 2009
@@ -130,7 +130,7 @@
         
         // Inline
         if (InlineFunction(CS, NULL, TD)) {
-          if (Callee->use_empty() && Callee->hasInternalLinkage())
+          if (Callee->use_empty() && Callee->hasLocalLinkage())
             DeadFunctions.insert(Callee);
           Changed = true;
           CallSites.erase(CallSites.begin() + index);

Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Thu Jan 15 14:18:42 2009
@@ -199,7 +199,7 @@
   // If there is only one call of the function, and it has internal linkage,
   // make it almost guaranteed to be inlined.
   //
-  if (Callee->hasInternalLinkage() && Callee->hasOneUse())
+  if (Callee->hasLocalLinkage() && Callee->hasOneUse())
     InlineCost -= 15000;
   
   // If this function uses the coldcc calling convention, prefer not to inline

Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Jan 15 14:18:42 2009
@@ -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;

Modified: llvm/trunk/lib/VMCore/Mangler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Mangler.cpp (original)
+++ llvm/trunk/lib/VMCore/Mangler.cpp Thu Jan 15 14:18:42 2009
@@ -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.

Modified: llvm/trunk/lib/VMCore/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Module.cpp (original)
+++ llvm/trunk/lib/VMCore/Module.cpp Thu Jan 15 14:18:42 2009
@@ -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;
     }
 }
-

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Thu Jan 15 14:18:42 2009
@@ -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(),

Added: llvm/trunk/test/Assembler/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/Assembler/private.ll (added)
+++ llvm/trunk/test/Assembler/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,9 @@
+; Test to make sure that the 'private' tag is not lost!
+;
+; RUN: llvm-as < %s | llvm-dis | grep private
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}

Added: llvm/trunk/test/CodeGen/ARM/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/ARM/private.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,22 @@
+; Test to make sure that the 'private' is used correctly.
+;
+; RUN: llvm-as < %s | llc -mtriple=arm-linux-gnueabi > %t
+; RUN: grep .Lfoo: %t
+; RUN: egrep bl.*\.Lfoo %t
+; RUN: grep .Lbaz: %t
+; RUN: grep long.*\.Lbaz %t
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}
+
+ at baz = private global i32 4;
+
+define i32 @bar() {
+        call void @foo()
+	%1 = load i32* @baz, align 4
+        ret i32 %1
+}
+

Added: llvm/trunk/test/CodeGen/Alpha/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Alpha/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/Alpha/private.ll (added)
+++ llvm/trunk/test/CodeGen/Alpha/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,21 @@
+; Test to make sure that the 'private' is used correctly.
+;
+; RUN: llvm-as < %s | llc > %t
+; RUN: grep .Lfoo: %t
+; RUN: grep call.*\.Lfoo %t
+; RUN: grep .Lbaz: %t
+; RUN: grep movl.*\.Lbaz %t
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}
+
+ at baz = private global i32 4;
+
+define i32 @bar() {
+        call void @foo()
+	%1 = load i32* @baz, align 4
+        ret i32 %1
+}

Added: llvm/trunk/test/CodeGen/CellSPU/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/CellSPU/private.ll (added)
+++ llvm/trunk/test/CodeGen/CellSPU/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,22 @@
+; Test to make sure that the 'private' is used correctly.
+;
+; RUN: llvm-as < %s | llc -march=cellspu > %t
+; RUN: grep .Lfoo: %t
+; RUN: grep brsl.*\.Lfoo %t
+; RUN: grep .Lbaz: %t
+; RUN: grep ila.*\.Lbaz %t
+
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}
+
+ at baz = private global i32 4;
+
+define i32 @bar() {
+        call void @foo()
+	%1 = load i32* @baz, align 4
+        ret i32 %1
+}

Added: llvm/trunk/test/CodeGen/IA64/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/IA64/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/IA64/private.ll (added)
+++ llvm/trunk/test/CodeGen/IA64/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,21 @@
+; Test to make sure that the 'private' is used correctly.
+;
+; RUN: llvm-as < %s | llc -march=ia64 > %t
+; RUN: grep .foo: %t
+; RUN: grep br.call.sptk.*\.foo %t
+; RUN: grep .baz: %t
+; RUN: grep ltoff.*\.baz %t
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}
+
+ at baz = private global i32 4;
+
+define i32 @bar() {
+        call void @foo()
+	%1 = load i32* @baz, align 4
+        ret i32 %1
+}

Added: llvm/trunk/test/CodeGen/Mips/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/Mips/private.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,21 @@
+; Test to make sure that the 'private' is used correctly.
+;
+; RUN: llvm-as < %s | llc -march=mips > %t
+; RUN: grep \\\$foo: %t
+; RUN: grep call.*\\\$foo %t
+; RUN: grep \\\$baz: %t
+; RUN: grep lw.*\\\$baz %t
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}
+
+ at baz = private global i32 4;
+
+define i32 @bar() {
+        call void @foo()
+	%1 = load i32* @baz, align 4
+        ret i32 %1
+}

Added: llvm/trunk/test/CodeGen/PowerPC/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/private.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,21 @@
+; Test to make sure that the 'private' is used correctly.
+;
+; RUN: llvm-as < %s | llc -mtriple=powerpc-unknown-linux-gnu > %t
+; RUN: grep .Lfoo: %t
+; RUN: grep bl.*\.Lfoo %t
+; RUN: grep .Lbaz: %t
+; RUN: grep lis.*\.Lbaz %t
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}
+
+ at baz = private global i32 4;
+
+define i32 @bar() {
+        call void @foo()
+	%1 = load i32* @baz, align 4
+        ret i32 %1
+}

Added: llvm/trunk/test/CodeGen/SPARC/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/SPARC/private.ll (added)
+++ llvm/trunk/test/CodeGen/SPARC/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,21 @@
+; Test to make sure that the 'private' is used correctly.
+;
+; RUN: llvm-as < %s | llc  -march=sparc > %t
+; RUN: grep .foo: %t
+; RUN: grep call.*\.foo %t
+; RUN: grep .baz: %t
+; RUN: grep ld.*\.baz %t
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}
+
+ at baz = private global i32 4;
+
+define i32 @bar() {
+        call void @foo()
+	%1 = load i32* @baz, align 4
+        ret i32 %1
+}

Added: llvm/trunk/test/CodeGen/X86/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/private.ll (added)
+++ llvm/trunk/test/CodeGen/X86/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,20 @@
+; Test to make sure that the 'private' is used correctly.
+;
+; RUN: llvm-as < %s | llc -mtriple=x86_64-pc-linux | grep .Lfoo:
+; RUN: llvm-as < %s | llc -mtriple=x86_64-pc-linux | grep call.*\.Lfoo
+; RUN: llvm-as < %s | llc -mtriple=x86_64-pc-linux | grep .Lbaz:
+; RUN: llvm-as < %s | llc -mtriple=x86_64-pc-linux | grep movl.*\.Lbaz
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}
+
+ at baz = private global i32 4;
+
+define i32 @bar() {
+        call void @foo()
+	%1 = load i32* @baz, align 4
+        ret i32 %1
+}

Added: llvm/trunk/test/CodeGen/XCore/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/private.ll?rev=62279&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/XCore/private.ll (added)
+++ llvm/trunk/test/CodeGen/XCore/private.ll Thu Jan 15 14:18:42 2009
@@ -0,0 +1,21 @@
+; Test to make sure that the 'private' is used correctly.
+;
+; RUN: llvm-as < %s | llc -march=xcore > %t
+; RUN: grep .Lfoo: %t
+; RUN: grep bl.*\.Lfoo %t
+; RUN: grep .Lbaz: %t
+; RUN: grep ldw.*\.Lbaz %t
+
+declare void @foo()
+
+define private void @foo() {
+        ret void
+}
+
+ at baz = private global i32 4;
+
+define i32 @bar() {
+        call void @foo()
+	%1 = load i32* @baz, align 4
+        ret i32 %1
+}

Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Thu Jan 15 14:18:42 2009
@@ -199,7 +199,7 @@
 /// prune appropriate entries out of M1s list.
 static void SplitStaticCtorDtor(const char *GlobalName, Module *M1, Module *M2){
   GlobalVariable *GV = M1->getNamedGlobal(GlobalName);
-  if (!GV || GV->isDeclaration() || GV->hasInternalLinkage() ||
+  if (!GV || GV->isDeclaration() || GV->hasLocalLinkage() ||
       !GV->use_empty()) return;
   
   std::vector<std::pair<Function*, int> > M1Tors, M2Tors;

Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=62279&r1=62278&r2=62279&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Thu Jan 15 14:18:42 2009
@@ -68,6 +68,7 @@
 }
 
 static char TypeCharForSymbol(GlobalValue &GV) {
+  /* FIXME: what to do with private linkage? */
   if (GV.isDeclaration())                                  return 'U';
   if (GV.hasLinkOnceLinkage())                             return 'C';
   if (GV.hasCommonLinkage())                               return 'C';
@@ -91,7 +92,7 @@
     return;
   if ((TypeChar == 'U') && DefinedOnly)
     return;
-  if (GV.hasInternalLinkage () && ExternalOnly)
+  if (GV.hasLocalLinkage () && ExternalOnly)
     return;
   if (OutputFormat == posix) {
     std::cout << GV.getName () << " " << TypeCharForSymbol (GV) << " "





More information about the llvm-commits mailing list