From 5b585f8b1a6f5c2531333d533c263746a648e81c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 19 Jan 2010 02:48:26 +0000 Subject: introduce a section kind for common linkage. Use this to slightly simplify and commonize some of the asmprinter logic for globals. This also avoids printing the MCSection for .zerofill, which broke the llvm-gcc build. llvm-svn: 93843 --- llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp') diff --git a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 2ba940bb492..9016f5c1124 100644 --- a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -1197,10 +1197,27 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { O << "\t.type " << *GVarSym << ",%object\n"; SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GVar, TM); + + // Handle normal common symbols. + if (GVKind.isCommon()) { + if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. + + O << ".comm " << *GVarSym << ',' << Size; + if (MAI->getCOMMDirectiveTakesAlignment()) + O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align); + + if (VerboseAsm) { + O << "\t\t" << MAI->getCommentString() << " '"; + WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent()); + O << '\''; + } + O << '\n'; + return; + } + const MCSection *TheSection = getObjFileLowering().SectionForGlobal(GVar, GVKind, Mang, TM); - OutStreamer.SwitchSection(TheSection); - + // Handle the zerofill directive on darwin, which is a special form of BSS // emission. if (GVKind.isBSS() && MAI->hasMachoZeroFillDirective()) { @@ -1215,6 +1232,8 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { } } + OutStreamer.SwitchSection(TheSection); + // FIXME: get this stuff from section kind flags. if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() && // Don't put things that should go in the cstring section into "comm". -- cgit v1.2.3