[llvm] r333357 - Remove boolean argument from isSuitableFromBSS.

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Sun May 27 04:39:34 PDT 2018


Author: echristo
Date: Sun May 27 04:39:34 2018
New Revision: 333357

URL: http://llvm.org/viewvc/llvm-project?rev=333357&view=rev
Log:
Remove boolean argument from isSuitableFromBSS.

The argument was used as an additional negative condition and can be
expressed in the if conditional without needing to pass it down.
Update bss commentary around main use.

Modified:
    llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp

Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=333357&r1=333356&r2=333357&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Sun May 27 04:39:34 2018
@@ -64,7 +64,7 @@ static bool isNullOrUndef(const Constant
   return true;
 }
 
-static bool isSuitableForBSS(const GlobalVariable *GV, bool NoZerosInBSS) {
+static bool isSuitableForBSS(const GlobalVariable *GV) {
   const Constant *C = GV->getInitializer();
 
   // Must have zero initializer.
@@ -79,10 +79,6 @@ static bool isSuitableForBSS(const Globa
   if (GV->hasSection())
     return false;
 
-  // If -nozero-initialized-in-bss is specified, don't ever use BSS.
-  if (NoZerosInBSS)
-    return false;
-
   // Otherwise, put it in BSS!
   return true;
 }
@@ -155,7 +151,7 @@ SectionKind TargetLoweringObjectFile::ge
 
   // Handle thread-local data first.
   if (GVar->isThreadLocal()) {
-    if (isSuitableForBSS(GVar, TM.Options.NoZerosInBSS))
+    if (isSuitableForBSS(GVar) && !TM.Options.NoZerosInBSS)
       return SectionKind::getThreadBSS();
     return SectionKind::getThreadData();
   }
@@ -164,8 +160,9 @@ SectionKind TargetLoweringObjectFile::ge
   if (GVar->hasCommonLinkage())
     return SectionKind::getCommon();
 
-  // Variable can be easily put to BSS section.
-  if (isSuitableForBSS(GVar, TM.Options.NoZerosInBSS)) {
+  // Most non-mergeable zero data can be put in the BSS section unless otherwise
+  // specified.
+  if (isSuitableForBSS(GVar) && !TM.Options.NoZerosInBSS) {
     if (GVar->hasLocalLinkage())
       return SectionKind::getBSSLocal();
     else if (GVar->hasExternalLinkage())




More information about the llvm-commits mailing list