[llvm] r324679 - [Lanai] Code model dictates section selection.

Jacques Pienaar via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 8 15:25:05 PST 2018


Author: jpienaar
Date: Thu Feb  8 15:25:05 2018
New Revision: 324679

URL: http://llvm.org/viewvc/llvm-project?rev=324679&view=rev
Log:
[Lanai] Code model dictates section selection.

Always use the small section when the small code model is specified.


Modified:
    llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp

Modified: llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp?rev=324679&r1=324678&r2=324679&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp Thu Feb  8 15:25:05 2018
@@ -50,8 +50,7 @@ static bool isInSmallSection(uint64_t Si
 // section.
 bool LanaiTargetObjectFile::isGlobalInSmallSection(
     const GlobalObject *GO, const TargetMachine &TM) const {
-  if (GO == nullptr)
-    return false;
+  if (GO == nullptr) return TM.getCodeModel() == CodeModel::Small;
 
   // We first check the case where global is a declaration, because finding
   // section kind using getKindForGlobal() is only allowed for global
@@ -67,8 +66,7 @@ bool LanaiTargetObjectFile::isGlobalInSm
 bool LanaiTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO,
                                                    const TargetMachine &TM,
                                                    SectionKind Kind) const {
-  return (isGlobalInSmallSectionImpl(GO, TM) &&
-          (Kind.isData() || Kind.isBSS() || Kind.isCommon()));
+  return isGlobalInSmallSectionImpl(GO, TM);
 }
 
 // Return true if this global address should be placed into small data/bss
@@ -76,10 +74,10 @@ bool LanaiTargetObjectFile::isGlobalInSm
 // kind.
 bool LanaiTargetObjectFile::isGlobalInSmallSectionImpl(
     const GlobalObject *GO, const TargetMachine &TM) const {
-  // Only global variables, not functions.
   const auto *GVA = dyn_cast<GlobalVariable>(GO);
-  if (!GVA)
-    return false;
+
+  // If not a GlobalVariable, only consider the code model.
+  if (!GVA) return TM.getCodeModel() == CodeModel::Small;
 
   // Global values placed in sections starting with .ldata do not fit in
   // 21-bits, so always use large memory access for them. FIXME: This is a




More information about the llvm-commits mailing list