From 2d23c9f1ab18027b700e4b8e89c0a6f4a7833573 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 15 Feb 2006 01:56:23 +0000 Subject: [PATCH] Use .zerofill on x86/darwin. llvm-svn: 26196 --- llvm/lib/Target/X86/X86AsmPrinter.cpp | 37 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp index 7de9ef2b5ff3..5a43f867fd56 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -96,24 +96,31 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { if (C->isNullValue() && /* FIXME: Verify correct */ (I->hasInternalLinkage() || I->hasWeakLinkage() || - I->hasLinkOnceLinkage())) { + I->hasLinkOnceLinkage() || + (forDarwin && I->hasExternalLinkage() && !I->hasSection()))) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - SwitchSection(".data", I); - if (LCOMMDirective != NULL) { - if (I->hasInternalLinkage()) { - O << LCOMMDirective << name << "," << Size; - if (forDarwin) - O << "," << (AlignmentIsInBytes ? (1 << Align) : Align); - } else - O << COMMDirective << name << "," << Size; + if (I->hasExternalLinkage()) { + O << "\t.global\t" << name << "\n"; + O << "\t.zerofill __DATA__, __common, " << name << ", " + << Size << ", " << Align; } else { - if (I->hasInternalLinkage()) - O <<"\t.local\t" << name << "\n"; - O << COMMDirective << name << "," << Size; - if (COMMDirectiveTakesAlignment) - O << "," << (AlignmentIsInBytes ? (1 << Align) : Align); + SwitchSection(".data", I); + if (LCOMMDirective != NULL) { + if (I->hasInternalLinkage()) { + O << LCOMMDirective << name << "," << Size; + if (forDarwin) + O << "," << (AlignmentIsInBytes ? (1 << Align) : Align); + } else + O << COMMDirective << name << "," << Size; + } else { + if (I->hasInternalLinkage()) + O << "\t.local\t" << name << "\n"; + O << COMMDirective << name << "," << Size; + if (COMMDirectiveTakesAlignment) + O << "," << (AlignmentIsInBytes ? (1 << Align) : Align); + } + O << "\t\t" << CommentString << " " << I->getName() << "\n"; } - O << "\t\t" << CommentString << " " << I->getName() << "\n"; } else { switch (I->getLinkage()) { case GlobalValue::LinkOnceLinkage: