make TLOF subclassify BSS based on linkage type into private, external
authorChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 04:15:51 +0000 (04:15 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 04:15:51 +0000 (04:15 +0000)
and everything else (weak).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93846 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/SectionKind.h
lib/Target/TargetLoweringObjectFile.cpp

index f125d1578f2278cdee5278e55020353c464739db..c9557f29c9a5c79254c4607c4178eac7982f3deb 100644 (file)
@@ -88,6 +88,13 @@ class SectionKind {
            /// BSS - Zero initialized writeable data.
            BSS,
     
+               /// BSSLocal - This is BSS (zero initialized and writable) data
+               /// which has local linkage.
+               BSSLocal,
+    
+               /// BSSExtern - This is BSS data with normal external linkage.
+               BSSExtern,
+    
            /// Common - Data with common linkage.  These represent tentative
            /// definitions, which always have a zero initializer and are never
            /// marked 'constant'.
@@ -166,7 +173,10 @@ public:
     return isBSS() || isCommon() || isDataRel() || isReadOnlyWithRel();
   }
   
-  bool isBSS() const { return K == BSS; }
+  bool isBSS() const { return K == BSS || K == BSSLocal || K == BSSExtern; }
+  bool isBSSLocal() const { return K == BSSLocal; }
+  bool isBSSExtern() const { return K == BSSExtern; }
+  
   bool isCommon() const { return K == Common; }
   
   bool isDataRel() const {
@@ -213,6 +223,8 @@ public:
   static SectionKind getThreadBSS() { return get(ThreadBSS); }
   static SectionKind getThreadData() { return get(ThreadData); }
   static SectionKind getBSS() { return get(BSS); }
+  static SectionKind getBSSLocal() { return get(BSSLocal); }
+  static SectionKind getBSSExtern() { return get(BSSExtern); }
   static SectionKind getCommon() { return get(Common); }
   static SectionKind getDataRel() { return get(DataRel); }
   static SectionKind getDataRelLocal() { return get(DataRelLocal); }
index 7b00b332f63679a147402a6c6b15f2e068027f45..77203e08382434b8db2260e6141715c2ba62b97a 100644 (file)
@@ -146,8 +146,13 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
     return SectionKind::getCommon();
 
   // Variable can be easily put to BSS section.
-  if (isSuitableForBSS(GVar))
+  if (isSuitableForBSS(GVar)) {
+    if (GVar->hasLocalLinkage())
+      return SectionKind::getBSSLocal();
+    else if (GVar->hasExternalLinkage())
+      return SectionKind::getBSSExtern();
     return SectionKind::getBSS();
+  }
 
   Constant *C = GVar->getInitializer();
 
@@ -926,7 +931,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
 
   // Put zero initialized globals with strong external linkage in the
   // DATA, __common section with the .zerofill directive.
-  if (Kind.isBSS() && GV->hasExternalLinkage())
+  if (Kind.isBSSExtern())
     return DataCommonSection;
   
   // Otherwise, just drop the variable in the normal data section.