Go to the documentation of this file.
42 #include "llvm/Config/llvm-config.h"
73 #include <type_traits>
81 #define DEBUG_TYPE "codegen"
84 "align-all-functions",
85 cl::desc(
"Force the alignment of all functions in log2 format (e.g. 4 "
86 "means align on 16B boundaries)."),
94 case P::FailedISel:
return "FailedISel";
95 case P::IsSSA:
return "IsSSA";
96 case P::Legalized:
return "Legalized";
97 case P::NoPHIs:
return "NoPHIs";
98 case P::NoVRegs:
return "NoVRegs";
99 case P::RegBankSelected:
return "RegBankSelected";
100 case P::Selected:
return "Selected";
101 case P::TracksLiveness:
return "TracksLiveness";
102 case P::TiedOpsRewritten:
return "TiedOpsRewritten";
103 case P::FailsVerification:
return "FailsVerification";
104 case P::TracksDebugUserValues:
return "TracksDebugUserValues";
111 if (!
F.hasFnAttribute(Attribute::SafeStack))
115 dyn_cast_or_null<MDTuple>(
F.getMetadata(LLVMContext::MD_annotation));
117 if (!Existing || Existing->getNumOperands() != 2)
120 auto *MetadataName =
"unsafe-stack-size";
121 if (
auto &
N = Existing->getOperand(0)) {
122 if (cast<MDString>(
N.get())->getString() == MetadataName) {
123 if (
auto &
Op = Existing->getOperand(1)) {
124 auto Val = mdconst::extract<ConstantInt>(
Op)->getZExtValue();
132 void MachineFunction::Delegate::anchor() {}
135 const char *Separator =
"";
139 OS << Separator << getPropertyName(static_cast<Property>(
I));
157 if (
auto MA =
F.getFnStackAlign())
166 FunctionNumber = FunctionNum;
180 void MachineFunction::init() {
216 JumpTableInfo =
nullptr;
229 "Can't create a MachineFunction using a Module with a "
230 "Target-incompatible DataLayout attached\n");
233 std::make_unique<PseudoSourceValueManager>(*(
getSubtarget().
241 void MachineFunction::clear() {
248 I->Insts.clearAndLeakNodesUnsafely();
249 MBBNumbering.clear();
251 InstructionRecycler.clear(Allocator);
252 OperandRecycler.
clear(Allocator);
253 BasicBlockRecycler.clear(Allocator);
254 CodeViewAnnotations.clear();
257 RegInfo->~MachineRegisterInfo();
265 FrameInfo->~MachineFrameInfo();
272 JumpTableInfo->~MachineJumpTableInfo();
277 WinEHInfo->~WinEHFuncInfo();
282 WasmEHInfo->~WasmEHFuncInfo();
295 if (JumpTableInfo)
return JumpTableInfo;
297 JumpTableInfo =
new (Allocator)
299 return JumpTableInfo;
313 FrameInstructions.push_back(Inst);
314 return FrameInstructions.size() - 1;
322 if (
empty()) { MBBNumbering.clear();
return; }
330 unsigned BlockNo = 0;
332 BlockNo = std::prev(
MBBI)->getNumber() + 1;
339 "MBB number mismatch!");
344 if (MBBNumbering[BlockNo])
345 MBBNumbering[BlockNo]->setNumber(-1);
347 MBBNumbering[BlockNo] = &*
MBBI;
354 assert(BlockNo <= MBBNumbering.size() &&
"Mismatch!");
355 MBBNumbering.resize(BlockNo);
368 std::prev(
MBBI)->setIsEndSection();
378 return new (InstructionRecycler.Allocate<
MachineInstr>(Allocator))
386 return new (InstructionRecycler.Allocate<
MachineInstr>(Allocator))
398 if (FirstClone ==
nullptr) {
404 if (!
I->isBundledWithSucc())
425 assert((!
MI->isCandidateForCallSiteEntry() ||
426 CallSitesInfo.
find(
MI) == CallSitesInfo.
end()) &&
427 "Call site info was not updated!");
435 InstructionRecycler.Deallocate(Allocator,
MI);
452 MBB->~MachineBasicBlock();
453 BasicBlockRecycler.Deallocate(Allocator,
MBB);
461 return new (Allocator)
463 SSID, Ordering, FailureOrdering);
471 return new (Allocator)
473 Ordering, FailureOrdering);
478 return new (Allocator)
486 return new (Allocator)
494 int64_t Offset,
LLT Ty) {
536 return MachineInstr::ExtraInfo::create(Allocator, MMOs, PreInstrSymbol,
537 PostInstrSymbol, HeapAllocMarker);
543 Dest[
Name.size()] = 0;
551 memset(
Mask, 0, Size *
sizeof(
Mask[0]));
558 return {AllocMask,
Mask.size()};
561 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
572 OS <<
"# Machine code for function " <<
getName() <<
": ";
577 FrameInfo->
print(*
this, OS);
581 JumpTableInfo->
print(OS);
589 OS <<
"Function Live Ins: ";
595 if (std::next(
I) !=
E)
603 for (
const auto &
BB : *
this) {
606 BB.print(OS, MST, Indexes,
true);
609 OS <<
"\n# End machine code for function " <<
getName() <<
".\n\n";
626 return (
"CFG for '" +
F->getName() +
"' function").str();
638 OSS <<
": " <<
BB->getName();
643 if (OutStr[0] ==
'\n') OutStr.erase(OutStr.begin());
646 for (
unsigned i = 0;
i != OutStr.length(); ++
i)
647 if (OutStr[
i] ==
'\n') {
649 OutStr.insert(OutStr.begin()+
i+1,
'l');
662 errs() <<
"MachineFunction::viewCFG is only available in debug builds on "
663 <<
"systems with Graphviz or gv!\n";
672 errs() <<
"MachineFunction::viewCFGOnly is only available in debug builds on "
673 <<
"systems with Graphviz or gv!\n";
693 "Register class mismatch!");
705 bool isLinkerPrivate)
const {
707 assert(JumpTableInfo &&
"No jump tables");
708 assert(JTI < JumpTableInfo->getJumpTables().
size() &&
"Invalid JTI!");
711 :
DL.getPrivateGlobalPrefix();
730 unsigned N = LandingPads.size();
731 for (
unsigned i = 0;
i <
N; ++
i) {
738 return LandingPads[
N];
754 if (
const auto *LPI = dyn_cast<LandingPadInst>(FirstI)) {
756 dyn_cast<Function>(
F.getPersonalityFn()->stripPointerCasts()))
759 if (LPI->isCleanup())
765 for (
unsigned I = LPI->getNumClauses();
I != 0; --
I) {
766 Value *Val = LPI->getClause(
I - 1);
767 if (LPI->isCatch(
I - 1)) {
772 auto *CVal = cast<Constant>(Val);
774 for (
const Use &U : CVal->operands())
775 FilterList.push_back(cast<GlobalValue>(U->stripPointerCasts()));
781 }
else if (
const auto *CPI = dyn_cast<CatchPadInst>(FirstI)) {
782 for (
unsigned I = CPI->getNumArgOperands();
I != 0; --
I) {
788 assert(isa<CleanupPadInst>(FirstI) &&
"Invalid landingpad!");
791 return LandingPadLabel;
804 std::vector<unsigned> IdsInFilter(TyInfo.
size());
805 for (
unsigned I = 0,
E = TyInfo.
size();
I !=
E; ++
I)
811 bool TidyIfNoBeginLabels) {
812 for (
unsigned i = 0;
i != LandingPads.size(); ) {
822 LandingPads.erase(LandingPads.begin() +
i);
826 if (TidyIfNoBeginLabels) {
827 for (
unsigned j = 0,
e = LandingPads[
i].BeginLabels.size();
j !=
e; ++
j) {
830 if ((BeginLabel->
isDefined() || (LPMap && (*LPMap)[BeginLabel] != 0)) &&
831 (EndLabel->
isDefined() || (LPMap && (*LPMap)[EndLabel] != 0)))
841 if (LandingPads[
i].BeginLabels.empty()) {
842 LandingPads.erase(LandingPads.begin() +
i);
882 LPadToCallSiteMap[Sym].append(Sites.
begin(), Sites.
end());
886 for (
unsigned i = 0,
N = TypeInfos.size();
i !=
N; ++
i)
887 if (TypeInfos[
i] == TI)
return i + 1;
889 TypeInfos.push_back(TI);
890 return TypeInfos.size();
897 for (
unsigned i : FilterEnds) {
898 unsigned j = TyIds.size();
901 if (FilterIds[--
i] != TyIds[--
j])
912 int FilterID = -(1 + FilterIds.size());
913 FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
915 FilterEnds.push_back(FilterIds.size());
916 FilterIds.push_back(0);
922 assert(
MI->isCandidateForCallSiteEntry() &&
923 "Call site info refers only to call (MI) candidates");
925 if (!
Target.Options.EmitCallSiteInfo)
926 return CallSitesInfo.
end();
927 return CallSitesInfo.
find(
MI);
937 if (BMI.isCandidateForCallSiteEntry())
944 assert(
MI->shouldUpdateCallSiteInfo() &&
945 "Call site info refers only to call (MI) candidates or "
946 "candidates inside bundles");
950 if (CSIt == CallSitesInfo.
end())
952 CallSitesInfo.
erase(CSIt);
958 "Call site info refers only to call (MI) candidates or "
959 "candidates inside bundles");
961 if (!New->isCandidateForCallSiteEntry())
966 if (CSIt == CallSitesInfo.
end())
970 CallSitesInfo[New] = CSInfo;
976 "Call site info refers only to call (MI) candidates or "
977 "candidates inside bundles");
979 if (!New->isCandidateForCallSiteEntry())
984 if (CSIt == CallSitesInfo.
end())
988 CallSitesInfo.
erase(CSIt);
989 CallSitesInfo[New] = CSInfo;
1009 unsigned MaxOperand) {
1021 for (
unsigned int I = 0;
I < MaxOperand; ++
I) {
1023 auto &NewMO = New.getOperand(
I);
1026 if (!OldMO.isReg() || !OldMO.isDef())
1030 unsigned NewInstrNum = New.getDebugInstrNum();
1032 std::make_pair(NewInstrNum,
I));
1044 if (
auto CopyDstSrc =
TII.isCopyInstr(
MI)) {
1045 Dest = CopyDstSrc->Destination->getReg();
1048 Dest =
MI.getOperand(0).getReg();
1051 auto CacheIt = DbgPHICache.find(Dest);
1052 if (CacheIt != DbgPHICache.end())
1053 return CacheIt->second;
1056 auto OperandPair = salvageCopySSAImpl(
MI);
1057 DbgPHICache.insert({Dest, OperandPair});
1083 auto GetRegAndSubreg =
1084 [&](
const MachineInstr &Cpy) -> std::pair<Register, unsigned> {
1088 OldReg = Cpy.getOperand(0).getReg();
1089 NewReg = Cpy.getOperand(1).getReg();
1090 SubReg = Cpy.getOperand(1).getSubReg();
1091 }
else if (Cpy.isSubregToReg()) {
1092 OldReg = Cpy.getOperand(0).getReg();
1093 NewReg = Cpy.getOperand(2).getReg();
1094 SubReg = Cpy.getOperand(3).getImm();
1096 auto CopyDetails = *
TII.isCopyInstr(Cpy);
1100 NewReg = Src.getReg();
1101 SubReg = Src.getSubReg();
1111 auto State = GetRegAndSubreg(
MI);
1112 auto CurInst =
MI.getIterator();
1116 if (!State.first.isVirtual())
1121 SubregsSeen.push_back(State.second);
1130 State = GetRegAndSubreg(Inst);
1137 auto ApplySubregisters =
1139 for (
unsigned Subreg :
reverse(SubregsSeen)) {
1141 unsigned NewInstrNumber = getNewDebugInstrNum();
1144 makeDebugValueSubstitution({NewInstrNumber, 0},
P, Subreg);
1147 P = {NewInstrNumber, 0};
1154 if (State.first.isVirtual()) {
1157 for (
auto &MO : Inst->
operands()) {
1158 if (!MO.isReg() || !MO.isDef() || MO.getReg() != State.first)
1160 return ApplySubregisters(
1169 assert(CurInst->isCopyLike() ||
TII.isCopyInstr(*CurInst));
1170 State = GetRegAndSubreg(*CurInst);
1173 auto RMII = CurInst->getReverseIterator();
1174 auto PrevInstrs =
make_range(RMII, CurInst->getParent()->instr_rend());
1175 for (
auto &ToExamine : PrevInstrs) {
1176 for (
auto &MO : ToExamine.operands()) {
1178 if (!MO.isReg() || !MO.isDef() ||
1182 return ApplySubregisters(
1183 {ToExamine.getDebugInstrNum(), ToExamine.getOperandNo(&MO)});
1200 TII.get(TargetOpcode::DBG_PHI));
1202 unsigned NewNum = getNewDebugInstrNum();
1204 return ApplySubregisters({NewNum, 0u});
1213 MI.getOperand(0).setReg(0);
1214 MI.getOperand(1).ChangeToRegister(0,
false);
1218 for (
auto &
MBB : *
this) {
1219 for (
auto &
MI :
MBB) {
1220 if (!
MI.isDebugRef() || !
MI.getOperand(0).isReg())
1229 MakeUndefDbgValue(
MI);
1241 MI.getOperand(0).ChangeToImmediate(Result.first);
1242 MI.getOperand(1).setImm(Result.second);
1245 unsigned OperandIdx = 0;
1246 for (
const auto &MO :
DefMI.operands()) {
1247 if (MO.isReg() && MO.isDef() && MO.getReg() ==
Reg)
1254 unsigned ID =
DefMI.getDebugInstrNum();
1255 MI.getOperand(0).ChangeToImmediate(
ID);
1256 MI.getOperand(1).setImm(OperandIdx);
1271 if (
F.hasFnAttribute(Attribute::OptimizeNone))
1330 const std::vector<MachineBasicBlock*> &DestBBs) {
1331 assert(!DestBBs.empty() &&
"Cannot create an empty jump table!");
1333 return JumpTables.size()-1;
1340 assert(Old != New &&
"Not making a change?");
1341 bool MadeChange =
false;
1342 for (
size_t i = 0,
e = JumpTables.size();
i !=
e; ++
i)
1349 bool MadeChange =
false;
1351 auto removeBeginItr =
std::remove(JTE.MBBs.begin(), JTE.MBBs.end(),
MBB);
1352 MadeChange |= (removeBeginItr != JTE.MBBs.end());
1353 JTE.MBBs.erase(removeBeginItr, JTE.MBBs.end());
1363 assert(Old != New &&
"Not making a change?");
1364 bool MadeChange =
false;
1375 if (JumpTables.empty())
return;
1377 OS <<
"Jump Tables:\n";
1379 for (
unsigned i = 0,
e = JumpTables.size();
i !=
e; ++
i) {
1390 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1402 void MachineConstantPoolValue::anchor() {}
1405 return DL.getTypeAllocSize(Ty);
1410 return Val.MachineCPVal->getSizeInBytes(
DL);
1411 return DL.getTypeAllocSize(
Val.ConstVal->getType());
1417 return Val.ConstVal->needsDynamicRelocation();
1443 if (
C.isMachineConstantPoolEntry()) {
1444 Deleted.insert(
C.Val.MachineCPVal);
1445 delete C.Val.MachineCPVal;
1458 if (
A ==
B)
return true;
1462 if (
A->getType() ==
B->getType())
return false;
1465 if (isa<StructType>(
A->getType()) || isa<ArrayType>(
A->getType()) ||
1466 isa<StructType>(
B->getType()) || isa<ArrayType>(
B->getType()))
1470 uint64_t StoreSize =
DL.getTypeStoreSize(
A->getType());
1471 if (StoreSize !=
DL.getTypeStoreSize(
B->getType()) || StoreSize > 128)
1480 if (isa<PointerType>(
A->getType()))
1483 else if (
A->getType() != IntTy)
1486 if (isa<PointerType>(
B->getType()))
1489 else if (
B->getType() != IntTy)
1500 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1506 if (!
Constants[
i].isMachineConstantPoolEntry() &&
1519 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1526 MachineCPVsSharingEntries.insert(V);
1527 return (
unsigned)Idx;
1537 OS <<
"Constant Pool:\n";
1539 OS <<
" cp#" <<
i <<
": ";
1540 if (
Constants[
i].isMachineConstantPoolEntry())
1543 Constants[
i].Val.ConstVal->printAsOperand(OS,
false);
1544 OS <<
", align=" <<
Constants[
i].getAlign().value();
1549 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
std::string getNodeLabel(const MachineBasicBlock *Node, const MachineFunction *Graph)
unsigned getDebugInstrNum()
Fetch the instruction number of this MachineInstr.
static SectionKind getReadOnlyWithRel()
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
def_iterator def_begin(Register RegNo) const
unsigned getConstantPoolIndex(const Constant *C, Align Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one.
This is an optimization pass for GlobalISel generic memory operations.
bool RemoveMBBFromJumpTables(MachineBasicBlock *MBB)
RemoveMBBFromJumpTables - If MBB is present in any jump tables, remove it.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
A parsed version of the target data layout string in and methods for querying it.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
std::pair< unsigned, unsigned > DebugInstrOperandPair
Pair of instruction number and operand number.
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Context object for machine code objects.
MCContext & getContext() const
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
virtual const TargetInstrInfo * getInstrInfo() const
void assignBeginEndSections()
Assign IsBeginSection IsEndSection fields for basic blocks in this function.
A raw_ostream that writes to an std::string.
Target - Wrapper for Target specific information.
def_instr_iterator def_instr_begin(Register RegNo) const
MaybeAlign getFnStackAlign() const
Return the stack alignment for the function.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool useDebugInstrRef() const
Returns true if the function's variable locations should be tracked with instruction referencing.
static cl::opt< unsigned > AlignAllFunctions("align-all-functions", cl::desc("Force the alignment of all functions in log2 format (e.g. 4 " "means align on 16B boundaries)."), cl::init(0), cl::Hidden)
Align getPrefFunctionAlignment() const
Return the preferred function alignment.
MCSymbol * LandingPadLabel
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
bool livein_empty() const
SmallVector< SEHHandler, 1 > SEHHandlers
void copyCallSiteInfo(const MachineInstr *Old, const MachineInstr *New)
Copy the call site info from Old to \ New.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
Reg
All possible values of the reg field in the ModR/M byte.
const TargetRegisterInfo * getTargetRegisterInfo() const
union llvm::MachineConstantPoolEntry::@188 Val
The constant itself.
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist,...
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
void bundleWithPred()
Bundle this instruction with its predecessor.
const MachineBasicBlock & back() const
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool erase(const KeyT &Val)
bool hasDebugInfo() const
Returns true if valid debug info is present.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void moveCallSiteInfo(const MachineInstr *Old, const MachineInstr *New)
Move the call site info from Old to \New call site info.
Abstract base class for all machine specific constantpool value subclasses.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL, bool NoImplicit=false)
CreateMachineInstr - Allocate a new MachineInstr.
virtual void MF_HandleRemoval(MachineInstr &MI)=0
Callback before a removal. This should not modify the MI directly.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
static SectionKind getMergeableConst16()
A description of a memory reference used in the backend.
Register getLiveInVirtReg(MCRegister PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in virtual r...
OutputIt copy(R &&Range, OutputIt Out)
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
Map the landing pad's EH symbol to the call site indexes.
@ EK_BlockAddress
EK_BlockAddress - Each entry is a plain address of block, e.g.
static unsigned getFnStackAlignment(const TargetSubtargetInfo *STI, const Function &F)
unsigned peekDebugInstrNum() const
Examine the instruction number of this MachineInstr.
void addSEHCatchHandler(MachineBasicBlock *LandingPad, const Function *Filter, const BlockAddress *RecoverBA)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
void incorporateFunction(const Function &F)
Incorporate the given function.
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
MachineInstr & cloneMachineInstrBundle(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig)
Clones instruction or the whole instruction bundle Orig and insert into MBB before InsertBefore.
AAMDNodes getAAInfo() const
Return the AA tags for the memory reference.
@ EK_Custom32
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
Manage lifetime of a slot tracker for printing IR.
unsigned const TargetRegisterInfo * TRI
const Function * FilterOrFinally
Filter or finally function. Null indicates a catch-all.
static const char * getPropertyName(MachineFunctionProperties::Property Prop)
BasicBlockListType::iterator iterator
iterator erase(iterator where)
LLVM Basic Block Representation.
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
MachineBasicBlock::instr_iterator getBundleEnd(MachineBasicBlock::instr_iterator I)
Returns an iterator pointing beyond the bundle containing I.
bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTables - If Old is the target of any jump tables, update the jump tables to branch to...
JTEntryKind getEntryKind() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void dump() const
dump - Call to stderr.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
static SectionKind getReadOnly()
const MachinePointerInfo & getPointerInfo() const
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void substituteDebugValuesForInst(const MachineInstr &Old, MachineInstr &New, unsigned MaxOperand=UINT_MAX)
Create substitutions for any tracked values in Old, to point at New.
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
< i1 > br i1 label label bb bb
const MachineBasicBlock & front() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
TargetInstrInfo - Interface to description of machine instruction set.
Align getBaseAlign() const
Return the minimum known alignment in bytes of the base address, without the offset.
SmallVector< MCSymbol *, 1 > EndLabels
Itanium Name Demangler i e convert the string _Z1fv into f()". You can also use the CRTP base ManglingParser to perform some simple analysis on the mangled name
void ensureMaxAlignment(Align Alignment)
Make sure the function is at least Align bytes aligned.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
const Value * getValue() const
Return the base address of the memory access.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
(vector float) vec_cmpeq(*A, *B) C
const MachineOperand & getOperand(unsigned i) const
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
unsigned ForceDwarfFrameSection
Emit DWARF debug frame section.
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the catch typeinfo for a landing pad.
Align getMinFunctionAlignment() const
Return the minimum function alignment.
Align getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
std::vector< MachineBasicBlock * > MBBs
MBBs - The vector of basic blocks from which to create the jump table.
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
virtual ~MachineFunctionInfo()
void deleteMachineInstr(MachineInstr *MI)
DeleteMachineInstr - Delete the given MachineInstr.
const MachineFunctionProperties & getProperties() const
Get the function properties.
std::vector< int > TypeIds
const HexagonInstrInfo * TII
void setDebugInstrNumberingCount(unsigned Num)
Set value of DebugInstrNumberingCount field.
SectionKind getSectionKind(const DataLayout *DL) const
void deleteMachineBasicBlock(MachineBasicBlock *MBB)
DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
Describe properties that are true of each instruction in the target description file.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MachineOperand class - Representation of each machine instruction operand.
MachineFunctionProperties & set(Property P)
This class contains meta information specific to a module.
bool shouldUpdateCallSiteInfo() const
Return true if copying, moving, or erasing this instruction requires updating Call Site Info (see cop...
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
This class implements an extremely fast bulk output stream that can only output to a stream.
bool hasPersonalityFn() const
Check whether this function has a personality function.
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
Provide the filter typeinfo for a landing pad.
Printable printJumpTableEntryReference(unsigned Idx)
Prints a jump table entry reference.
livein_iterator livein_begin() const
static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B, const DataLayout &DL)
Test whether the given two constants can be allocated the same constant pool entry.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
This struct is a compact representation of a valid (non-zero power of two) alignment.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID for this memory operation.
void tidyLandingPads(DenseMap< MCSymbol *, uintptr_t > *LPMap=nullptr, bool TidyIfNoBeginLabels=true)
Remap landing pad labels and remove any deleted landing pads.
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
Provide the begin and end labels of an invoke style call and associate it with a try landing pad bloc...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static const MachineInstr * getCallInstr(const MachineInstr *MI)
Return the call machine instruction or find a call within bundle.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
@ EK_LabelDifference32
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table.
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
static std::string getGraphName(const MachineFunction *F)
MachineModuleInfo & getMMI() const
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
Implements a dense probed hash-table based set.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
AtomicOrdering
Atomic ordering for LLVM's memory model.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
@ EK_GPRel64BlockAddress
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative,...
This is an important base class in LLVM.
bool regsOverlap(Register RegA, Register RegB) const
Returns true if the two registers are equal or alias each other.
virtual unsigned getSizeInBytes(const DataLayout &DL) const
SmallVector< MCSymbol *, 1 > BeginLabels
Representation of each machine instruction.
MachineInstr::ExtraInfo * createMIExtraInfo(ArrayRef< MachineMemOperand * > MMOs, MCSymbol *PreInstrSymbol=nullptr, MCSymbol *PostInstrSymbol=nullptr, MDNode *HeapAllocMarker=nullptr)
Allocate and construct an extra info structure for a MachineInstr.
Module * getParent()
Get the module that this global value is contained inside of...
void addSEHCleanupHandler(MachineBasicBlock *LandingPad, const Function *Cleanup)
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
multiplies can be turned into SHL s
bool debuginfoShouldUseDebugInstrRef(const Triple &T)
This class contains a discriminated union of information about pointers in memory operands,...
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch,...
Represent subnormal handling kind for floating point instruction inputs and outputs.
initializer< Ty > init(const Ty &Val)
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
JTEntryKind
JTEntryKind - This enum indicates how each entry of the jump table is represented and emitted.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void finalizeDebugInstrRefs()
Finalise any partially emitted debug instructions.
void setIsEndSection(bool V=true)
iterator find(const_arg_type_t< KeyT > Val)
Flags
Flags values. These may be or'd together.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
MachineBasicBlock * LandingPadBlock
Align getPointerABIAlignment(unsigned AS) const
Layout pointer alignment.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
AtomicOrdering getSuccessOrdering() const
Return the atomic ordering requirements for this memory operation.
void makeDebugValueSubstitution(DebugInstrOperandPair, DebugInstrOperandPair, unsigned SubReg=0)
Create a substitution between one <instr,operand> value to a different, new value.
Register getReg() const
getReg - Returns the register number.
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
static const HTTPClientCleanup Cleanup
MachinePointerInfo getWithOffset(int64_t O) const
void clear(AllocatorType &Allocator)
Release all the tracked allocations to the allocator.
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry.
Register addLiveIn(MCRegister PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
The address of a basic block.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
PointerUnion< const Value *, const PseudoSourceValue * > V
This is the IR pointer value for the access, or it is null if unknown.
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
ArrayRef< int > allocateShuffleMask(ArrayRef< int > Mask)
StringRef - Represent a constant reference to a string, i.e.
MachineBasicBlock MachineBasicBlock::iterator MBBI
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const Function * getParent(const Value *V)
MachineBasicBlock::instr_iterator getBundleStart(MachineBasicBlock::instr_iterator I)
Returns an iterator to the first instruction in the bundle containing I.
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
self_iterator getIterator()
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about jump tables.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTable - If Old is a target of the jump tables, update the jump table to branch to New...
MachineFunctionProperties & reset(Property P)
void setUnsafeStackSize(const Function &F, MachineFrameInfo &FrameInfo)
StringRef getName() const
Return a constant reference to the value's name.
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
TargetSubtargetInfo - Generic base class for all target subtargets.
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
unsigned DebugInstrNumberingCount
A count of how many instructions in the function have had numbers assigned to them.
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
unsigned const MachineRegisterInfo * MRI
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Wrapper class representing virtual and physical registers.
int getFilterIDFor(std::vector< unsigned > &TyIds)
Return the id of the filter encoded by TyIds. This is function wide.
static SectionKind getMergeableConst8()
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Align commonAlignment(Align A, Align B)
Returns the alignment that satisfies both alignments.
SectionKind - This is a simple POD value that classifies the properties of a section.
This class is a data container for one entry in a MachineConstantPool.
Function & getFunction()
Return the LLVM function that this machine code represents.
virtual const TargetFrameLowering * getFrameLowering() const
bool needsFrameMoves() const
True if this function needs frame moves for debug or exceptions.
bool isCopyLike() const
Return true if the instruction behaves like a copy.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Iterator for intrusive lists based on ilist_node.
uint64_t value() const
This is a hole in the type system and should not be abused.
uint64_t getSize() const
Return the size in bytes of the memory reference.
@ EK_Inline
EK_Inline - Jump table entries are emitted inline at their point of use.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
void setIsBeginSection(bool V=true)
std::vector< std::pair< MCRegister, Register > >::const_iterator livein_iterator
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream.
MachineJumpTableEntry - One jump table in the jump table info.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
MachineFunction(Function &F, const LLVMTargetMachine &Target, const TargetSubtargetInfo &STI, unsigned FunctionNum, MachineModuleInfo &MMI)
static bool isSimple(Instruction *I)
Constant * getPersonalityFn() const
Get the personality function associated with this function.
void addCleanup(MachineBasicBlock *LandingPad)
Add a cleanup action for a landing pad.
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about constant pool objects.
bool getAlign(const Function &F, unsigned index, unsigned &align)
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
virtual const TargetLowering * getTargetLowering() const
static void deleteNode(NodeTy *V)
virtual int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment)=0
Simple wrapper around std::function<void(raw_ostream&)>.
void setUnsafeStackSize(uint64_t Size)
void addPersonality(const Function *Personality)
Provide the personality function for the exception information.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static SectionKind getMergeableConst4()
MachineInstrBuilder MachineInstrBuilder & DefMI
SmallVector< DebugSubstitution, 8 > DebugValueSubstitutions
Debug value substitutions: a collection of DebugSubstitution objects, recording changes in where a va...
unsigned getNumOperands() const
Retuns the total number of operands.
size_t size() const
size - Get the array size.
Align max(MaybeAlign Lhs, Align Rhs)
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
A raw_ostream that writes to an SmallVector or SmallString.
@ EK_GPRel32BlockAddress
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative,...
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
AtomicOrdering getFailureOrdering() const
For cmpxchg atomic operations, return the atomic ordering requirements when store does not occur.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
This structure is used to retain landing pad info for the current function.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
const static unsigned int DebugOperandMemNumber
A reserved operand number representing the instructions memory operand, for instructions that have a ...
DebugInstrOperandPair salvageCopySSA(MachineInstr &MI, DenseMap< Register, DebugInstrOperandPair > &DbgPHICache)
Find the underlying defining instruction / operand for a COPY instruction while in SSA form.
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad, and extract the exception handling information from the landingpad instruction...
static SectionKind getMergeableConst32()
const MDNode * getRanges() const
Return the range tag for the memory reference.
void dump() const
dump - Call print(cerr) to be called from the debugger.
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.
void eraseCallSiteInfo(const MachineInstr *MI)
Following functions update call site info.
VariableDbgInfoMapTy VariableDbgInfos
livein_iterator livein_end() const
const BlockAddress * RecoverBA
Address of block to recover at. Null for a finally handler.
DOTGraphTraits(bool isSimple=false)
iterator_range< mop_iterator > operands()
LLVM Value Representation.
Flags getFlags() const
Return the raw flags of the source value,.
void Deallocate(const void *Ptr, size_t Size, size_t)
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
Find or create an LandingPadInfo for the specified MachineBasicBlock.
DebugInstrOperandPair salvageCopySSAImpl(MachineInstr &MI)
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
unsigned getSizeInBytes(const DataLayout &DL) const
A Use represents the edge between a Value definition and its users.
Wrapper class representing physical registers. Should be passed by value.
const PseudoSourceValue * getPseudoValue() const
virtual void MF_HandleInsertion(MachineInstr &MI)=0
Callback after an insertion. This should not modify the MI directly.