From 56b1319fbe18e886f7cff415b45df404fac39623 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 19 Jan 2010 03:13:44 +0000 Subject: [PATCH] now that elf weak bss symbols are handled correctly, simplify a bunch of code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93845 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 33 +++-------------- lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 48 ++++++------------------- lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp | 26 ++------------ 3 files changed, 18 insertions(+), 89 deletions(-) diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 9016f5c1124..738f257833f 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -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'; diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index 5e194281263..4b69f0bb7cf 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -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; } diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp index 82577cfa194..f32a659f727 100644 --- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp @@ -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); -- 2.11.0