[llvm-commits] [llvm] r93855 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoCOFF.cpp lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp

Chris Lattner sabre at nondot.org
Mon Jan 18 21:08:14 PST 2010


Author: lattner
Date: Mon Jan 18 23:08:13 2010
New Revision: 93855

URL: http://llvm.org/viewvc/llvm-project?rev=93855&view=rev
Log:
hookize the cygwin ".linkonce" directive.

Modified:
    llvm/trunk/include/llvm/MC/MCAsmInfo.h
    llvm/trunk/lib/MC/MCAsmInfo.cpp
    llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp

Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=93855&r1=93854&r2=93855&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Mon Jan 18 23:08:13 2010
@@ -226,6 +226,10 @@
     /// WeakDefDirective - This directive, if non-null, is used to declare a
     /// global as being a weak defined symbol.
     const char *WeakDefDirective;            // Defaults to NULL.
+
+    /// LinkOnceDirective - This directive, if non-null is used to declare a
+    /// global as being a weak defined symbol.  This is used on cygwin/mingw.
+    const char *LinkOnceDirective;           // Defaults to NULL.
     
     /// HiddenDirective - This directive, if non-null, is used to declare a
     /// global or function as having hidden visibility.
@@ -426,12 +430,9 @@
     const char *getUsedDirective() const {
       return UsedDirective;
     }
-    const char *getWeakRefDirective() const {
-      return WeakRefDirective;
-    }
-    const char *getWeakDefDirective() const {
-      return WeakDefDirective;
-    }
+    const char *getWeakRefDirective() const { return WeakRefDirective; }
+    const char *getWeakDefDirective() const { return WeakDefDirective; }
+    const char *getLinkOnceDirective() const { return LinkOnceDirective; }
     const char *getHiddenDirective() const {
       return HiddenDirective;
     }

Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=93855&r1=93854&r2=93855&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfo.cpp Mon Jan 18 23:08:13 2010
@@ -62,6 +62,7 @@
   UsedDirective = 0;
   WeakRefDirective = 0;
   WeakDefDirective = 0;
+  LinkOnceDirective = 0;
   // FIXME: These are ELFish - move to ELFMAI.
   HiddenDirective = "\t.hidden\t";
   ProtectedDirective = "\t.protected\t";

Modified: llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp?rev=93855&r1=93854&r2=93855&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp Mon Jan 18 23:08:13 2010
@@ -25,6 +25,7 @@
   HiddenDirective = NULL;
   PrivateGlobalPrefix = "L";  // Prefix for private global symbols
   WeakRefDirective = "\t.weak\t";
+  LinkOnceDirective = "\t.linkonce same_size\n";
   SetDirective = "\t.set\t";
 
   // Set up DWARF directives

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

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Mon Jan 18 23:08:13 2010
@@ -727,12 +727,16 @@
   case GlobalValue::WeakAnyLinkage:
   case GlobalValue::WeakODRLinkage:
   case GlobalValue::LinkerPrivateLinkage:
-    if (Subtarget->isTargetDarwin()) {
+    if (const char *WeakDef = MAI->getWeakDefDirective()) {
+      // .globl _foo
       OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
-      O << MAI->getWeakDefDirective() << *GVarSym << '\n';
-    } else if (Subtarget->isTargetCygMing()) {
+      // .weak_definition _foo
+      O << WeakDef << *GVarSym << '\n';
+    } else if (const char *LinkOnce = MAI->getLinkOnceDirective()) {
+      // .globl _foo
       OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
-      O << "\t.linkonce same_size\n";
+      // .linkonce same_size
+      O << LinkOnce;
     } else
       O << "\t.weak\t" << *GVarSym << '\n';
     break;
@@ -741,7 +745,8 @@
     // FIXME: appending linkage variables should go into a section of
     // their name or something.  For now, just emit them as external.
   case GlobalValue::ExternalLinkage:
-    // If external or appending, declare as a global symbol
+    // If external or appending, declare as a global symbol.
+    // .globl _foo
     OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
     break;
   case GlobalValue::PrivateLinkage:
@@ -753,7 +758,7 @@
 
   EmitAlignment(AlignLog, GVar);
   O << *GVarSym << ":";
-  if (VerboseAsm){
+  if (VerboseAsm) {
     O.PadToColumn(MAI->getCommentColumn());
     O << MAI->getCommentString() << ' ';
     WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());





More information about the llvm-commits mailing list