134 using namespace llvm;
136 #define DEBUG_TYPE "asm-printer" 148 "CodeView Line Tables";
150 STATISTIC(EmittedInsts,
"Number of machine instrs printed");
152 char AsmPrinter::ID = 0;
171 if (InAlign > Alignment)
179 assert(GVAlign &&
"GVAlign must be set");
184 Alignment = *GVAlign;
195 assert(!DD &&
Handlers.empty() &&
"Debug/EH info didn't get finalized");
197 if (GCMetadataPrinters) {
201 GCMetadataPrinters =
nullptr;
229 assert(
MF &&
"getSubtargetInfo requires a valid MachineFunction!");
238 assert(DD &&
"Dwarf debug file is not defined.");
259 auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
260 MMI = MMIWP ? &MMIWP->getMMI() :
nullptr;
267 .getModuleMetadata(M);
294 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
297 MP->beginAssembly(M, *MI, *
this);
306 OutStreamer->AddComment(
"Start of file scope inline assembly");
310 OutStreamer->AddComment(
"End of file scope inline assembly");
315 bool EmitCodeView = MMI->getModule()->getCodeViewFlag();
317 Handlers.emplace_back(std::make_unique<CodeViewDebug>(
this),
318 DbgTimerName, DbgTimerDescription,
319 CodeViewLineTablesGroupName,
320 CodeViewLineTablesGroupDescription);
322 if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) {
325 Handlers.emplace_back(std::unique_ptr<DwarfDebug>(DD), DbgTimerName,
326 DbgTimerDescription, DWARFGroupName,
327 DWARFGroupDescription);
335 isCFIMoveForDebugging =
true;
342 if (!
F.isDeclarationForLinker() &&
F.needsUnwindTableEntry()) {
343 isCFIMoveForDebugging =
false;
349 isCFIMoveForDebugging =
false;
380 Handlers.emplace_back(std::unique_ptr<EHStreamer>(ES), EHTimerName,
381 EHTimerDescription, DWARFGroupName,
382 DWARFGroupDescription);
385 if (mdconst::extract_or_null<ConstantInt>(
386 MMI->getModule()->getModuleFlag(
"cfguard")))
387 Handlers.emplace_back(std::make_unique<WinCFGuard>(
this), CFGuardName,
388 CFGuardDescription, DWARFGroupName,
389 DWARFGroupDescription);
457 "No emulated TLS variables in the common section");
497 "' is already defined");
514 HI.TimerGroupName,
HI.TimerGroupDescription,
516 HI.Handler->setSymbolSize(GVSym, Size);
521 if (Size == 0) Size = 1;
523 const bool SupportsAlignment =
526 SupportsAlignment ? Alignment.
value() : 0);
567 const bool SupportsAlignment =
570 SupportsAlignment ? Alignment.
value() : 0);
655 void AsmPrinter::EmitFunctionHeader() {
660 <<
"-- Begin function " 711 unsigned PatchableFunctionPrefix = 0;
712 unsigned PatchableFunctionEntry = 0;
719 if (PatchableFunctionPrefix) {
724 }
else if (PatchableFunctionEntry) {
742 std::vector<MCSymbol*> DeadBlockSyms;
744 for (
unsigned i = 0,
e = DeadBlockSyms.size(); i !=
e; ++i) {
745 OutStreamer->AddComment(
"Address taken block that was later removed");
764 HI.Handler->beginFunction(
MF);
781 "' is a protected alias");
784 "' label emitted multiple times to assembly file");
800 CommentOS << *Size <<
"-byte Reload\n";
803 CommentOS << *Size <<
"-byte Folded Reload\n";
805 CommentOS << *Size <<
"-byte Spill\n";
808 CommentOS << *Size <<
"-byte Folded Spill\n";
813 CommentOS <<
" Reload Reuse\n";
823 OS <<
"implicit-def: " 836 assert(Op.
isReg() &&
"KILL instruction must have only register operands");
837 OS <<
' ' << (Op.
isDef() ?
"def " :
"killed ")
854 OS <<
"DEBUG_VALUE: ";
857 if (
auto *
SP = dyn_cast<DISubprogram>(V->
getScope())) {
871 bool NeedSep =
false;
878 for (
unsigned I = 0;
I <
Op.getNumArgs(); ++
I)
879 OS <<
' ' <<
Op.getArg(
I);
905 OS <<
"!target-index(" <<
Op.getIndex() <<
"," <<
Op.getOffset() <<
")";
931 OS <<
'+' << Offset <<
']';
947 OS <<
"DEBUG_LABEL: ";
950 if (
auto *
SP = dyn_cast<DISubprogram>(
991 while (
I != MBB->end() &&
I->isTransient())
993 if (
I == MBB->instr_end() &&
994 MBB->getReverseIterator() == MBB->getParent()->rbegin())
1019 if (!StackSizeSection)
1054 EmitFunctionHeader();
1063 MDT = getAnalysisIfAvailable<MachineDominatorTree>();
1065 OwnedMDT = std::make_unique<MachineDominatorTree>();
1066 OwnedMDT->getBase().recalculate(*
MF);
1067 MDT = OwnedMDT.get();
1071 MLI = getAnalysisIfAvailable<MachineLoopInfo>();
1073 OwnedMLI = std::make_unique<MachineLoopInfo>();
1075 MLI = OwnedMLI.get();
1080 bool HasAnyRealCode =
false;
1081 int NumInstsInFunction = 0;
1082 for (
auto &MBB : *
MF) {
1085 for (
auto &
MI : MBB) {
1087 if (!
MI.isPosition() && !
MI.isImplicitDef() && !
MI.isKill() &&
1088 !
MI.isDebugInstr()) {
1089 HasAnyRealCode =
true;
1090 ++NumInstsInFunction;
1097 if (ShouldPrintDebugScopes) {
1100 HI.TimerGroupName,
HI.TimerGroupDescription,
1102 HI.Handler->beginInstruction(&
MI);
1109 switch (
MI.getOpcode()) {
1110 case TargetOpcode::CFI_INSTRUCTION:
1113 case TargetOpcode::LOCAL_ESCAPE:
1118 case TargetOpcode::GC_LABEL:
1125 case TargetOpcode::DBG_VALUE:
1131 case TargetOpcode::DBG_LABEL:
1137 case TargetOpcode::IMPLICIT_DEF:
1152 if (ShouldPrintDebugScopes) {
1155 HI.TimerGroupName,
HI.TimerGroupDescription,
1157 HI.Handler->endInstruction();
1165 EmittedInsts += NumInstsInFunction;
1167 MF->getFunction().getSubprogram(),
1169 R <<
ore::NV(
"NumInstructions", NumInstsInFunction)
1170 <<
" instructions in function";
1185 MF->getSubtarget().getInstrInfo()->getNoop(Noop);
1190 OutStreamer->AddComment(
"avoids zero-length function");
1196 for (
const auto &BB : F) {
1197 if (!BB.hasAddressTaken())
1202 OutStreamer->AddComment(
"Address of block that was removed by CodeGen");
1230 HI.Handler->markFunctionEnd();
1240 HI.Handler->endFunction(MF);
1249 OutStreamer->GetCommentOS() <<
"-- End function\n";
1259 if (isa<GlobalVariable>(C))
1262 unsigned NumUses = 0;
1275 unsigned &NumGOTEquivUsers) {
1286 for (
auto *U : GV->
users())
1289 return NumGOTEquivUsers > 0;
1303 for (
const auto &
G : M.
globals()) {
1304 unsigned NumGOTEquivUsers = 0;
1323 unsigned Cnt =
I.second.second;
1327 GlobalGOTEquivs.clear();
1329 for (
auto *GV : FailedCandidates)
1333 void AsmPrinter::emitGlobalIndirectSymbol(
Module &M,
1350 if (CE->getOpcode() == Instruction::BitCast)
1352 CE->getOperand(0)->getType()->getPointerElementType()->isFunctionTy();
1357 OutStreamer->EmitSymbolAttribute(Name, isa<GlobalIFunc>(GIS)
1365 if (isa<GlobalAlias>(&GIS) &&
MAI->
hasAltEntry() && isa<MCBinaryExpr>(Expr))
1371 if (
auto *GA = dyn_cast<GlobalAlias>(&GIS)) {
1395 Filename = *FilenameRef;
1397 assert(!Filename->empty() &&
"The filename can't be empty.");
1402 std::unique_ptr<remarks::MetaSerializer> MetaSerializer =
1405 MetaSerializer->emit();
1436 if (!
F.isDeclarationForLinker())
1461 if (!Stubs.empty()) {
1466 for (
const auto &Stub : Stubs) {
1468 OutStreamer->EmitSymbolValue(Stub.second.getPointer(),
1480 if (!Stubs.empty()) {
1483 for (
const auto &Stub : Stubs) {
1485 SectionName += Stub.first->getName();
1495 OutStreamer->EmitSymbolValue(Stub.second.getPointer(),
1505 HI.Handler->endModule();
1518 for (
const auto &GO : M.global_objects()) {
1519 if (!GO.hasExternalWeakLinkage())
1531 for (
const auto &Alias : M.aliases()) {
1534 if (!AliasVisited.
insert(Cur).second)
1539 emitGlobalIndirectSymbol(M, *AncestorAlias);
1542 for (
const auto &IFunc : M.ifuncs())
1543 emitGlobalIndirectSymbol(M, IFunc);
1546 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
1549 MP->finishAssembly(M, *MI, *
this);
1552 EmitModuleIdents(M);
1555 EmitModuleCommandLines(M);
1587 if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->
use_empty())
1600 if (!Flags.empty()) {
1608 if (
const auto *LU = M.getNamedGlobal(
"llvm.used")) {
1609 assert(LU->hasInitializer() &&
1610 "expected llvm.used to have an initializer");
1611 assert(isa<ArrayType>(LU->getValueType()) &&
1612 "expected llvm.used to be an array type");
1613 if (
const auto *A = cast<ConstantArray>(LU->getInitializer())) {
1614 for (
const Value *
Op : A->operands()) {
1615 const auto *GV = cast<GlobalValue>(
Op->stripPointerCasts());
1619 if (GV->hasLocalLinkage())
1626 if (!Flags.empty()) {
1640 if (!GV.use_empty() && !GV.isThreadLocal() &&
1641 !GV.hasDLLImportStorageClass() && !GV.getName().startswith(
"llvm.") &&
1642 !GV.hasAtLeastLocalUnnamedAddr())
1648 unsigned UniqueID = 0;
1650 if (!GV.hasPartition() || GV.isDeclarationForLinker() ||
1679 if (!CurExceptionSym)
1681 return CurExceptionSym;
1691 " supported on AIX.");
1693 " initalized first.");
1702 cast<MCSymbolXCOFF>(
CurrentFnSym)->setContainingCsect(FnEntryPointSec);
1709 CurExceptionSym =
nullptr;
1715 if (NeedsLocalForSize)
1719 ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
1720 PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
1725 &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI()) :
1737 SectionCPs(
MCSection *s,
unsigned a) : S(s), Alignment(a) {}
1748 const std::vector<MachineConstantPoolEntry> &
CP = MCP->
getConstants();
1749 if (CP.empty())
return;
1754 for (
unsigned i = 0,
e = CP.size(); i !=
e; ++i) {
1770 unsigned SecIdx = CPSections.
size();
1771 while (SecIdx != 0) {
1772 if (CPSections[--SecIdx].S == S) {
1778 SecIdx = CPSections.
size();
1779 CPSections.
push_back(SectionCPs(S, Align));
1782 if (Align > CPSections[SecIdx].Alignment)
1783 CPSections[SecIdx].Alignment =
Align;
1790 for (
unsigned i = 0,
e = CPSections.
size(); i !=
e; ++i) {
1791 for (
unsigned j = 0, ee = CPSections[i].CPEs.
size(); j != ee; ++j) {
1792 unsigned CPI = CPSections[i].CPEs[j];
1798 cast<MCSymbolXCOFF>(Sym)->setContainingCsect(
1799 cast<MCSectionXCOFF>(CPSections[i].S));
1802 if (CurSection != CPSections[i].S) {
1805 CurSection = CPSections[i].S;
1813 unsigned NewOffset = (Offset + AlignMask) & ~AlignMask;
1836 if (JT.empty())
return;
1845 if (JTInDiffSection) {
1855 if (!JTInDiffSection)
1858 for (
unsigned JTI = 0,
e = JT.size(); JTI !=
e; ++JTI) {
1859 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
1862 if (JTBBs.empty())
continue;
1871 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
1873 if (!EmittedSets.
insert(MBB).second)
1897 cast<MCSymbolXCOFF>(JTISymbol)->setContainingCsect(
1902 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
1903 EmitJumpTableEntry(MJTI, JTBBs[ii], JTI);
1905 if (!JTInDiffSection)
1913 unsigned UID)
const {
1967 assert(Value &&
"Unknown entry kind!");
1977 if (GV->
getName() ==
"llvm.used") {
1992 if (GV->
getName() ==
"llvm.global_ctors") {
1999 if (GV->
getName() ==
"llvm.global_dtors") {
2011 void AsmPrinter::EmitLLVMUsedList(
const ConstantArray *InitList) {
2028 Structor() =
default;
2039 if (!isa<ConstantArray>(List))
return;
2043 if (!InitList)
return;
2059 if (!Priority)
continue;
2061 Structor &S = Structors.
back();
2071 return L.Priority < R.Priority;
2074 for (Structor &S : Structors) {
2078 if (GV->isDeclarationForLinker())
2098 void AsmPrinter::EmitModuleIdents(
Module &M) {
2103 for (
unsigned i = 0,
e = NMD->getNumOperands(); i !=
e; ++i) {
2104 const MDNode *
N = NMD->getOperand(i);
2106 "llvm.ident metadata entry can have only one operand");
2113 void AsmPrinter::EmitModuleCommandLines(
Module &M) {
2128 "llvm.commandline metadata entry can have only one operand");
2165 unsigned Size)
const {
2166 OutStreamer->emitAbsoluteSymbolDiff(Hi, Lo, Size);
2174 bool IsSectionRelative)
const {
2220 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV))
2223 if (
const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
2226 if (
const BlockAddress *BA = dyn_cast<BlockAddress>(CV))
2247 OS <<
"Unsupported expression in static initializer: ";
2252 case Instruction::GetElementPtr: {
2255 cast<GEPOperator>(CE)->accumulateConstantOffset(
getDataLayout(), OffsetAI);
2266 case Instruction::Trunc:
2272 case Instruction::BitCast:
2275 case Instruction::IntToPtr: {
2286 case Instruction::PtrToInt: {
2312 case Instruction::Sub: {
2321 const MCExpr *RelocExpr =
2327 int64_t Addend = (LHSOffset - RHSOffset).getSExtValue();
2341 case Instruction::Mul:
2342 case Instruction::SDiv:
2343 case Instruction::SRem:
2344 case Instruction::Shl:
2345 case Instruction::And:
2346 case Instruction::Or:
2347 case Instruction::Xor: {
2379 assert(!Data.
empty() &&
"Empty aggregates should be CAZ node");
2381 for (
unsigned i = 1,
e = Data.
size(); i !=
e; ++i)
2382 if (Data[i] != C)
return -1;
2383 return static_cast<uint8_t
>(
C);
2390 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
2395 APInt Value = CI->getValue().zextOrSelf(Size);
2404 assert(CA->getNumOperands() != 0 &&
"Should be a CAZ");
2411 for (
unsigned i = 1,
e = CA->getNumOperands(); i !=
e; ++i)
2412 if (CA->getOperand(i) != Op0)
2458 assert(EmittedSize <= Size &&
"Size cannot be less than EmittedSize!");
2459 if (
unsigned Padding = Size - EmittedSize)
2490 if (
unsigned Padding = Size - EmittedSize)
2500 uint64_t SizeSoFar = 0;
2511 SizeSoFar += FieldSize + PadSize;
2519 "Layout of constant struct may be incorrect!");
2523 assert(ET &&
"Unknown float type");
2532 AP.
OutStreamer->GetCommentOS() <<
' ' << StrVal <<
'\n';
2539 unsigned TrailingBytes = NumBytes %
sizeof(uint64_t);
2548 AP.
OutStreamer->EmitIntValue(p[Chunk--], TrailingBytes);
2550 for (; Chunk >= 0; --Chunk)
2551 AP.
OutStreamer->EmitIntValue(p[Chunk],
sizeof(uint64_t));
2554 for (Chunk = 0; Chunk < NumBytes /
sizeof(uint64_t); ++Chunk)
2555 AP.
OutStreamer->EmitIntValue(p[Chunk],
sizeof(uint64_t));
2558 AP.
OutStreamer->EmitIntValue(p[Chunk], TrailingBytes);
2577 uint64_t ExtraBits = 0;
2578 unsigned ExtraBitsSize = BitWidth & 63;
2580 if (ExtraBitsSize) {
2597 ExtraBits = Realigned.getRawData()[0] &
2598 (((uint64_t)-1) >> (64 - ExtraBitsSize));
2599 Realigned.lshrInPlace(ExtraBitsSize);
2601 ExtraBits = Realigned.getRawData()[BitWidth / 64];
2607 const uint64_t *RawData = Realigned.getRawData();
2608 for (
unsigned i = 0,
e = BitWidth / 64; i !=
e; ++i) {
2609 uint64_t Val = DL.
isBigEndian() ? RawData[
e - i - 1] : RawData[i];
2613 if (ExtraBitsSize) {
2618 Size -= (BitWidth / 64) * 8;
2619 assert(Size && Size * 8 >= ExtraBitsSize &&
2620 (ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize)))
2621 == ExtraBits &&
"Directive too small for extra bits.");
2653 if (!(*ME)->evaluateAsRelocatable(MV,
nullptr,
nullptr) || MV.
isAbsolute())
2664 const GlobalValue *BaseGV = dyn_cast_or_null<GlobalValue>(BaseCst);
2672 if (!SymB || BaseSym != &SymB->
getSymbol())
2683 if (GOTPCRelCst < 0)
2705 int NumUses = (int)Result.second;
2726 BaseCV = dyn_cast<Constant>(CV->
user_back());
2728 if (isa<ConstantAggregateZero>(CV) || isa<UndefValue>(CV))
2731 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
2739 CI->getZExtValue());
2748 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(CV))
2751 if (isa<ConstantPointerNull>(CV)) {
2765 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
2768 if (CE->getOpcode() == Instruction::BitCast)
2776 if (New && New != CE)
2817 else if (Offset < 0)
2856 if (
MCSymbol *Sym = S->getCOMDATSymbol()) {
2857 if (Sym->isUndefined())
2903 <<
"Parent Loop BB" << FunctionNumber <<
"_" 2914 OS.
indent(CL->getLoopDepth()*2)
2915 <<
"Child Loop BB" << FunctionNumber <<
"_" 2916 << CL->getHeader()->getNumber() <<
" Depth " << CL->getLoopDepth()
2931 assert(Header &&
"No header for loop");
2935 if (Header != &MBB) {
2936 AP.
OutStreamer->AddComment(
" in Loop: Header=BB" +
2967 HI.Handler->endFunclet();
2968 HI.Handler->beginFunclet(MBB);
2996 if (BB->hasName()) {
2998 false, BB->getModule());
3003 assert(
MLI !=
nullptr &&
"MachineLoopInfo should has been computed");
3018 OutStreamer->AddComment(
"Label of block must be emitted");
3026 bool IsDefinition)
const {
3029 switch (Visibility) {
3072 if (!
MI.isBranch() ||
MI.isIndirectBranch())
3081 if (
OP->isMBB() &&
OP->getMBB() == MBB)
3095 if (GCPI != GCMap.
end())
3096 return GCPI->second.get();
3103 if (
Name ==
I->getName()) {
3104 std::unique_ptr<GCMetadataPrinter> GMP =
I->instantiate();
3106 auto IterBool = GCMap.
insert(std::make_pair(&S, std::move(GMP)));
3107 return IterBool.first->second.get();
3115 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
3116 bool NeedsDefault =
false;
3119 NeedsDefault =
true;
3121 for (
auto &
I : *MI) {
3123 if (MP->emitStackMaps(SM, *
this))
3127 NeedsDefault =
true;
3146 auto Kind8 =
static_cast<uint8_t
>(Kind);
3149 StringRef(reinterpret_cast<const char *>(&AlwaysInstrument), 1));
3151 auto Padding = (4 * Bytes) - ((2 * Bytes) + 3);
3152 assert(Padding >= 0 &&
"Instrumentation map entry > 4 * Word Size");
3160 auto PrevSection =
OutStreamer->getCurrentSectionOnly();
3166 assert(Associated !=
nullptr);
3168 std::string GroupName;
3177 GroupName, UniqueID, Associated);
3180 GroupName, UniqueID, Associated);
3198 for (
const auto &Sled :
Sleds)
3208 OutStreamer->EmitCodeAlignment(2 * WordSizeBytes);
3209 OutStreamer->EmitSymbolValue(SledsStart, WordSizeBytes,
false);
3210 OutStreamer->EmitSymbolValue(SledsEnd, WordSizeBytes,
false);
3220 bool AlwaysInstrument =
3221 Attr.isStringAttribute() && Attr.getValueAsString() ==
"xray-always";
3225 AlwaysInstrument, &
F, Version});
3230 unsigned PatchableFunctionPrefix = 0, PatchableFunctionEntry = 0;
3237 if (!PatchableFunctionPrefix && !PatchableFunctionEntry)
3248 std::string GroupName;
3260 GroupName, UniqueID, cast<MCSymbolELF>(
CurrentFnSym)));
3271 return OutStreamer->getContext().getDwarfVersion();
3275 OutStreamer->getContext().setDwarfVersion(Version);
ANNOTATION_LABEL - Represents a mid basic block label used by annotations.
virtual void EmitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
const Function & getFunction() const
void setDwarfVersion(uint16_t Version)
MachineConstantPoolValue * MachineCPVal
StringRef getSection() const
Get the custom section of this global if it has one.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
bool doesSetDirectiveSuppressReloc() const
void emitInt64(uint64_t Value) const
Emit a long long directive and value.
virtual void EmitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
A parsed version of the target data layout string in and methods for querying it. ...
static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP)
StringRef getTargetFeatureString() const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
bool usesWindowsCFI() const
MCSymbolAttr getHiddenVisibilityAttr() const
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
SectionKind getKind() const
const std::vector< MachineJumpTableEntry > & getJumpTables() const
bool isThreadData() const
union llvm::MachineConstantPoolEntry::@168 Val
The constant itself.
bool hasLocalLinkage() const
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
Special purpose, only applies to global arrays.
uint64_t getZExtValue() const
Get zero extended value.
static void emitBasicBlockLoopComments(const MachineBasicBlock &MBB, const MachineLoopInfo *LI, const AsmPrinter &AP)
emitBasicBlockLoopComments - Pretty-print comments for basic blocks.
DiagnosticInfoOptimizationBase::Argument NV
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
bool hasDebugInfo() const
Returns true if valid debug info is present.
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
static const char *const DbgTimerDescription
MDNode * getOperand(unsigned i) const
MCTargetOptions MCOptions
Machine level options.
virtual MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const
bool hasPrivateLinkage() const
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
const std::vector< MCCFIInstruction > & getFrameInstructions() const
Returns a reference to a list of cfi instructions in the function's prologue.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
bool isVariable() const
isVariable - Check if this is a variable symbol.
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...
.type _foo, STT_OBJECT # aka
This represents an "assembler immediate".
static bool isGOTEquivalentCandidate(const GlobalVariable *GV, unsigned &NumGOTEquivUsers)
Only consider global GOT equivalents if at least one user is a cstexpr inside an initializer of anoth...
bool hasMachoTBSSDirective() const
StringRef getPrivateGlobalPrefix() const
MCSection * getRemarksSection() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Align getAlignment() const
getAlignment - Return the alignment of the function.
A Module instance is used to store all the information related to an LLVM module. ...
void redefineIfPossible()
Prepare this symbol to be redefined.
MCSection * getTLSBSSSection() const
bool doesSupportDebugInformation() const
bool hasSingleParameterDotFile() const
bool doFinalization(Module &M) override
Shut down the asmprinter.
SmallVector< std::unique_ptr< GCStrategy >, 1 >::const_iterator iterator
Same, but only replaced by something equivalent.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static void emitGlobalConstantDataSequential(const DataLayout &DL, const ConstantDataSequential *CDS, AsmPrinter &AP)
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
virtual int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
MCContext & OutContext
This is the context for the output file that we are streaming.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool hasLinkOnceDirective() const
bool isTargetIndex() const
isTargetIndex - Tests if this is a MO_TargetIndex operand.
unsigned getLoopDepth() const
Return the nesting level of this loop.
Available for inspection, not emission.
unsigned getNumWords() const
Get the number of words.
unsigned getNumElements() const
Random access to the elements.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
void push_back(const T &Elt)
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
setjmp/longjmp based exceptions
uint16_t getDwarfVersion() const
CFIMoveType needsCFIMoves() const
virtual void EmitJumpTableInfo()
Print assembly representations of the jump tables used by the current function to the current output ...
static int isRepeatedByteSequence(const ConstantDataSequential *V)
isRepeatedByteSequence - Determine whether the given value is composed of a repeated sequence of iden...
Collects and handles dwarf debug information.
bool hasAvailableExternallyLinkage() const
virtual void EmitXXStructor(const DataLayout &DL, const Constant *CV)
Targets can override this to change how global constants that are part of a C++ static/global constru...
EK_Inline - Jump table entries are emitted inline at their point of use.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
virtual const TargetLowering * getTargetLowering() const
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
bool hasDotTypeDotSizeDirective() const
bool needsDwarfSectionOffsetDirective() const
float convertToFloat() const
uint64_t getElementByteSize() const
Return the size (in bytes) of each element in the array/vector.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM...
virtual MCSection * getSectionForCommandLines() const
If supported, return the section to use for the llvm.commandline metadata.
Like Internal, but omit from symbol table.
void EmitAlignment(Align Alignment, const GlobalObject *GV=nullptr) const
Emit an alignment directive to the specified power of two boundary.
Externally visible function.
bool IsConstantOffsetFromGlobal(Constant *C, GlobalValue *&GV, APInt &Offset, const DataLayout &DL)
If this constant is a constant offset from a global, return the global and the constant.
bool hasPrologueData() const
Check whether this function has prologue data.
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
static const char *const DWARFGroupName
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
A raw_ostream that writes to an SmallVector or SmallString.
virtual void EmitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
bool hasDotLGloblDirective() const
DebugLoc emitInitialLocDirective(const MachineFunction &MF, unsigned CUID)
Emits inital debug location directive.
STATISTIC(NumFunctions, "Total number of functions")
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
unsigned getProgramPointerSize() const
MachineFunction * MF
The current machine function.
SmallVector< HandlerInfo, 1 > Handlers
A vector of all debug/EH info emitters we should use.
const MDOperand & getOperand(unsigned I) const
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
virtual void emitLinkerFlagsForUsed(raw_ostream &OS, const GlobalValue *GV) const
static const MCBinaryExpr * createMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
std::pair< const GlobalVariable *, unsigned > GOTEquivUsePair
Map global GOT equivalent MCSymbols to GlobalVariables and keep track of its number of uses by other ...
static void emitKill(const MachineInstr *MI, AsmPrinter &AP)
static const char *const DWARFGroupDescription
bool hasSplitStack() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool hasIdentDirective() const
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
virtual void EmitDebugValue(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
DenseMap< GCStrategy *, std::unique_ptr< GCMetadataPrinter > > gcp_map_type
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
bool hasMachoZeroFillDirective() const
WinEH::EncodingType getWinEHEncodingType() const
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
unsigned getBitWidth() const
Return the number of bits in the APInt.
Constant * getPrologueData() const
Get the prologue data associated with this function.
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
virtual MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const
const Triple & getTargetTriple() const
void emitRemarksSection(RemarkStreamer &RS)
MCSymbol * CurrentPatchableFunctionEntrySym
The symbol for the entry in __patchable_function_entires.
This represents a section on Windows.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
The address of a basic block.
static const MCBinaryExpr * createXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
AnalysisUsage & addRequired()
int64_t getConstant() const
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
bool hasNosplitStack() const
const MCSymbolRefExpr * getSymB() const
static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP)
bool hasPrefixData() const
Check whether this function has prefix data.
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
Emits exception handling directives.
Align getPointerPrefAlignment(unsigned AS=0) const
Return target's alignment for stack-based pointers FIXME: The defaults need to be removed once all of...
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
StringRef getName() const
MCSymbol * createLinkerPrivateTempSymbol()
Create and return a new linker temporary symbol with a unique but unspecified name.
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual void EmitEndOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the end of their file...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
static void emitGlobalConstantStruct(const DataLayout &DL, const ConstantStruct *CS, AsmPrinter &AP, const Constant *BaseCV, uint64_t Offset)
unsigned getPointerTypeSize(Type *Ty) const
MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation for COFF targets.
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Retuns the total number of operands.
StringRef getRawDataValues() const
Return the raw, underlying, bytes of this data.
Class to represent struct types.
This class is basically a combination of TimeRegion and Timer.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
virtual void emitModuleMetadata(MCStreamer &Streamer, Module &M) const
Emit the module-level metadata that the platform cares about.
void make_absolute(const Twine ¤t_directory, SmallVectorImpl< char > &path)
Make path an absolute path.
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Base class for the full range of assembler expressions which are needed for parsing.
iterator_range< iterator > terminators()
Represent a reference to a symbol from inside an expression.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getNumOperands() const
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
bool getCommDirectiveSupportsAlignment() const
MCSection * getBSSSection() const
SmallVector< XRayFunctionEntry, 4 > Sleds
An analysis pass which caches information about the entire Module.
MCSection * getDataSection() const
MCSection * getStackSizesSection(const MCSection &TextSec) const
const char * getWeakRefDirective() const
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
unsigned getCFIIndex() const
Align getAlignment() const
Return alignment of the basic block.
This file implements a class to represent arbitrary precision integral constant values and operations...
bool hasCommonLinkage() const
INLINEASM - Represents an inline asm block.
Constant * getPrefixData() const
Get the prefix data associated with this function.
BlockT * getHeader() const
static const char *const CodeViewLineTablesGroupName
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
Optional< unsigned > getFoldedRestoreSize(const TargetInstrInfo *TII) const
Return a valid size if the instruction is a folded restore instruction.
void emitNops(unsigned N)
Emit N NOP instructions.
void emitXRayTable()
Emit a table with all XRay instrumentation points.
Context object for machine code objects.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
bool hasExternalLinkage() const
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
Constant * ConstantFoldConstant(const Constant *C, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldConstant - Attempt to fold the constant using the specified DataLayout.
static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF, MachineModuleInfo *MMI)
static const MCBinaryExpr * createShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
===- LazyMachineBlockFrequencyInfo.h - Lazy Block Frequency -*- C++ -*–===//
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
A constant value that is initialized with an expression using other constant values.
void EmitFunctionBody()
This method emits the body and trailer for a function.
int64_t getSExtValue() const
Get sign extended value.
static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS)
emitComments - Pretty-print comments for instructions.
const std::string & getName() const
Return the name of the GC strategy.
Type * getType() const
All values are typed, get the type of this value.
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MCSymbol * getFunctionBegin() const
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
virtual void EmitBasicBlockEnd(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the end of a basic block.
bool isPositionIndependent() const
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
bool supportGOTPCRelWithOffset() const
Target GOT "PC"-relative relocation supports encoding an additional binary expression with an offset...
.type _foo, STT_GNU_IFUNC
Optional< unsigned > getRestoreSize(const TargetInstrInfo *TII) const
Return a valid size if the instruction is a restore instruction.
VisibilityTypes
An enumeration for the kinds of visibility of global values.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
EK_BlockAddress - Each entry is a plain address of block, e.g.
LLVM_NODISCARD size_t size() const
size - Get the string size.
const APInt & getValue() const
Return the constant as an APInt value reference.
BasicBlock * getBasicBlock() const
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
bool hasFunctionAlignment() const
bool hasPersonalityFn() const
Check whether this function has a personality function.
This class is a data container for one entry in a MachineConstantPool.
virtual const MCExpr * LowerCustomJumpTableEntry(const MachineJumpTableInfo *, const MachineBasicBlock *, unsigned, MCContext &) const
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
LinkageTypes getLinkage() const
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
Protected struct HandlerInfo and Handlers permit target extended AsmPrinter adds their own handlers...
virtual const TargetInstrInfo * getInstrInfo() const
static const fltSemantics & IEEEdouble() LLVM_READNONE
StringRef getTargetCPU() const
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
unsigned getAlignment() const
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool hasLinkOnceLinkage() const
uint64_t value() const
This is a hole in the type system and should not be abused.
bool isVerbose() const
Return true if assembly output should contain comments.
bool hasNoDeadStrip() const
const std::string & str() const
Type * getElementType() const
Return the element type of the array/vector.
void emitGlobalGOTEquivs()
Constant expressions using GOT equivalent globals may not be eligible for PC relative GOT entry conve...
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Value * getOperand(unsigned i) const
Instances of this class represent a single low-level machine instruction.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME, const Constant *BaseCst, uint64_t Offset)
Transform a not absolute MCExpr containing a reference to a GOT equivalent global, by a target specific GOT pc relative access to the final symbol.
const std::string & getSourceFileName() const
Get the module's original source file name.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
static bool canBeHidden(const GlobalValue *GV, const MCAsmInfo &MAI)
static void emitGlobalConstantArray(const DataLayout &DL, const ConstantArray *CA, AsmPrinter &AP, const Constant *BaseCV, uint64_t Offset)
void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label+Offset" where the size in bytes of the directive is specified by Siz...
StringRef getName() const
TargetInstrInfo - Interface to description of machine instruction set.
bool hasAppendingLinkage() const
iterator find(const_arg_type_t< KeyT > Val)
WebAssembly Exception Handling.
const Constant * ConstVal
virtual void getNoop(MCInst &NopInst) const
Return the noop instruction to use for a noop.
This class is intended to be used as a base class for asm properties and features specific to the tar...
bool hasProfileSummary()
Returns true if profile summary is available.
MCSection * getTLSExtraDataSection() const
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
bool isOSWindows() const
Tests whether the OS is Windows.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
ExternalWeak linkage description.
virtual MCSection * getNonexecutableStackSection(MCContext &Ctx) const
Targets can implement this method to specify a section to switch to if the translation unit doesn't h...
Optional< unsigned > getSpillSize(const TargetInstrInfo *TII) const
Return a valid size if the instruction is a spill instruction.
static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP)
emitDebugValueComment - This method handles the target-independent form of DBG_VALUE, returning true if it was able to do so.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
void emitPatchableFunctionEntries()
Same, but only replaced by something equivalent.
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Streaming machine code generation interface.
virtual void EmitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
static const char *const EHTimerDescription
StringRef getName() const
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
MCSymbol * CurrentFnBegin
.weak_def_can_be_hidden (MachO)
VisibilityTypes getVisibility() const
MCSymbol * CurrentFnSym
The symbol for the current function.
bool getAsmPrinterFlag(CommentFlag Flag) const
Return whether an AsmPrinter flag is set.
DenseMap< const MCSection *, unsigned > PatchableFunctionEntryID
LLVM Basic Block Representation.
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
const MCAsmInfo * MAI
Target Asm Printer information.
The instances of the Type class are immutable: once they are created, they are never changed...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const
void takeDeletedSymbolsForFunction(const Function *F, std::vector< MCSymbol *> &Result)
If the specified function has had any references to address-taken blocks generated, but the block got deleted, return the symbol now so we can emit it.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual void emitLinkerFlagsForGlobal(raw_ostream &OS, const GlobalValue *GV) const
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool needsLocalForSize() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
bool hasEHFunclets() const
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
MCSymbol * getAddrLabelSymbol(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
This is an alternative analysis pass to MachineBlockFrequencyInfo.
virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const
Given a constant with the SectionKind, return a section that it should be placed in.
static Align getGVAlignment(const GlobalValue *GV, const DataLayout &DL, Align InAlign=Align::None())
Return the alignment for the specified GV.
ConstantFP - Floating Point Values [float, double].
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
MCSymbol * getSymbol(const GlobalValue *GV) const
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
unsigned EmitStackSizeSection
Emit section containing metadata on function stack sizes.
double convertToDouble() const
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
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...
Represent the analysis usage information of a pass.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
const MCSymbolRefExpr * getSymA() const
const DILabel * getDebugLabel() const
Return the debug label referenced by this DBG_LABEL instruction.
const MCObjectFileInfo * getObjectFileInfo() const
bool hasWeakDefCanBeHiddenDirective() const
static bool isDiscardableIfUnused(LinkageTypes Linkage)
Whether the definition of this global may be discarded if it is not used in its compilation unit...
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
SectionKind - This is a simple POD value that classifies the properties of a section.
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
const Triple & getTargetTriple() const
bool useAssignmentForEHBegin() const
bool hasLinkerPrivateGlobalPrefix() const
static void PrintChildLoopComment(raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber)
PrintChildLoopComment - Print comments about child loops within the loop for this basic block...
self_iterator getIterator()
Ty & getObjFileInfo()
Keep track of various per-function pieces of information for backends that would like to do so...
Constant Vector Declarations.
virtual void EmitFunctionDescriptor()
bool usesMorestackAddr() const
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
bool hasSubsectionsViaSymbols() const
void emitFrameAlloc(const MachineInstr &MI)
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
const Target & getTarget() const
static const char *const EHTimerName
bool hasWeakDefDirective() const
bool isSplat(unsigned SplatSizeInBits) const
Check if the APInt consists of a repeated bit pattern.
void emitStackMaps(StackMaps &SM)
Emit the stack maps.
bool hasAddressTaken() const
Test whether this block is potentially the target of an indirect branch.
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
virtual const MCExpr * getIndirectSymViaGOTPCRel(const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV, int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const
Get the target specific PC relative GOT entry relocation.
pred_iterator pred_begin()
Abstract base class for all machine specific constantpool value subclasses.
static void emitGlobalConstantVector(const DataLayout &DL, const ConstantVector *CV, AsmPrinter &AP)
Optional< unsigned > getFoldedSpillSize(const TargetInstrInfo *TII) const
Return a valid size if the instruction is a folded spill instruction.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
virtual void markFunctionEnd()
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Windows x64, Windows Itanium (IA-64)
StringRef OperationEncodingString(unsigned Encoding)
unsigned ForceDwarfFrameSection
Emit DWARF debug frame section.
static void PrintParentLoopComment(raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber)
PrintParentLoopComment - Print comments about parent loops of this one.
This struct is a compact representation of a valid (non-zero power of two) alignment.
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
Triple - Helper class for working with autoconf configuration names.
MCSection * getDrectveSection() const
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
DILocalScope * getNonLexicalBlockFileScope() const
Get the first non DILexicalBlockFile scope of this scope.
void serializeToStackMapSection()
If there is any stack map data, create a stack map section and serialize the map info into it...
unsigned getPointerSize(unsigned AS) const
Get the pointer size for this target.
iterator_range< expr_op_iterator > expr_ops() const
bool isOSAIX() const
Tests whether the OS is AIX.
bool hasWeakLinkage() const
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
const std::vector< MachineConstantPoolEntry > & getConstants() const
const APFloat & getValueAPF() const
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
unsigned getFunctionNumber() const
Return a unique ID for the current function.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
unsigned getNumOperands() const
void emitCFIInstruction(const MachineInstr &MI)
virtual void emitImplicitDef(const MachineInstr *MI) const
Targets can override this to customize the output of IMPLICIT_DEF instructions in verbose mode...
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
ConstMIBundleOperands - Iterate over all operands in a const bundle of machine instructions.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
virtual const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the l...
unsigned Alignment
The required alignment for this entry.
This is the shared class of boolean and integer constants.
MCSymbol * CurrentFnDescSym
The symbol for the current function descriptor on AIX.
virtual TargetLoweringObjectFile * getObjFileLowering() const
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
static const char *const CodeViewLineTablesGroupDescription
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
MCSymbol * getSymbol(const GlobalValue *GV) const
const MCSymbol & getSymbol() const
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
virtual void EmitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Keep one copy of function when linking (inline)
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
StringRef getAsString() const
If this array is isString(), then this method returns the array as a StringRef.
Module.h This file contains the declarations for the Module class.
void beginModule()
Emit all Dwarf sections that should come prior to the content.
unsigned EmitAddrsig
Emit address-significance table.
Information about stack frame layout on the target.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
bool EmitSpecialLLVMGlobal(const GlobalVariable *GV)
Check to see if the specified global is a special global used by LLVM.
static SectionKind getReadOnlyWithRel()
uint64_t getSizeInBytes() const
StringRef str()
Return a StringRef for the vector contents.
bool usesMetadata() const
If set, appropriate metadata tables must be emitted by the back-end (assembler, JIT, or otherwise).
bool hasGlobalUnnamedAddr() const
void emitInt32(int Value) const
Emit a long directive and value.
void print(raw_ostream &OS, bool isSigned) const
MachineDominatorTree * MDT
This is a pointer to the current MachineLoopInfo.
unsigned pred_size() const
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
unsigned getPreferredAlignment(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
This file contains constants used for implementing Dwarf debug support.
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
Target - Wrapper for Target specific information.
Class for arbitrary precision integers.
ConstantArray - Constant Array Declarations.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1', drop it.
virtual void EmitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
MCSymbol * getCurExceptionSym()
LinkageTypes
An enumeration for the kinds of linkage for global values.
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
void setPreservesAll()
Set by analyses that do not transform their input at all.
iterator_range< user_iterator > users()
bool useIntegratedAssembler() const
Return true if assembly (inline or otherwise) should be parsed.
unsigned getNumElements() const
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
FunctionNumber(functionNumber)
const MachineBasicBlock * getParent() const
MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation for ELF targets.
static bool emitDebugLabelComment(const MachineInstr *MI, AsmPrinter &AP)
This method handles the target-independent form of DBG_LABEL, returning true if it was able to do so...
Iterators for registry entries.
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
const Comdat * getComdat() const
LoopT * getParentLoop() const
MachineLoopInfo * MLI
This is a pointer to the current MachineLoopInfo.
Representation of each machine instruction.
static const char *const CFGuardName
static void emitGlobalConstantImpl(const DataLayout &DL, const Constant *C, AsmPrinter &AP, const Constant *BaseCV=nullptr, uint64_t Offset=0)
void emitInitialRawDwarfLocDirective(const MachineFunction &MF)
Emits inital debug location directive.
void EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const
This emits linkage information about GVSym based on GV, if this is supported by the target...
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
GCStrategy describes a garbage collector algorithm's code generation requirements, and provides overridable hooks for those needs which cannot be abstractly described.
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
bool isFunctionTy() const
True if this is an instance of FunctionType.
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
uint64_t getElementOffset(unsigned Idx) const
SequentialType * getType() const
Specialize the getType() method to always return a SequentialType, which reduces the amount of castin...
APFloat getElementAsAPFloat(unsigned i) const
If this is a sequential container of floating point type, return the specified element as an APFloat...
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
iterator begin() const
begin/end - Iterators for used strategies.
void print(raw_ostream &O, bool IsForDebug=false, bool NoDetails=false) const
Print the current type.
bool isEHPad() const
Returns true if the block is a landing pad.
Linkage
Describes symbol linkage.
StringRef getValueAsString() const
Return the attribute's value as a string.
Represents a single loop in the control flow graph.
bool isPositionIndependent() const
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
VectorType * getType() const
Specialize the getType() method to always return a VectorType, which reduces the amount of casting ne...
.type _foo, STT_FUNC # aka
MCSymbol * GetJTSetSymbol(unsigned UID, unsigned MBBID) const
Return the symbol for the specified jump table .set FIXME: privatize to AsmPrinter.
StringRef getName() const
Return a constant reference to the value's name.
virtual ~AsmPrinterHandler()
Pin vtable to this file.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Windows Exception Handling.
static unsigned getNumGlobalVariableUses(const Constant *C)
Compute the number of Global Variables that uses a Constant.
virtual const TargetFrameLowering * getFrameLowering() const
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
Generic base class for all target subtargets.
SectionKind getSectionKind(const DataLayout *DL) const
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
static gcp_map_type & getGCMap(void *&P)
static const MCBinaryExpr * createMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Emit something like ".long Hi-Lo" where the size in bytes of the directive is specified by Size and H...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getValueType() const
static const char *const CFGuardDescription
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
const Constant * getIndirectSymbol() const
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
TypeSize getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
virtual void EmitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
MachineBlockFrequencyInfo * MBFI
const Module * getModule() const
bool hasLabelMustBeEmitted() const
Test whether this block must have its label emitted.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
const GlobalObject * getBaseObject() const
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
StringRef getName() const
getName - Get the symbol name.
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
DILocalScope * getScope() const
Get the local scope for this label.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool needsFunctionDescriptors() const
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
void stable_sort(R &&Range)
A raw_ostream that writes to an std::string.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
MCSymbol * getMCSymbol() const
void EmitGlobalConstant(const DataLayout &DL, const Constant *CV)
Print a general LLVM constant to the .s file.
void emitInt8(int Value) const
Emit a byte directive and value.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
JTEntryKind getEntryKind() const
static const unsigned Nop
Instruction opcodes emitted via means other than CodeGen.
bool isThreadLocal() const
bool hasInitializer() const
Definitions have initializers, declarations don't.
MachineLoop * getLoopFor(const MachineBasicBlock *BB) const
Return the innermost loop that BB lives in.
Windows CE ARM, PowerPC, SH3, SH4.
static const char *const DbgTimerName
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
ExceptionHandling getExceptionHandlingType() const
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
This class implements an extremely fast bulk output stream that can only output to a stream...
Primary interface to the complete machine description for the target machine.
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
const DataLayout & getDataLayout() const
Return information about data layout.
Type * getElementType() const
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
virtual MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const
iterator_range< global_iterator > globals()
MachineOptimizationRemarkEmitter * ORE
Optimization remark emitter.
bool hasOneUse() const
Return true if there is exactly one user of this value.
StringRef - Represent a constant reference to a string, i.e.
virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the start of a basic block.
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
APInt bitcastToAPInt() 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...
unsigned getNumElements() const
Return the number of elements in the array or vector.
DWARF-like instruction based exceptions.
Register getReg() const
getReg - Returns the register number.
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
const MCSection * getCurrentSection() const
Return the current section we are emitting to.
void EmitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition=true) const
This emits visibility information about symbol, if this is supported by the target.
unsigned getOpcode() const
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
DILocalScope * getScope() const
Get the local scope for this variable.
VersionTuple getSDKVersion() const
Get the build SDK version metadata.
unsigned getNumOperands() const
Return number of MDNode operands.
void emit(int, MCStreamer *, const MCSymbol *) const
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineOperand & getOperand(unsigned i) const
const ConstantInt * getCImm() const
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isNoOpWithoutInvoke(EHPersonality Pers)
Return true if this personality may be safely removed if there are no invoke instructions remaining i...
MCSymbolAttr getHiddenDeclarationVisibilityAttr() const
static SectionKind getReadOnly()
MCSymbol * createTempSymbol(const Twine &Name) const
MCSymbolAttr getProtectedVisibilityAttr() const
StructType * getType() const
Specialization - reduce amount of casting.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
void emitStackSizeSection(const MachineFunction &MF)
virtual const MCExpr * getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI, MCContext &Ctx) const
This returns the relocation base for the given PIC jumptable, the same as getPICJumpTableRelocBase, but as an MCExpr.
PointerType * getType() const
Global values are always pointers.
bool supportIndirectSymViaGOTPCRel() const
Target supports replacing a data "PC"-relative access to a symbol through another symbol...
Wrapper class representing virtual and physical registers.
void emitInt16(int Value) const
Emit a short directive and value.
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
bool isString(unsigned CharSize=8) const
This method returns true if this is an array of CharSize integers.
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)