From 8a6d7ac88f8b0f37c8c1f134efb39a0725394719 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 19 Jan 2010 18:58:52 +0000 Subject: [PATCH] mcstreamerize AsmPrinter::EmitZeros, at least when emitting to the default address space. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93890 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 14 ++++++-------- lib/MC/MCAsmStreamer.cpp | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index c22e501f53f..48add10b352 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -436,7 +436,7 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) { // Emit inter-object padding for alignment. unsigned AlignMask = CPE.getAlignment() - 1; unsigned NewOffset = (Offset + AlignMask) & ~AlignMask; - EmitZeros(NewOffset - Offset); + OutStreamer.EmitFill(NewOffset - Offset); const Type *Ty = CPE.getType(); Offset = NewOffset + TM.getTargetData()->getTypeAllocSize(Ty); @@ -917,8 +917,8 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV, /// void AsmPrinter::EmitZeros(uint64_t NumZeros, unsigned AddrSpace) const { if (NumZeros == 0) return; - if (MAI->getZeroDirective()) { - O << MAI->getZeroDirective() << NumZeros << '\n'; + if (MAI->getZeroDirective() || AddrSpace == 0) { + OutStreamer.EmitFill(NumZeros); } else { for (; NumZeros; --NumZeros) O << MAI->getData8bitsDirective(AddrSpace) << "0\n"; @@ -1417,13 +1417,11 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, unsigned AddrSpace) { const Type *type = CV->getType(); unsigned Size = TD->getTypeAllocSize(type); - if (CV->isNullValue() || isa(CV)) { - EmitZeros(Size, AddrSpace); - return; - } + if (CV->isNullValue() || isa(CV)) + return EmitZeros(Size, AddrSpace); if (const ConstantArray *CVA = dyn_cast(CV)) { - EmitGlobalConstantArray(CVA , AddrSpace); + EmitGlobalConstantArray(CVA, AddrSpace); return; } diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 317e74d5b32..1fd048ef667 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -203,6 +203,8 @@ void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size) { /// EmitFill - Emit NumBytes bytes worth of the value specified by /// FillValue. This implements directives such as '.space'. void MCAsmStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) { + if (NumBytes == 0) return; + if (const char *ZeroDirective = MAI.getZeroDirective()) { OS << ZeroDirective << NumBytes; if (FillValue != 0)