Honor user-defined section specification of a global, ignores whether its initializer...
authorEvan Cheng <evan.cheng@apple.com>
Fri, 21 Sep 2007 00:41:19 +0000 (00:41 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 21 Sep 2007 00:41:19 +0000 (00:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42182 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMAsmPrinter.cpp
lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.cpp

index f637dec9d9a6bc8e6237a617ff371f9757e98b87..342e52a1b2b68a286a731c84954eeb930802600a 100644 (file)
@@ -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);
index 9e5f1032bafd13dc1cfbe52fc9ae4ec5759e6b98..b561c043da72a8454aaccfe8df01a48de95f23f1 100644 (file)
@@ -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';
index 85840495beda41cd7668873bd0f4430bed1a83a6..c4d5958bfcaef76c0d2649383ed8f593340f3de5 100644 (file)
@@ -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.