46#define DEBUG_TYPE "early-ifcvt"
52 cl::desc(
"Maximum number of instructions per speculated block."));
59STATISTIC(NumDiamondsConv,
"Number of diamonds converted");
61STATISTIC(NumTrianglesConv,
"Number of triangles converted");
105 bool isTriangle()
const {
return TBB ==
Tail || FBB ==
Tail; }
108 MachineBasicBlock *getTPred()
const {
return TBB == Tail ? Head : TBB; }
111 MachineBasicBlock *getFPred()
const {
return FBB == Tail ? Head : FBB; }
118 int CondCycles = 0, TCycles = 0, FCycles = 0;
120 PHIInfo(MachineInstr *phi) : PHI(
phi) {}
131 SmallPtrSet<MachineInstr*, 8> InsertAfter;
134 BitVector ClobberedRegUnits;
137 SparseSet<unsigned> LiveRegUnits;
145 bool canSpeculateInstrs(MachineBasicBlock *
MBB);
149 bool canPredicateInstrs(MachineBasicBlock *
MBB);
153 bool InstrDependenciesAllowIfConv(MachineInstr *
I);
157 void PredicateBlock(MachineBasicBlock *
MBB,
bool ReversePredicate);
160 bool findInsertionPoint();
163 void replacePHIInstrs();
166 void rewritePHIOperands();
170 void clearRepeatedKillFlagsFromTBB(MachineBasicBlock *TBB,
171 MachineBasicBlock *FBB);
175 void init(MachineFunction &MF) {
179 LiveRegUnits.clear();
180 LiveRegUnits.setUniverse(TRI->getNumRegUnits());
181 ClobberedRegUnits.clear();
182 ClobberedRegUnits.resize(TRI->getNumRegUnits());
189 bool canConvertIf(MachineBasicBlock *
MBB,
bool Predicate =
false);
193 void convertIf(SmallVectorImpl<MachineBasicBlock *> &RemoveBlocks,
194 bool Predicate =
false);
218 for (MachineInstr &
MI :
220 if (
MI.isDebugInstr())
244 bool DontMoveAcrossStore =
true;
245 if (!
MI.isSafeToMove(DontMoveAcrossStore)) {
251 if (!InstrDependenciesAllowIfConv(&
MI))
261bool SSAIfConv::InstrDependenciesAllowIfConv(MachineInstr *
I) {
262 for (
const MachineOperand &MO :
I->operands()) {
263 if (MO.isRegMask()) {
274 ClobberedRegUnits.
set(Unit);
285 LLVM_DEBUG(
dbgs() <<
"Can't insert instructions below terminator.\n");
300bool SSAIfConv::canPredicateInstrs(MachineBasicBlock *
MBB) {
315 if (
I->isDebugInstr())
343 if (!InstrDependenciesAllowIfConv(&(*
I)))
350void SSAIfConv::PredicateBlock(MachineBasicBlock *
MBB,
bool ReversePredicate) {
351 auto Condition =
Cond;
352 if (ReversePredicate) {
354 assert(CanRevCond &&
"Reversed predicate is not supported");
361 if (
I->isDebugInstr())
377bool SSAIfConv::findInsertionPoint() {
380 LiveRegUnits.
clear();
388 if (InsertAfter.
count(&*
I)) {
394 for (
const MachineOperand &MO :
I->operands()) {
404 LiveRegUnits.
erase(Unit);
410 while (!Reads.
empty())
412 if (ClobberedRegUnits.
test(Unit))
413 LiveRegUnits.
insert(Unit);
416 if (
I != FirstTerm &&
I->isTerminator())
421 if (!LiveRegUnits.
empty()) {
423 dbgs() <<
"Would clobber";
424 for (
unsigned LRU : LiveRegUnits)
426 dbgs() <<
" live before " << *
I;
445bool SSAIfConv::canConvertIf(MachineBasicBlock *
MBB,
bool Predicate) {
451 MachineBasicBlock *Succ0 = Head->
succ_begin()[0];
452 MachineBasicBlock *Succ1 = Head->
succ_begin()[1];
475 if (!
Tail->livein_empty()) {
488 if (!Predicate && (
Tail->empty() || !
Tail->front().isPHI())) {
502 LLVM_DEBUG(
dbgs() <<
"analyzeBranch didn't find conditional branch.\n");
509 LLVM_DEBUG(
dbgs() <<
"analyzeBranch found an unconditional branch.\n");
515 FBB =
TBB == Succ0 ? Succ1 : Succ0;
519 MachineBasicBlock *TPred = getTPred();
520 MachineBasicBlock *FPred = getFPred();
522 I !=
E &&
I->isPHI(); ++
I) {
524 PHIInfo &PI = PHIs.
back();
526 for (
unsigned i = 1; i != PI.PHI->getNumOperands(); i += 2) {
527 if (PI.PHI->getOperand(i+1).getMBB() == TPred)
528 PI.TReg = PI.PHI->getOperand(i).getReg();
529 if (PI.PHI->getOperand(i+1).getMBB() == FPred)
530 PI.FReg = PI.PHI->getOperand(i).getReg();
532 assert(PI.TReg.isVirtual() &&
"Bad PHI");
533 assert(PI.FReg.isVirtual() &&
"Bad PHI");
536 if (!
TII->canInsertSelect(*Head,
Cond, PI.PHI->getOperand(0).getReg(),
537 PI.TReg, PI.FReg, PI.CondCycles, PI.TCycles,
546 ClobberedRegUnits.
reset();
550 if (FBB !=
Tail && !canPredicateInstrs(FBB))
555 if (FBB !=
Tail && !canSpeculateInstrs(FBB))
561 if (!findInsertionPoint())
578 if (!TReg.isVirtual() || !FReg.
isVirtual())
600 return MO.isReg() && MO.getReg().isPhysical();
605 if (!
TII->produceSameValue(*TDef, *FDef, &
MRI))
611 if (TIdx == -1 || FIdx == -1)
620void SSAIfConv::replacePHIInstrs() {
621 assert(
Tail->pred_size() == 2 &&
"Cannot replace PHIs");
623 assert(FirstTerm != Head->
end() &&
"No terminators");
624 DebugLoc HeadDL = FirstTerm->getDebugLoc();
627 for (PHIInfo &PI : PHIs) {
629 Register DstReg = PI.PHI->getOperand(0).getReg();
633 BuildMI(*Head, FirstTerm, HeadDL,
TII->get(TargetOpcode::COPY), DstReg)
636 TII->insertSelect(*Head, FirstTerm, HeadDL, DstReg,
Cond, PI.TReg,
640 PI.PHI->eraseFromParent();
648void SSAIfConv::rewritePHIOperands() {
650 assert(FirstTerm != Head->
end() &&
"No terminators");
651 DebugLoc HeadDL = FirstTerm->getDebugLoc();
654 for (PHIInfo &PI : PHIs) {
663 Register PHIDst = PI.PHI->getOperand(0).getReg();
664 DstReg =
MRI->createVirtualRegister(
MRI->getRegClass(PHIDst));
665 TII->insertSelect(*Head, FirstTerm, HeadDL,
666 DstReg,
Cond, PI.TReg, PI.FReg);
671 for (
unsigned i = PI.PHI->getNumOperands(); i != 1; i -= 2) {
672 MachineBasicBlock *
MBB = PI.PHI->getOperand(i-1).getMBB();
673 if (
MBB == getTPred()) {
674 PI.PHI->getOperand(i-1).setMBB(Head);
675 PI.PHI->getOperand(i-2).setReg(DstReg);
676 }
else if (
MBB == getFPred()) {
677 PI.PHI->removeOperand(i-1);
678 PI.PHI->removeOperand(i-2);
685void SSAIfConv::clearRepeatedKillFlagsFromTBB(MachineBasicBlock *
TBB,
686 MachineBasicBlock *FBB) {
690 SmallDenseSet<Register> FBBKilledRegs;
691 for (MachineInstr &
MI : FBB->
instrs()) {
692 for (MachineOperand &MO :
MI.operands()) {
693 if (MO.isReg() && MO.isKill() && MO.getReg().isVirtual())
694 FBBKilledRegs.
insert(MO.getReg());
698 if (FBBKilledRegs.
empty())
703 for (MachineOperand &MO :
MI.operands()) {
704 if (MO.isReg() && MO.isKill() && FBBKilledRegs.
contains(MO.getReg()))
715void SSAIfConv::convertIf(SmallVectorImpl<MachineBasicBlock *> &RemoveBlocks,
717 assert(Head &&
Tail &&
TBB && FBB &&
"Call canConvertIf first.");
730 clearRepeatedKillFlagsFromTBB(
TBB, FBB);
735 PredicateBlock(
TBB,
false);
740 PredicateBlock(FBB,
true);
744 bool ExtraPreds =
Tail->pred_size() != 2;
746 rewritePHIOperands();
786 if (
Tail != &
Tail->getParent()->back())
787 Tail->moveAfter(&
Tail->getParent()->back());
803class EarlyIfConverter {
804 const TargetInstrInfo *
TII =
nullptr;
805 const TargetRegisterInfo *
TRI =
nullptr;
806 MCSchedModel SchedModel;
807 MachineRegisterInfo *
MRI =
nullptr;
808 MachineDominatorTree *DomTree =
nullptr;
809 MachineLoopInfo *
Loops =
nullptr;
810 MachineTraceMetrics *Traces =
nullptr;
815 EarlyIfConverter(MachineDominatorTree &DT, MachineLoopInfo &LI,
816 MachineTraceMetrics &MTM)
817 : DomTree(&DT),
Loops(&LI), Traces(&MTM) {}
818 EarlyIfConverter() =
delete;
820 bool run(MachineFunction &MF);
823 bool tryConvertIf(MachineBasicBlock *);
824 void invalidateTraces();
825 bool shouldConvertIf();
828class EarlyIfConverterLegacy :
public MachineFunctionPass {
831 EarlyIfConverterLegacy() : MachineFunctionPass(
ID) {}
832 void getAnalysisUsage(AnalysisUsage &AU)
const override;
833 bool runOnMachineFunction(MachineFunction &MF)
override;
834 StringRef getPassName()
const override {
return "Early If-Conversion"; }
838char EarlyIfConverterLegacy::ID = 0;
849void EarlyIfConverterLegacy::getAnalysisUsage(
AnalysisUsage &AU)
const {
862void updateDomTree(MachineDominatorTree *DomTree,
const SSAIfConv &IfConv,
868 for (
auto *
B : Removed) {
870 assert(Node != HeadNode &&
"Cannot erase the head node");
871 while (
Node->getNumChildren()) {
872 assert(
Node->getBlock() == IfConv.Tail &&
"Unexpected children");
880void updateLoops(MachineLoopInfo *
Loops,
884 for (
auto *
B : Removed)
890void EarlyIfConverter::invalidateTraces() {
901 if (Delta < 0 && Cyc + Delta > Cyc)
913 return R <<
ore::NV(
C.Key,
C.Value) << (
C.Value == 1 ?
" cycle" :
" cycles");
920bool EarlyIfConverter::shouldConvertIf() {
927 MachineLoop *CurrentLoop =
Loops->getLoopFor(IfConv.Head);
933 if (CurrentLoop &&
any_of(IfConv.Cond, [&](MachineOperand &MO) {
934 if (!MO.isReg() || !MO.isUse())
936 Register Reg = MO.getReg();
937 if (Reg.isPhysical())
940 MachineInstr *Def = MRI->getVRegDef(Reg);
941 return CurrentLoop->isLoopInvariant(*Def) ||
942 all_of(Def->operands(), [&](MachineOperand &Op) {
945 if (!MO.isReg() || !MO.isUse())
947 Register Reg = MO.getReg();
948 if (Reg.isPhysical())
951 MachineInstr *Def = MRI->getVRegDef(Reg);
952 return CurrentLoop->isLoopInvariant(*Def);
958 MinInstr = Traces->getEnsemble(MachineTraceStrategy::TS_MinInstrCount);
967 unsigned CritLimit = SchedModel.MispredictPenalty/2;
969 MachineBasicBlock &
MBB = *IfConv.Head;
976 if (IfConv.TBB != IfConv.Tail)
980 <<
", minimal critical path " << MinCrit <<
'\n');
981 if (ResLength > MinCrit + CritLimit) {
984 MachineOptimizationRemarkMissed
R(
DEBUG_TYPE,
"IfConversion",
986 R <<
"did not if-convert branch: the resulting critical path ("
987 << Cycles{
"ResLength", ResLength}
988 <<
") would extend the shorter leg's critical path ("
989 << Cycles{
"MinCrit", MinCrit} <<
") by more than the threshold of "
990 << Cycles{
"CritLimit", CritLimit}
991 <<
", which cannot be hidden by available ILP.";
1001 unsigned BranchDepth =
1008 struct CriticalPathInfo {
1012 CriticalPathInfo
Cond{};
1013 CriticalPathInfo TBlock{};
1014 CriticalPathInfo FBlock{};
1015 bool ShouldConvert =
true;
1016 for (SSAIfConv::PHIInfo &PI : IfConv.PHIs) {
1022 unsigned CondDepth =
adjCycles(BranchDepth, PI.CondCycles);
1023 if (CondDepth > MaxDepth) {
1024 unsigned Extra = CondDepth - MaxDepth;
1025 LLVM_DEBUG(
dbgs() <<
"Condition adds " << Extra <<
" cycles.\n");
1026 if (Extra >
Cond.Extra)
1027 Cond = {Extra, CondDepth};
1028 if (Extra > CritLimit) {
1030 ShouldConvert =
false;
1036 if (TDepth > MaxDepth) {
1037 unsigned Extra = TDepth - MaxDepth;
1039 if (Extra > TBlock.Extra)
1040 TBlock = {Extra, TDepth};
1041 if (Extra > CritLimit) {
1043 ShouldConvert =
false;
1049 if (FDepth > MaxDepth) {
1050 unsigned Extra = FDepth - MaxDepth;
1052 if (Extra > FBlock.Extra)
1053 FBlock = {Extra, FDepth};
1054 if (Extra > CritLimit) {
1056 ShouldConvert =
false;
1064 const CriticalPathInfo
Short = TBlock.Extra > FBlock.Extra ? FBlock : TBlock;
1065 const CriticalPathInfo
Long = TBlock.Extra > FBlock.Extra ? TBlock : FBlock;
1067 if (ShouldConvert) {
1069 MachineOptimizationRemark
R(
DEBUG_TYPE,
"IfConversion",
1071 R <<
"performing if-conversion on branch: the condition adds "
1072 << Cycles{
"CondCycles",
Cond.Extra} <<
" to the critical path";
1073 if (
Short.Extra > 0)
1074 R <<
", and the short leg adds another "
1075 << Cycles{
"ShortCycles",
Short.Extra};
1077 R <<
", and the long leg adds another "
1078 << Cycles{
"LongCycles",
Long.Extra};
1079 R <<
", each staying under the threshold of "
1080 << Cycles{
"CritLimit", CritLimit} <<
".";
1085 MachineOptimizationRemarkMissed
R(
DEBUG_TYPE,
"IfConversion",
1087 R <<
"did not if-convert branch: the condition would add "
1088 << Cycles{
"CondCycles",
Cond.Extra} <<
" to the critical path";
1089 if (
Cond.Extra > CritLimit)
1090 R <<
" exceeding the limit of " << Cycles{
"CritLimit", CritLimit};
1091 if (
Short.Extra > 0) {
1092 R <<
", and the short leg would add another "
1093 << Cycles{
"ShortCycles",
Short.Extra};
1094 if (
Short.Extra > CritLimit)
1095 R <<
" exceeding the limit of " << Cycles{
"CritLimit", CritLimit};
1097 if (
Long.Extra > 0) {
1098 R <<
", and the long leg would add another "
1099 << Cycles{
"LongCycles",
Long.Extra};
1100 if (
Long.Extra > CritLimit)
1101 R <<
" exceeding the limit of " << Cycles{
"CritLimit", CritLimit};
1108 return ShouldConvert;
1113bool EarlyIfConverter::tryConvertIf(MachineBasicBlock *
MBB) {
1115 while (IfConv.canConvertIf(
MBB) && shouldConvertIf()) {
1118 SmallVector<MachineBasicBlock *, 4> RemoveBlocks;
1119 IfConv.convertIf(RemoveBlocks);
1121 updateDomTree(DomTree, IfConv, RemoveBlocks);
1122 for (MachineBasicBlock *
MBB : RemoveBlocks)
1124 updateLoops(
Loops, RemoveBlocks);
1129bool EarlyIfConverter::run(MachineFunction &MF) {
1130 LLVM_DEBUG(
dbgs() <<
"********** EARLY IF-CONVERSION **********\n"
1131 <<
"********** Function: " << MF.
getName() <<
'\n');
1152 if (tryConvertIf(DomNode->getBlock()))
1165 EarlyIfConverter Impl(MDT, LI, MTM);
1177bool EarlyIfConverterLegacy::runOnMachineFunction(
MachineFunction &MF) {
1182 getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
1183 MachineLoopInfo &LI = getAnalysis<MachineLoopInfoWrapperPass>().getLI();
1185 getAnalysis<MachineTraceMetricsWrapperPass>().getMTM();
1187 return EarlyIfConverter(MDT, LI, MTM).run(MF);
1208 void getAnalysisUsage(AnalysisUsage &AU)
const override;
1209 bool runOnMachineFunction(MachineFunction &MF)
override;
1210 StringRef getPassName()
const override {
return "Early If-predicator"; }
1213 bool tryConvertIf(MachineBasicBlock *);
1214 bool shouldConvertIf();
1219#define DEBUG_TYPE "early-if-predicator"
1221char EarlyIfPredicator::ID = 0;
1231void EarlyIfPredicator::getAnalysisUsage(
AnalysisUsage &AU)
const {
1241bool EarlyIfPredicator::shouldConvertIf() {
1243 if (IfConv.isTriangle()) {
1244 MachineBasicBlock &IfBlock =
1245 (IfConv.TBB == IfConv.Tail) ? *IfConv.FBB : *IfConv.
TBB;
1247 unsigned ExtraPredCost = 0;
1248 unsigned Cycles = 0;
1249 for (MachineInstr &
I : IfBlock) {
1250 unsigned NumCycles = SchedModel.computeInstrLatency(&
I,
false);
1252 Cycles += NumCycles - 1;
1253 ExtraPredCost +=
TII->getPredicationCost(
I);
1259 unsigned TExtra = 0;
1260 unsigned FExtra = 0;
1261 unsigned TCycle = 0;
1262 unsigned FCycle = 0;
1263 for (MachineInstr &
I : *IfConv.TBB) {
1264 unsigned NumCycles = SchedModel.computeInstrLatency(&
I,
false);
1266 TCycle += NumCycles - 1;
1267 TExtra +=
TII->getPredicationCost(
I);
1269 for (MachineInstr &
I : *IfConv.FBB) {
1270 unsigned NumCycles = SchedModel.computeInstrLatency(&
I,
false);
1272 FCycle += NumCycles - 1;
1273 FExtra +=
TII->getPredicationCost(
I);
1276 FCycle, FExtra, TrueProbability);
1281bool EarlyIfPredicator::tryConvertIf(MachineBasicBlock *
MBB) {
1283 while (IfConv.canConvertIf(
MBB,
true) && shouldConvertIf()) {
1285 SmallVector<MachineBasicBlock *, 4> RemoveBlocks;
1286 IfConv.convertIf(RemoveBlocks,
true);
1288 updateDomTree(DomTree, IfConv, RemoveBlocks);
1289 for (MachineBasicBlock *
MBB : RemoveBlocks)
1291 updateLoops(
Loops, RemoveBlocks);
1296bool EarlyIfPredicator::runOnMachineFunction(MachineFunction &MF) {
1297 LLVM_DEBUG(
dbgs() <<
"********** EARLY IF-PREDICATOR **********\n"
1298 <<
"********** Function: " << MF.
getName() <<
'\n');
1306 SchedModel.
init(&STI);
1307 DomTree = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
1308 Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
1309 MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
1319 if (tryConvertIf(DomNode->getBlock()))
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static unsigned InstrCount
This file defines the DenseSet and SmallDenseSet classes.
static bool hasSameValue(const MachineRegisterInfo &MRI, const TargetInstrInfo *TII, Register TReg, Register FReg)
static unsigned adjCycles(unsigned Cyc, int Delta)
static cl::opt< bool > Stress("stress-early-ifcvt", cl::Hidden, cl::desc("Turn all knobs to 11"))
static cl::opt< unsigned > BlockInstrLimit("early-ifcvt-limit", cl::init(30), cl::Hidden, cl::desc("Maximum number of instructions per speculated block."))
const HexagonInstrInfo * TII
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
This file defines the SmallPtrSet class.
This file defines the SparseSet class derived from the version described in Briggs,...
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
bool test(unsigned Idx) const
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
void eraseNode(NodeT *BB)
eraseNode - Removes a node from the dominator tree.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
Remove the branching code at the end of the specific MBB.
bool isPredicated(const MachineInstr &MI) const override
Returns true if the instruction is already predicated.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e....
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
Reverses the branch condition of the specified condition list, returning false on success and true if...
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
Insert branch code into the end of the specified MachineBasicBlock.
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, BranchProbability Probability) const override
Return true if it's profitable to predicate instructions with accumulated instruction latency of "Num...
bool PredicateInstruction(MachineInstr &MI, ArrayRef< MachineOperand > Cond) const override
Convert the instruction into a predicated instruction.
bool isPredicable(const MachineInstr &MI) const override
Return true if the specified instruction can be predicated.
const MCSchedModel & getSchedModel() const
Get the machine model for this subtarget's CPU.
unsigned pred_size() const
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
succ_iterator succ_begin()
bool livein_empty() const
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
unsigned succ_size() const
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
LLVM_ABI void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
LLVM_ABI DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
LLVM_ABI bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
LLVM_ABI void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
LLVM_ABI void moveAfter(MachineBasicBlock *NewBefore)
BranchProbability getEdgeProbability(const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const
Analysis pass which computes a MachineDominatorTree.
Analysis pass which computes a MachineDominatorTree.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineBasicBlock & back() const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
const MachineBasicBlock * getParent() const
LLVM_ABI bool isDereferenceableInvariantLoad() const
Return true if this load instruction never traps and points to a memory location whose value doesn't ...
LLVM_ABI bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore,...
mop_range uses()
Returns all operands which may be register uses.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
LLVM_ABI int findRegisterDefOperandIdx(Register Reg, const TargetRegisterInfo *TRI, bool isDead=false, bool Overlap=false) const
Returns the operand index that is a def of the specified register or -1 if it is not found.
Analysis pass that exposes the MachineLoopInfo for a machine function.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
unsigned getResourceLength(ArrayRef< const MachineBasicBlock * > Extrablocks={}, ArrayRef< const MCSchedClassDesc * > ExtraInstrs={}, ArrayRef< const MCSchedClassDesc * > RemoveInstrs={}) const
Return the resource length of the trace.
InstrCycles getInstrCycles(const MachineInstr &MI) const
Return the depth and height of MI.
unsigned getInstrSlack(const MachineInstr &MI) const
Return the slack of MI.
unsigned getCriticalPath() const
Return the length of the (data dependency) critical path through the trace.
unsigned getPHIDepth(const MachineInstr &PHI) const
Return the Depth of a PHI instruction in a trace center block successor.
void verifyAnalysis() const
void invalidate(const MachineBasicBlock *MBB)
Invalidate cached information about MBB.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Wrapper class representing virtual and physical registers.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
void push_back(const T &Elt)
iterator erase(iterator I)
erase - Erases an existing element identified by a valid iterator.
bool empty() const
empty - Returns true if the set is empty.
void clear()
clear - Clears the set.
std::pair< iterator, bool > insert(const ValueT &Val)
insert - Attempts to insert a new element.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Provide an instruction scheduling machine model to CodeGen passes.
LLVM_ABI void init(const TargetSubtargetInfo *TSInfo, bool EnableSModel=true, bool EnableSItins=true)
Initialize the machine model for instruction scheduling.
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
virtual bool enableEarlyIfConversion() const
Enable the use of the early if conversion pass.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
DiagnosticInfoOptimizationBase::Argument NV
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI Printable printRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
iterator_range< po_iterator< T > > post_order(const T &G)
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI char & EarlyIfConverterLegacyID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions.
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned MCRegUnit
Register units are used to compute register aliasing.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI char & EarlyIfPredicatorID
EarlyIfPredicator - This pass performs if-conversion on SSA form by predicating if/else block and ins...
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
unsigned Depth
Earliest issue cycle as determined by data dependencies and instruction latencies from the beginning ...