From 1553fdee5583e0661271cb6738848a252237f21b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 24 Jul 2009 04:08:17 +0000 Subject: [PATCH] use section flags more correctly. llvm-svn: 76944 --- llvm/include/llvm/Target/TargetAsmInfo.h | 2 ++ llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 5 ++--- llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 3 ++- llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 5 ++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/Target/TargetAsmInfo.h b/llvm/include/llvm/Target/TargetAsmInfo.h index 393be617f42f..cd0fcf8ad811 100644 --- a/llvm/include/llvm/Target/TargetAsmInfo.h +++ b/llvm/include/llvm/Target/TargetAsmInfo.h @@ -123,6 +123,8 @@ namespace llvm { const std::string& getName() const { return Name; } unsigned getFlags() const { return Flags; } + + bool hasFlag(unsigned F) const { return (Flags & F) != 0; } }; /// TargetAsmInfo - This class is intended to be used as a base class for asm diff --git a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index e863043de554..d69ca325defb 100644 --- a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -1103,9 +1103,8 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { SwitchToSection(TheSection); if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() && - !(isDarwin && TheSection->getFlags() == SectionKind::RODataMergeStr)) { - // FIXME: This seems to be pretty darwin-specific - + // Don't put things that should go in the cstring section into "comm". + !TheSection->hasFlag(SectionFlags::Strings)) { if (GVar->hasExternalLinkage()) { if (const char *Directive = TAI->getZeroFillDirective()) { O << "\t.globl\t" << name << "\n"; diff --git a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index 9c0aa74a34e6..1ac3e32e568b 100644 --- a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -897,7 +897,8 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { !GVar->hasSection() && (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() || GVar->isWeakForLinker()) && - TheSection->getFlags() != SectionKind::RODataMergeStr) { + // Don't put things that should go in the cstring section into "comm". + !TheSection->hasFlag(SectionFlags::Strings)) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (GVar->hasExternalLinkage()) { diff --git a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 334172a90d7b..6e44b9b87f3a 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -798,9 +798,8 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { SwitchToSection(TheSection); if (C->isNullValue() && !GVar->hasSection() && - !(Subtarget->isTargetDarwin() && - TAI->SectionKindForGlobal(GVar) == SectionKind::RODataMergeStr)) { - // FIXME: This seems to be pretty darwin-specific + // Don't put things that should go in the cstring section into "comm". + !TheSection->hasFlag(SectionFlags::Strings)) { if (GVar->hasExternalLinkage()) { if (const char *Directive = TAI->getZeroFillDirective()) { O << "\t.globl " << name << '\n';