[llvm-commits] [llvm] r107205 - in /llvm/trunk: bindings/ada/llvm/ docs/ include/llvm-c/ include/llvm/ include/llvm/CodeGen/ include/llvm/MC/ include/llvm/Target/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/CodeGen/ lib/CodeGen/AsmPrinter/ lib/Linker/ lib/MC/ lib/Target/ lib/Target/CppBackend/ lib/Target/XCore/AsmPrinter/ lib/Transforms/IPO/ lib/VMCore/ tools/llvm-nm/

Bill Wendling isanbard at gmail.com
Tue Jun 29 14:24:00 PDT 2010


Author: void
Date: Tue Jun 29 16:24:00 2010
New Revision: 107205

URL: http://llvm.org/viewvc/llvm-project?rev=107205&view=rev
Log:
Introducing the "linker_weak" linkage type. This will be used for Objective-C
metadata types which should be marked as "weak", but which the linker will
remove upon final linkage. For example, the "objc_msgSend_fixup_alloc" symbol is
defined like this:

       .globl l_objc_msgSend_fixup_alloc
       .weak_definition l_objc_msgSend_fixup_alloc
       .section __DATA, __objc_msgrefs, coalesced
       .align 3
l_objc_msgSend_fixup_alloc:
        .quad   _objc_msgSend_fixup
        .quad   L_OBJC_METH_VAR_NAME_1

This is different from the "linker_private" linkage type, because it can't have
the metadata defined with ".weak_definition".

Modified:
    llvm/trunk/bindings/ada/llvm/llvm.ads
    llvm/trunk/docs/LangRef.html
    llvm/trunk/include/llvm-c/Core.h
    llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
    llvm/trunk/include/llvm/CodeGen/MachineFunction.h
    llvm/trunk/include/llvm/GlobalValue.h
    llvm/trunk/include/llvm/MC/MCAsmInfo.h
    llvm/trunk/include/llvm/Target/Mangler.h
    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/MachineFunction.cpp
    llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    llvm/trunk/lib/Linker/LinkModules.cpp
    llvm/trunk/lib/MC/MCAsmInfo.cpp
    llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
    llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
    llvm/trunk/lib/Target/Mangler.cpp
    llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
    llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
    llvm/trunk/lib/VMCore/AsmWriter.cpp
    llvm/trunk/lib/VMCore/Core.cpp
    llvm/trunk/tools/llvm-nm/llvm-nm.cpp

Modified: llvm/trunk/bindings/ada/llvm/llvm.ads
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ada/llvm/llvm.ads?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/bindings/ada/llvm/llvm.ads (original)
+++ llvm/trunk/bindings/ada/llvm/llvm.ads Tue Jun 29 16:24:00 2010
@@ -316,7 +316,8 @@
       LLVMExternalWeakLinkage,
       LLVMGhostLinkage,
       LLVMCommonLinkage,
-      LLVMLinkerPrivateLinkage);
+      LLVMLinkerPrivateLinkage,
+      LLVMLinkerWeakLinkage);
 
    for LLVMLinkage use
      (LLVMExternalLinkage            => 0,
@@ -333,7 +334,8 @@
       LLVMExternalWeakLinkage        => 11,
       LLVMGhostLinkage               => 12,
       LLVMCommonLinkage              => 13,
-      LLVMLinkerPrivateLinkage       => 14);
+      LLVMLinkerPrivateLinkage       => 14,
+      LLVMLinkerWeakLinkage          => 15);
 
    pragma Convention (C, LLVMLinkage);
 

Modified: llvm/trunk/docs/LangRef.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/docs/LangRef.html (original)
+++ llvm/trunk/docs/LangRef.html Tue Jun 29 16:24:00 2010
@@ -24,6 +24,7 @@
         <ol>
           <li><a href="#linkage_private">'<tt>private</tt>' Linkage</a></li>
           <li><a href="#linkage_linker_private">'<tt>linker_private</tt>' Linkage</a></li>
+          <li><a href="#linkage_linker_weak">'<tt>linker_weak</tt>' Linkage</a></li>
           <li><a href="#linkage_internal">'<tt>internal</tt>' Linkage</a></li>
           <li><a href="#linkage_available_externally">'<tt>available_externally</tt>' Linkage</a></li>
           <li><a href="#linkage_linkonce">'<tt>linkonce</tt>' Linkage</a></li>
@@ -546,23 +547,27 @@
 
 <dl>
   <dt><tt><b><a name="linkage_private">private</a></b></tt></dt>
-  <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
-      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>
+  <dd>Global values with "<tt>private</tt>" linkage are only directly accessible
+      by objects in the current module.  In particular, linking code into a
+      module with 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_linker_private">linker_private</a></b></tt></dt>
-  <dd>Similar to private, but the symbol is passed through the assembler and
-      removed by the linker after evaluation.  Note that (unlike private
-      symbols) linker_private symbols are subject to coalescing by the linker:
-      weak symbols get merged and redefinitions are rejected.  However, unlike
-      normal strong symbols, they are removed by the linker from the final
-      linked image (executable or dynamic library).</dd>
+  <dd>Similar to <tt>private</tt>, but the symbol is passed through the
+      assembler and removed by the linker after evaluation.  Note that (unlike
+      <tt>private</tt> symbols) <tt>linker_private</tt> symbols are subject to
+      coalescing by the linker: weak symbols get merged and redefinitions are
+      rejected.  However, unlike normal strong symbols, they are removed by the
+      linker from the final linked image (executable or dynamic library).</dd>
+
+  <dt><tt><b><a name="linkage_linker_weak">linker_weak</a></b></tt></dt>
+  <dd>Global values with "<tt>linker_weak</tt>" linkage are given weak linkage,
+      but are removed by the linker after evaluation.</dd>
 
   <dt><tt><b><a name="linkage_internal">internal</a></b></tt></dt>
-  <dd>Similar to private, but the value shows as a local symbol
+  <dd>Similar to <tt>private</tt>, but the value shows as a local symbol
       (<tt>STB_LOCAL</tt> 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-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Tue Jun 29 16:24:00 2010
@@ -226,7 +226,8 @@
   LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
   LLVMGhostLinkage,       /**< Obsolete */
   LLVMCommonLinkage,      /**< Tentative definitions */
-  LLVMLinkerPrivateLinkage /**< Like Private, but linker removes. */
+  LLVMLinkerPrivateLinkage, /**< Like private, but linker removes. */
+  LLVMLinkerWeakLinkage   /**< Like linker private, but weak. */
 } LLVMLinkage;
 
 typedef enum {

Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Tue Jun 29 16:24:00 2010
@@ -285,7 +285,7 @@
     MCSymbol *GetCPISymbol(unsigned CPID) const;
 
     /// GetJTISymbol - Return the symbol for the specified jump table entry.
-    MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
+    MCSymbol *GetJTISymbol(unsigned JTID, bool PassToLinker = false) const;
 
     /// GetJTSetSymbol - Return the symbol for the specified jump table .set
     /// FIXME: privatize to AsmPrinter.

Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Tue Jun 29 16:24:00 2010
@@ -402,10 +402,10 @@
   //
   
   /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
-  /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
-  /// normal 'L' label is returned.
-  MCSymbol *getJTISymbol(unsigned JTI, MCContext &Ctx, 
-                         bool isLinkerPrivate = false) const;
+  /// If PassToLinker is specified, an 'l' label is returned, otherwise a normal
+  /// 'L' label is returned.
+  MCSymbol *getJTISymbol(unsigned JTI, MCContext &Ctx,
+                         bool PassToLinker = false) const;
 };
 
 //===--------------------------------------------------------------------===//

Modified: llvm/trunk/include/llvm/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalValue.h?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/include/llvm/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/GlobalValue.h Tue Jun 29 16:24:00 2010
@@ -39,7 +39,8 @@
     AppendingLinkage,   ///< Special purpose, only applies to global arrays
     InternalLinkage,    ///< Rename collisions when linking (static functions).
     PrivateLinkage,     ///< Like Internal, but omit from symbol table.
-    LinkerPrivateLinkage, ///< Like Private, but linker removes.
+    LinkerPrivateLinkage, ///< Like private, but linker removes.
+    LinkerWeakLinkage,  ///< Like linker private, but weak.
     DLLImportLinkage,   ///< Function to be imported from DLL
     DLLExportLinkage,   ///< Function to be accessible from DLL.
     ExternalWeakLinkage,///< ExternalWeak linkage description.
@@ -132,7 +133,10 @@
     return Linkage == PrivateLinkage;
   }
   static bool isLinkerPrivateLinkage(LinkageTypes Linkage) {
-    return Linkage==LinkerPrivateLinkage;
+    return Linkage == LinkerPrivateLinkage;
+  }
+  static bool isLinkerWeakLinkage(LinkageTypes Linkage) {
+    return Linkage == LinkerWeakLinkage;
   }
   static bool isLocalLinkage(LinkageTypes Linkage) {
     return isInternalLinkage(Linkage) || isPrivateLinkage(Linkage) ||
@@ -187,6 +191,7 @@
   bool hasInternalLinkage() const { return isInternalLinkage(Linkage); }
   bool hasPrivateLinkage() const { return isPrivateLinkage(Linkage); }
   bool hasLinkerPrivateLinkage() const { return isLinkerPrivateLinkage(Linkage); }
+  bool hasLinkerWeakLinkage() const { return isLinkerWeakLinkage(Linkage); }
   bool hasLocalLinkage() const { return isLocalLinkage(Linkage); }
   bool hasDLLImportLinkage() const { return isDLLImportLinkage(Linkage); }
   bool hasDLLExportLinkage() const { return isDLLExportLinkage(Linkage); }

Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Tue Jun 29 16:24:00 2010
@@ -85,6 +85,11 @@
     /// be passed through the assembler but be removed by the linker.  This
     /// is "l" on Darwin, currently used for some ObjC metadata.
     const char *LinkerPrivateGlobalPrefix;   // Defaults to ""
+
+    /// LinkerWeakGlobalPrefix - This prefix is used for symbols that are marked
+    /// "weak" and should be passed through the assembler, but be removed by the
+    /// linker.  This is "l" on Darwin, currently used for some ObjC metadata.
+    const char *LinkerWeakGlobalPrefix;      // Defaults to ""
     
     /// InlineAsmStart/End - If these are nonempty, they contain a directive to
     /// emit before and after an inline assembly statement.
@@ -335,6 +340,9 @@
     const char *getLinkerPrivateGlobalPrefix() const {
       return LinkerPrivateGlobalPrefix;
     }
+    const char *getLinkerWeakGlobalPrefix() const {
+      return LinkerWeakGlobalPrefix;
+    }
     const char *getInlineAsmStart() const {
       return InlineAsmStart;
     }

Modified: llvm/trunk/include/llvm/Target/Mangler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Mangler.h?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/Mangler.h (original)
+++ llvm/trunk/include/llvm/Target/Mangler.h Tue Jun 29 16:24:00 2010
@@ -32,7 +32,8 @@
   enum ManglerPrefixTy {
     Default,               ///< Emit default string before each symbol.
     Private,               ///< Emit "private" prefix before each symbol.
-    LinkerPrivate          ///< Emit "linker private" prefix before each symbol.
+    LinkerPrivate,         ///< Emit "linker private" prefix before each symbol.
+    LinkerWeak             ///< Emit "linker weak" prefix before each symbol.
   };
 
 private:

Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp Tue Jun 29 16:24:00 2010
@@ -492,6 +492,7 @@
 
   KEYWORD(private);
   KEYWORD(linker_private);
+  KEYWORD(linker_weak);
   KEYWORD(internal);
   KEYWORD(available_externally);
   KEYWORD(linkonce);

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Jun 29 16:24:00 2010
@@ -198,6 +198,7 @@
     //               OptionalAddrSpace ('constant'|'global') ...
     case lltok::kw_private :       // OptionalLinkage
     case lltok::kw_linker_private: // OptionalLinkage
+    case lltok::kw_linker_weak:    // OptionalLinkage
     case lltok::kw_internal:       // OptionalLinkage
     case lltok::kw_weak:           // OptionalLinkage
     case lltok::kw_weak_odr:       // OptionalLinkage
@@ -629,7 +630,8 @@
       Linkage != GlobalValue::WeakODRLinkage &&
       Linkage != GlobalValue::InternalLinkage &&
       Linkage != GlobalValue::PrivateLinkage &&
-      Linkage != GlobalValue::LinkerPrivateLinkage)
+      Linkage != GlobalValue::LinkerPrivateLinkage &&
+      Linkage != GlobalValue::LinkerWeakLinkage)
     return Error(LinkageLoc, "invalid linkage type for alias");
 
   Constant *Aliasee;
@@ -1013,6 +1015,7 @@
 ///   ::= /*empty*/
 ///   ::= 'private'
 ///   ::= 'linker_private'
+///   ::= 'linker_weak'
 ///   ::= 'internal'
 ///   ::= 'weak'
 ///   ::= 'weak_odr'
@@ -1030,6 +1033,7 @@
   default:                       Res=GlobalValue::ExternalLinkage; return false;
   case lltok::kw_private:        Res = GlobalValue::PrivateLinkage;       break;
   case lltok::kw_linker_private: Res = GlobalValue::LinkerPrivateLinkage; break;
+  case lltok::kw_linker_weak:    Res = GlobalValue::LinkerWeakLinkage;    break;
   case lltok::kw_internal:       Res = GlobalValue::InternalLinkage;      break;
   case lltok::kw_weak:           Res = GlobalValue::WeakAnyLinkage;       break;
   case lltok::kw_weak_odr:       Res = GlobalValue::WeakODRLinkage;       break;
@@ -2704,6 +2708,7 @@
     break;
   case GlobalValue::PrivateLinkage:
   case GlobalValue::LinkerPrivateLinkage:
+  case GlobalValue::LinkerWeakLinkage:
   case GlobalValue::InternalLinkage:
   case GlobalValue::AvailableExternallyLinkage:
   case GlobalValue::LinkOnceAnyLinkage:

Modified: llvm/trunk/lib/AsmParser/LLToken.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLToken.h (original)
+++ llvm/trunk/lib/AsmParser/LLToken.h Tue Jun 29 16:24:00 2010
@@ -37,8 +37,9 @@
     kw_declare, kw_define,
     kw_global,  kw_constant,
 
-    kw_private, kw_linker_private, kw_internal, kw_linkonce, kw_linkonce_odr,
-    kw_weak, kw_weak_odr, kw_appending, kw_dllimport, kw_dllexport, kw_common,
+    kw_private, kw_linker_private, kw_linker_weak, kw_internal, kw_linkonce,
+    kw_linkonce_odr, kw_weak, kw_weak_odr, kw_appending, kw_dllimport,
+    kw_dllexport, kw_common,
     kw_available_externally,
     kw_default, kw_hidden, kw_protected,
     kw_extern_weak,

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jun 29 16:24:00 2010
@@ -75,6 +75,7 @@
   case 11: return GlobalValue::LinkOnceODRLinkage;
   case 12: return GlobalValue::AvailableExternallyLinkage;
   case 13: return GlobalValue::LinkerPrivateLinkage;
+  case 14: return GlobalValue::LinkerWeakLinkage;
   }
 }
 

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Jun 29 16:24:00 2010
@@ -313,6 +313,7 @@
   case GlobalValue::LinkOnceODRLinkage:         return 11;
   case GlobalValue::AvailableExternallyLinkage: return 12;
   case GlobalValue::LinkerPrivateLinkage:       return 13;
+  case GlobalValue::LinkerWeakLinkage:          return 14;
   }
 }
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Jun 29 16:24:00 2010
@@ -199,6 +199,7 @@
   case GlobalValue::LinkOnceODRLinkage:
   case GlobalValue::WeakAnyLinkage:
   case GlobalValue::WeakODRLinkage:
+  case GlobalValue::LinkerWeakLinkage:
   case GlobalValue::LinkerPrivateLinkage:
     if (MAI->getWeakDefDirective() != 0) {
       // .globl _foo
@@ -1610,8 +1611,8 @@
 }
 
 /// GetJTISymbol - Return the symbol for the specified jump table entry.
-MCSymbol *AsmPrinter::GetJTISymbol(unsigned JTID, bool isLinkerPrivate) const {
-  return MF->getJTISymbol(JTID, OutContext, isLinkerPrivate);
+MCSymbol *AsmPrinter::GetJTISymbol(unsigned JTID, bool PassToLinker) const {
+  return MF->getJTISymbol(JTID, OutContext, PassToLinker);
 }
 
 /// GetJTSetSymbol - Return the symbol for the specified jump table .set

Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Tue Jun 29 16:24:00 2010
@@ -410,17 +410,18 @@
 }
 
 /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
-/// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
-/// normal 'L' label is returned.
-MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx, 
-                                        bool isLinkerPrivate) const {
+/// If isLinkerPrivate or isLinkerWeak is specified, an 'l' label is returned,
+/// otherwise a normal 'L' label is returned.
+MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
+                                        bool PassToLinker) const {
   assert(JumpTableInfo && "No jump tables");
   
   assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
   const MCAsmInfo &MAI = *getTarget().getMCAsmInfo();
   
-  const char *Prefix = isLinkerPrivate ? MAI.getLinkerPrivateGlobalPrefix() :
-                                         MAI.getPrivateGlobalPrefix();
+  const char *Prefix = PassToLinker ?
+    MAI.getLinkerPrivateGlobalPrefix() :
+    MAI.getPrivateGlobalPrefix();
   SmallString<60> Name;
   raw_svector_ostream(Name)
     << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;

Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Tue Jun 29 16:24:00 2010
@@ -755,11 +755,12 @@
   /// the directive emitted (this occurs in ObjC metadata).
   if (!GV) return false;
 
-  // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix.
+  // Check whether the mangled name has the "Private", "LinkerPrivate", or
+  // "LinkerWeak" prefix.
   if (GV->hasLocalLinkage() && !isa<Function>(GV)) {
     // FIXME: ObjC metadata is currently emitted as internal symbols that have
-    // \1L and \0l prefixes on them.  Fix them to be Private/LinkerPrivate and
-    // this horrible hack can go away.
+    // \1L and \1l prefixes on them.  Fix them to be Private / LinkerPrivate /
+    // LinkerWeak and this horrible hack can go away.
     MCSymbol *Sym = Mang->getSymbol(GV);
     if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l')
       return false;

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Jun 29 16:24:00 2010
@@ -735,6 +735,9 @@
   else if (SL == GlobalValue::LinkerPrivateLinkage &&
            DL == GlobalValue::LinkerPrivateLinkage)
     return GlobalValue::LinkerPrivateLinkage;
+  else if (SL == GlobalValue::LinkerWeakLinkage &&
+           DL == GlobalValue::LinkerWeakLinkage)
+    return GlobalValue::LinkerWeakLinkage;
   else {
     assert (SL == GlobalValue::PrivateLinkage &&
             DL == GlobalValue::PrivateLinkage && "Unexpected linkage type");

Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfo.cpp Tue Jun 29 16:24:00 2010
@@ -31,6 +31,7 @@
   GlobalPrefix = "";
   PrivateGlobalPrefix = ".";
   LinkerPrivateGlobalPrefix = "";
+  LinkerWeakGlobalPrefix = "";
   InlineAsmStart = "APP";
   InlineAsmEnd = "NO_APP";
   AssemblerDialect = 0;

Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Tue Jun 29 16:24:00 2010
@@ -21,6 +21,7 @@
   GlobalPrefix = "_";
   PrivateGlobalPrefix = "L";
   LinkerPrivateGlobalPrefix = "l";
+  LinkerWeakGlobalPrefix = "l";
   AllowQuotesInName = true;
   HasSingleParameterDotFile = false;
   HasSubsectionsViaSymbols = true;

Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original)
+++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Tue Jun 29 16:24:00 2010
@@ -286,6 +286,8 @@
     Out << "GlobalValue::PrivateLinkage"; break;
   case GlobalValue::LinkerPrivateLinkage:
     Out << "GlobalValue::LinkerPrivateLinkage"; break;
+  case GlobalValue::LinkerWeakLinkage:
+    Out << "GlobalValue::LinkerWeakLinkage"; break;
   case GlobalValue::AvailableExternallyLinkage:
     Out << "GlobalValue::AvailableExternallyLinkage "; break;
   case GlobalValue::LinkOnceAnyLinkage:

Modified: llvm/trunk/lib/Target/Mangler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mangler.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mangler.cpp (original)
+++ llvm/trunk/lib/Target/Mangler.cpp Tue Jun 29 16:24:00 2010
@@ -118,6 +118,9 @@
     } else if (PrefixTy == Mangler::LinkerPrivate) {
       const char *Prefix = MAI.getLinkerPrivateGlobalPrefix();
       OutName.append(Prefix, Prefix+strlen(Prefix));
+    } else if (PrefixTy == Mangler::LinkerWeak) {
+      const char *Prefix = MAI.getLinkerWeakGlobalPrefix();
+      OutName.append(Prefix, Prefix+strlen(Prefix));
     }
 
     const char *Prefix = MAI.getGlobalPrefix();
@@ -182,6 +185,8 @@
     PrefixTy = Mangler::Private;
   else if (GV->hasLinkerPrivateLinkage())
     PrefixTy = Mangler::LinkerPrivate;
+  else if (GV->hasLinkerWeakLinkage())
+    PrefixTy = Mangler::LinkerWeak;
   
   // If this global has a name, handle it simply.
   if (GV->hasName()) {

Modified: llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp Tue Jun 29 16:24:00 2010
@@ -129,6 +129,7 @@
   case GlobalValue::WeakAnyLinkage:
   case GlobalValue::WeakODRLinkage:
   case GlobalValue::ExternalLinkage:
+  case GlobalValue::LinkerWeakLinkage:
     emitArrayBound(GVSym, GV);
     OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);
 

Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Tue Jun 29 16:24:00 2010
@@ -535,6 +535,7 @@
   case GlobalValue::WeakAnyLinkage:
   case GlobalValue::WeakODRLinkage:
   case GlobalValue::ExternalWeakLinkage:
+  case GlobalValue::LinkerWeakLinkage:
     return ExternalWeak;
 
   case GlobalValue::ExternalLinkage:

Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Jun 29 16:24:00 2010
@@ -1419,6 +1419,7 @@
   case GlobalValue::ExternalLinkage: break;
   case GlobalValue::PrivateLinkage:       Out << "private ";        break;
   case GlobalValue::LinkerPrivateLinkage: Out << "linker_private "; break;
+  case GlobalValue::LinkerWeakLinkage:    Out << "linker_weak ";    break;
   case GlobalValue::InternalLinkage:      Out << "internal ";       break;
   case GlobalValue::LinkOnceAnyLinkage:   Out << "linkonce ";       break;
   case GlobalValue::LinkOnceODRLinkage:   Out << "linkonce_odr ";   break;

Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Tue Jun 29 16:24:00 2010
@@ -1058,6 +1058,8 @@
     return LLVMPrivateLinkage;
   case GlobalValue::LinkerPrivateLinkage:
     return LLVMLinkerPrivateLinkage;
+  case GlobalValue::LinkerWeakLinkage:
+    return LLVMLinkerWeakLinkage;
   case GlobalValue::DLLImportLinkage:
     return LLVMDLLImportLinkage;
   case GlobalValue::DLLExportLinkage:
@@ -1108,6 +1110,9 @@
   case LLVMLinkerPrivateLinkage:
     GV->setLinkage(GlobalValue::LinkerPrivateLinkage);
     break;
+  case LLVMLinkerWeakLinkage:
+    GV->setLinkage(GlobalValue::LinkerWeakLinkage);
+    break;
   case LLVMDLLImportLinkage:
     GV->setLinkage(GlobalValue::DLLImportLinkage);
     break;

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=107205&r1=107204&r2=107205&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Tue Jun 29 16:24:00 2010
@@ -89,7 +89,8 @@
 static void DumpSymbolNameForGlobalValue(GlobalValue &GV) {
   // Private linkage and available_externally linkage don't exist in symtab.
   if (GV.hasPrivateLinkage() || GV.hasLinkerPrivateLinkage() ||
-      GV.hasAvailableExternallyLinkage()) return;
+      GV.hasLinkerWeakLinkage() || GV.hasAvailableExternallyLinkage())
+    return;
   
   const std::string SymbolAddrStr = "        "; // Not used yet...
   char TypeChar = TypeCharForSymbol(GV);





More information about the llvm-commits mailing list