Go to the documentation of this file.
63 if (!
getContext().getAsmInfo()->hasLEB128Directives())
70 if (
C->isNullValue() || isa<UndefValue>(
C))
72 if (!isa<ConstantAggregate>(
C))
74 for (
auto Operand :
C->operand_values()) {
107 unsigned NumElts = CDS->getNumElements();
108 assert(NumElts != 0 &&
"Can't have an empty CDS");
110 if (CDS->getElementAsInteger(NumElts-1) != 0)
114 for (
unsigned i = 0;
i != NumElts-1; ++
i)
115 if (CDS->getElementAsInteger(
i) == 0)
121 if (isa<ConstantAggregateZero>(
C))
122 return cast<ArrayType>(
C->getType())->getNumElements() == 1;
153 M.getModuleFlagsMetadata(ModuleFlags);
155 MDNode *CFGProfile =
nullptr;
157 for (
const auto &MFE : ModuleFlags) {
159 if (
Key ==
"CG Profile") {
160 CFGProfile = cast<MDNode>(MFE.Val);
171 auto *V = cast<ValueAsMetadata>(MDO);
172 const Function *
F = cast<Function>(V->getValue()->stripPointerCasts());
173 if (
F->hasDLLImportStorageClass())
178 for (
const auto &Edge : CFGProfile->
operands()) {
179 MDNode *
E = cast<MDNode>(Edge);
181 const MCSymbol *To = GetSym(
E->getOperand(1));
186 uint64_t Count = cast<ConstantAsMetadata>(
E->getOperand(2))
203 "Can only be used for global definitions");
206 if (isa<Function>(GO))
210 if (isa<BasicBlock>(GO))
214 const auto *GVar = cast<GlobalVariable>(GO);
217 if (GVar->isThreadLocal()) {
221 if (GVar->hasLocalLinkage()) {
230 if (GVar->hasCommonLinkage())
236 if (GVar->hasLocalLinkage())
238 else if (GVar->hasExternalLinkage())
245 if (GVar->isConstant()) {
249 const Constant *
C = GVar->getInitializer();
250 if (!
C->needsRelocation()) {
254 if (!GVar->hasGlobalUnnamedAddr())
259 if (
ArrayType *ATy = dyn_cast<ArrayType>(
C->getType())) {
261 dyn_cast<IntegerType>(ATy->getElementType())) {
262 if ((ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16 ||
263 ITy->getBitWidth() == 32) &&
265 if (ITy->getBitWidth() == 8)
267 if (ITy->getBitWidth() == 16)
270 assert(ITy->getBitWidth() == 32 &&
"Unknown width");
280 GVar->getParent()->getDataLayout().getTypeAllocSize(
C->getType())) {
298 !
C->needsDynamicRelocation())
320 if (
auto *GVar = dyn_cast<GlobalVariable>(GO)) {
322 if ((
Attrs.hasAttribute(
"bss-section") &&
Kind.isBSS()) ||
323 (
Attrs.hasAttribute(
"data-section") &&
Kind.isData()) ||
324 (
Attrs.hasAttribute(
"relro-section") &&
Kind.isReadOnlyWithRel()) ||
325 (
Attrs.hasAttribute(
"rodata-section") &&
Kind.isReadOnly())) {
330 if (
auto *
F = dyn_cast<Function>(GO)) {
331 if (
F->hasFnAttribute(
"implicit-section-name"))
357 bool UsesLabelDifference,
const Function &
F)
const {
361 if (UsesLabelDifference)
368 return F.isWeakForLinker();
375 Align &Alignment)
const {
408 switch (Encoding & 0x70) {
static bool isSuitableForBSS(const GlobalVariable *GV)
static SectionKind getReadOnlyWithRel()
static SectionKind getMergeable2ByteCString()
This is an optimization pass for GlobalISel generic memory operations.
static SectionKind getBSSExtern()
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
A parsed version of the target data layout string in and methods for querying it.
unsigned NoZerosInBSS
NoZerosInBSS - By default some codegens place zero-initialized data to .bss section.
virtual void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
Context object for machine code objects.
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix, const TargetMachine &TM) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static SectionKind getThreadBSSLocal()
MCSection * SectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const
This method computes the appropriate section to emit the specified global variable or function defini...
virtual const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const
Create a symbol reference to describe the given TLS variable when emitting the address in debug info.
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
static SectionKind getMergeableConst16()
Class to represent array types.
MCContext & getContext() const
unsigned CallSiteEncoding
op_range operands() const
static SectionKind getReadOnly()
Streaming machine code generation interface.
static SectionKind getBSSLocal()
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
static SectionKind getThreadBSS()
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
@ Ref
The access may reference the value stored in memory.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
(vector float) vec_cmpeq(*A, *B) C
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
static SectionKind getBSS()
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
Class to represent integer types.
This class contains meta information specific to a module.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void emitCGProfileMetadata(MCStreamer &Streamer, Module &M) const
Emit Call Graph Profile metadata.
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
MCSymbol * getSymbol(const GlobalValue *GV) const
static SectionKind getText()
This struct is a compact representation of a valid (non-zero power of two) alignment.
virtual MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
bool isPositionIndependent() const
virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, const MCSymbol *Sym) const
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
AttributeList getAttributes() const
Return the attribute list for this Function.
unsigned getCallSiteEncoding() const
void append(StringRef RHS)
Append from a StringRef.
static SectionKind getCommon()
bool hasSection() const
Check if this global has a custom object file section.
static SectionKind getMergeable1ByteCString()
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This is an important base class in LLVM.
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
virtual MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const =0
Module * getParent()
Get the module that this global value is contained inside of...
static SectionKind getMergeable4ByteCString()
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Primary interface to the complete machine description for the target machine.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static SectionKind getThreadData()
A Module instance is used to store all the information related to an LLVM module.
Represent a reference to a symbol from inside an expression.
void initMCObjectFileInfo(MCContext &MCCtx, bool PIC, bool LargeCodeModel=false)
virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const
virtual ~TargetLoweringObjectFile()
StringRef - Represent a constant reference to a string, i.e.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Instances of this class represent a uniqued identifier for a section in the current translation unit.
static bool IsNullTerminatedString(const Constant *C)
IsNullTerminatedString - Return true if the specified constant (which is known to have a type that is...
virtual MCSection * getSectionForMachineBasicBlock(const Function &F, const MachineBasicBlock &MBB, const TargetMachine &TM) const
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
unsigned PersonalityEncoding
PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values for EH.
virtual MCSection * getUniqueSectionForFunction(const Function &F, const TargetMachine &TM) const
static SectionKind getData()
static SectionKind getMergeableConst8()
SectionKind - This is a simple POD value that classifies the properties of a section.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
MCSection * DataSection
Section directive for standard data.
StringRef getPrivateGlobalPrefix() const
static bool isNullOrUndef(const Constant *C)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const
Given a constant with the SectionKind, return a section that it should be placed in.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
static SectionKind getMergeableConst4()
virtual MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const
bool isDeclarationForLinker() const
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
const char LLVMTargetMachineRef TM
CodeModel::Model getCodeModel() const
Returns the code model.
virtual MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const =0
Targets should implement this method to assign a section to globals with an explicit section specfied...
BlockVerifier::State From
static SectionKind getMergeableConst32()
virtual const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const
Return an MCExpr to use for a reference to the specified global variable from exception handling info...
Base class for the full range of assembler expressions which are needed for parsing.
Tracking metadata reference owned by Metadata.