[llvm-commits] [llvm] r93846 - in /llvm/trunk: include/llvm/MC/SectionKind.h lib/Target/TargetLoweringObjectFile.cpp

Chris Lattner sabre at nondot.org
Mon Jan 18 20:15:52 PST 2010


Author: lattner
Date: Mon Jan 18 22:15:51 2010
New Revision: 93846

URL: http://llvm.org/viewvc/llvm-project?rev=93846&view=rev
Log:
make TLOF subclassify BSS based on linkage type into private, external
and everything else (weak).

Modified:
    llvm/trunk/include/llvm/MC/SectionKind.h
    llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp

Modified: llvm/trunk/include/llvm/MC/SectionKind.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/SectionKind.h?rev=93846&r1=93845&r2=93846&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/SectionKind.h (original)
+++ llvm/trunk/include/llvm/MC/SectionKind.h Mon Jan 18 22:15:51 2010
@@ -88,6 +88,13 @@
            /// 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 @@
     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 @@
   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); }

Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93846&r1=93845&r2=93846&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Jan 18 22:15:51 2010
@@ -146,8 +146,13 @@
     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 @@
 
   // 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.





More information about the llvm-commits mailing list