From d675ed54009e515876feedde33d7bb560e9f85db Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 21 Sep 2007 00:41:19 +0000 Subject: [PATCH] Honor user-defined section specification of a global, ignores whether its initializer is null. llvm-svn: 42182 --- lib/Target/ARM/ARMAsmPrinter.cpp | 7 +++---- lib/Target/PowerPC/PPCAsmPrinter.cpp | 4 ++-- lib/Target/X86/X86AsmPrinter.cpp | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index f637dec9d9a..342e52a1b2b 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -835,7 +835,7 @@ bool ARMAsmPrinter::doFinalization(Module &M) { if (Subtarget->isTargetELF()) O << "\t.type " << name << ",%object\n"; - if (C->isNullValue()) { + if (C->isNullValue() && !I->hasSection()) { if (I->hasExternalLinkage()) { if (const char *Directive = TAI->getZeroFillDirective()) { O << "\t.globl\t" << name << "\n"; @@ -845,9 +845,8 @@ bool ARMAsmPrinter::doFinalization(Module &M) { } } - if (!I->hasSection() && - (I->hasInternalLinkage() || I->hasWeakLinkage() || - I->hasLinkOnceLinkage())) { + if (I->hasInternalLinkage() || I->hasWeakLinkage() || + I->hasLinkOnceLinkage()) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (!NoZerosInBSS && TAI->getBSSSection()) SwitchToDataSection(TAI->getBSSSection(), I); diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index 9e5f1032baf..b561c043da7 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -661,9 +661,9 @@ bool LinuxAsmPrinter::doFinalization(Module &M) { unsigned Align = TD->getPreferredAlignmentLog(I); if (C->isNullValue() && /* FIXME: Verify correct */ + !I->hasSection() && (I->hasInternalLinkage() || I->hasWeakLinkage() || - I->hasLinkOnceLinkage() || - (I->hasExternalLinkage() && !I->hasSection()))) { + I->hasLinkOnceLinkage() || I->hasExternalLinkage())) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (I->hasExternalLinkage()) { O << "\t.global " << name << '\n'; diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 85840495bed..c4d5958bfca 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -170,7 +170,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { if (Subtarget->isTargetELF()) O << "\t.type\t" << name << ",@object\n"; - if (C->isNullValue()) { + if (C->isNullValue() && !I->hasSection()) { if (I->hasExternalLinkage()) { if (const char *Directive = TAI->getZeroFillDirective()) { O << "\t.globl\t" << name << "\n"; @@ -180,7 +180,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { } } - if (!I->hasSection() && !I->isThreadLocal() && + if (!I->isThreadLocal() && (I->hasInternalLinkage() || I->hasWeakLinkage() || I->hasLinkOnceLinkage())) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.