now that elf weak bss symbols are handled correctly, simplify a bunch of code.
authorChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 03:13:44 +0000 (03:13 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 03:13:44 +0000 (03:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93845 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp

index 9016f5c1124675abad996e4721885cc9edfc9409..738f257833f2c8e696ce0f0dbe50a095bdda8ba4 100644 (file)
@@ -1238,39 +1238,14 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
   if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() &&
       // Don't put things that should go in the cstring section into "comm".
       !TheSection->getKind().isMergeableCString() &&
-      (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
+      (GVar->hasLocalLinkage() || GVar->hasLocalLinkage())) {
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
     if (isDarwin) {
-      if (GVar->hasLocalLinkage()) {
-        O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size
-          << ',' << Align;
-      } else if (GVar->hasCommonLinkage()) {
-        O << MAI->getCOMMDirective() << *GVarSym << ',' << Size
-          << ',' << Align;
-      } else {
-        OutStreamer.SwitchSection(TheSection);
-        O << "\t.globl " << *GVarSym << '\n' << MAI->getWeakDefDirective();
-        O << *GVarSym << '\n';
-        EmitAlignment(Align, GVar);
-        O << *GVarSym << ":";
-        if (VerboseAsm) {
-          O.PadToColumn(MAI->getCommentColumn());
-          O << MAI->getCommentString() << ' ';
-          WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
-        }
-        O << '\n';
-        EmitGlobalConstant(C);
-        return;
-      }
+      O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size
+        << ',' << Align;
     } else if (MAI->getLCOMMDirective() != NULL) {
-      if (GVar->hasLocalLinkage()) {
-        O << MAI->getLCOMMDirective() << *GVarSym << "," << Size;
-      } else {
-        O << MAI->getCOMMDirective() << *GVarSym << "," << Size;
-        if (MAI->getCOMMDirectiveTakesAlignment())
-          O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
-      }
+      O << MAI->getLCOMMDirective() << *GVarSym << "," << Size;
     } else {
       if (GVar->hasLocalLinkage())
         O << "\t.local\t" << *GVarSym << '\n';
index 5e1942812630a67808050f75c9174b517896e270..4b69f0bb7cfa35a6fc1c0dfe91ba4dc84fd9ff9d 100644 (file)
@@ -736,22 +736,11 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
   OutStreamer.SwitchSection(getObjFileLowering().
                             SectionForGlobal(GVar, GVKind, Mang, TM));
 
-  if (C->isNullValue() && /* FIXME: Verify correct */
-      !GVar->hasSection() &&
-      (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
-       GVar->isWeakForLinker())) {
+  if (C->isNullValue() && !GVar->hasSection() && GVar->hasLocalLinkage()) {
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
-    if (GVar->hasExternalLinkage()) {
-      O << "\t.global " << *GVarSym << '\n';
-      O << "\t.type " << *GVarSym << ", @object\n";
-      O << *GVarSym << ":\n";
-      O << "\t.zero " << Size << '\n';
-    } else if (GVar->hasLocalLinkage()) {
-      O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size;
-    } else {
-      O << ".comm " << *GVarSym << ',' << Size;
-    }
+    O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size;
+        
     if (VerboseAsm) {
       O << "\t\t" << MAI->getCommentString() << " '";
       WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
@@ -1003,34 +992,19 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
 
   /// FIXME: Drive this off the section!
   if (C->isNullValue() && /* FIXME: Verify correct */
-      !GVar->hasSection() &&
-      (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
-       GVar->isWeakForLinker()) &&
+      !GVar->hasSection() && GVar->hasLocalLinkage() &&
       // Don't put things that should go in the cstring section into "comm".
       !TheSection->getKind().isMergeableCString()) {
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
-    if (GVar->hasLocalLinkage()) {
-      O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align;
-      
-      if (VerboseAsm) {
-        O << "\t\t" << MAI->getCommentString() << " '";
-        WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
-        O << "'";
-      }
-      O << '\n';
-    } else {
-      O << "\t.globl " << *GVarSym << '\n' << MAI->getWeakDefDirective();
-      O << *GVarSym << '\n';
-      EmitAlignment(Align, GVar);
-      O << *GVarSym << ":";
-      if (VerboseAsm) {
-        O << "\t\t\t\t" << MAI->getCommentString() << " ";
-        WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
-      }
-      O << '\n';
-      EmitGlobalConstant(C);
+    O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align;
+    
+    if (VerboseAsm) {
+      O << "\t\t" << MAI->getCommentString() << " '";
+      WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
+      O << "'";
     }
+    O << '\n';
     return;
   }
 
index 82577cfa194ec80301f43fdd50604acb7afb1689..f32a659f72784101c272ed5f3724a45856a200a6 100644 (file)
@@ -717,8 +717,7 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
   if (C->isNullValue() && !GVar->hasSection() &&
       // Don't put things that should go in the cstring section into "comm".
       !TheSection->getKind().isMergeableCString() &&
-      !GVar->isThreadLocal() &&
-      (GVar->hasLocalLinkage())) {
+      !GVar->isThreadLocal() && GVar->hasLocalLinkage()) {
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
     if (const char *LComm = MAI->getLCOMMDirective()) {
@@ -726,29 +725,10 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
         O << LComm << *GVarSym << ',' << Size;
         if (Subtarget->isTargetDarwin())
           O << ',' << Align;
-      } else if (Subtarget->isTargetDarwin()) {
-        OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
-        O << MAI->getWeakDefDirective() << *GVarSym << '\n';
-        EmitAlignment(Align, GVar);
-        O << *GVarSym << ":";
-        if (VerboseAsm) {
-          O.PadToColumn(MAI->getCommentColumn());
-          O << MAI->getCommentString() << ' ';
-          WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
-        }
-        O << '\n';
-        EmitGlobalConstant(C);
-        return;
-      } else {
-        O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
-        if (MAI->getCOMMDirectiveTakesAlignment())
-          O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
       }
     } else {
-      if (!Subtarget->isTargetCygMing()) {
-        if (GVar->hasLocalLinkage())
-          O << "\t.local\t" << *GVarSym << '\n';
-      }
+      if (!Subtarget->isTargetCygMing())
+        O << "\t.local\t" << *GVarSym << '\n';
       O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
       if (MAI->getCOMMDirectiveTakesAlignment())
         O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);