mcstreamer'ize the rest of EmitGlobalVariable that is used on
authorChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 06:41:24 +0000 (06:41 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 06:41:24 +0000 (06:41 +0000)
darwin.  The next big piece to get global variables streamerized
is EmitGlobalConstant.

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

lib/CodeGen/AsmPrinter/AsmPrinter.cpp

index fbbcc27a580a9f61e1810fac16fdfa86afa6b488..9da8a29ffed6831e9dd226aa561ccc5ed8739159 100644 (file)
@@ -226,18 +226,20 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
   case GlobalValue::WeakAnyLinkage:
   case GlobalValue::WeakODRLinkage:
   case GlobalValue::LinkerPrivateLinkage:
-    if (const char *WeakDef = MAI->getWeakDefDirective()) {
+    if (MAI->getWeakDefDirective() != 0) {
       // .globl _foo
       OutStreamer.EmitSymbolAttribute(GVSym, MCStreamer::Global);
       // .weak_definition _foo
-      O << WeakDef << *GVSym << '\n';
+      OutStreamer.EmitSymbolAttribute(GVSym, MCStreamer::WeakDefinition);
     } else if (const char *LinkOnce = MAI->getLinkOnceDirective()) {
       // .globl _foo
       OutStreamer.EmitSymbolAttribute(GVSym, MCStreamer::Global);
       // .linkonce same_size
       O << LinkOnce;
-    } else
-      O << "\t.weak\t" << *GVSym << '\n';
+    } else {
+      // .weak _foo
+      OutStreamer.EmitSymbolAttribute(GVSym, MCStreamer::Weak);
+    }
     break;
   case GlobalValue::DLLExportLinkage:
   case GlobalValue::AppendingLinkage:
@@ -256,13 +258,13 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
   }
 
   EmitAlignment(AlignLog, GV);
-  O << *GVSym << ":";
   if (VerboseAsm) {
     O.PadToColumn(MAI->getCommentColumn());
     O << MAI->getCommentString() << ' ';
     WriteAsOperand(O, GV, /*PrintType=*/false, GV->getParent());
+    O << '\n';
   }
-  O << '\n';
+  OutStreamer.EmitLabel(GVSym);
 
   EmitGlobalConstant(GV->getInitializer());