26 cl::desc(
"Small data and bss section threshold size (default=0)"),
51 bool LanaiTargetObjectFile::isGlobalInSmallSection(
60 return isGlobalInSmallSectionImpl(GO, TM);
67 bool LanaiTargetObjectFile::isGlobalInSmallSection(
const GlobalObject *GO,
70 return (isGlobalInSmallSectionImpl(GO, TM) &&
77 bool LanaiTargetObjectFile::isGlobalInSmallSectionImpl(
87 if (GVA->getSection().startswith(
".ldata"))
93 if (GVA->hasLocalLinkage())
96 if (((GVA->hasExternalLinkage() && GVA->isDeclaration()) ||
97 GVA->hasCommonLinkage()))
100 Type *Ty = GVA->getValueType();
102 GVA->getParent()->getDataLayout().getTypeAllocSize(Ty));
108 if (Kind.
isBSS() && isGlobalInSmallSection(GO, TM, Kind))
109 return SmallBSSSection;
110 if (Kind.
isData() && isGlobalInSmallSection(GO, TM, Kind))
111 return SmallDataSection;
126 unsigned &Align)
const {
128 return SmallDataSection;
Instances of this class represent a uniqued identifier for a section in the current translation unit...
A parsed version of the target data layout string in and methods for querying it. ...
static cl::opt< unsigned > SSThreshold("lanai-ssection-threshold", cl::Hidden, cl::desc("Small data and bss section threshold size (default=0)"), cl::init(0))
bool hasAvailableExternallyLinkage() const
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const override
Given a constant with the SectionKind, return a section that it should be placed in.
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Context object for machine code objects.
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
MCContext & getContext() const
initializer< Ty > init(const Ty &Val)
CodeModel::Model getCodeModel() const
Returns the code model.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important base class in LLVM.
void InitializeELF(bool UseInitArray_)
SectionKind - This is a simple POD value that classifies the properties of a section.
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Type * getType() const
All values are typed, get the type of this value.
static bool isInSmallSection(uint64_t Size)
bool isConstantInSmallSection(const DataLayout &DL, const Constant *CN) const
Return true if this constant should be placed into small data section.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const override
Given a constant with the SectionKind, return a section that it should be placed in.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Primary interface to the complete machine description for the target machine.
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...