diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h index 393be617f42..cd0fcf8ad81 100644 --- a/include/llvm/Target/TargetAsmInfo.h +++ b/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/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index e863043de55..d69ca325def 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/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/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index 9c0aa74a34e..1ac3e32e568 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/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/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 334172a90d7..6e44b9b87f3 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/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';