55 struct MachineVerifier {
57 MachineVerifier(
Pass *
pass,
const char *b) :
75 bool isFunctionRegBankSelected;
76 bool isFunctionSelected;
85 BlockSet FunctionBlocks;
89 RegVector regsDefined, regsDead, regsKilled;
90 RegMaskVector regMasks;
95 void addRegWithSubRegs(RegVector &RV,
unsigned Reg) {
99 RV.push_back(*SubRegs);
124 RegSet vregsRequired;
127 BlockSet Preds, Succs;
129 BBInfo() : reachable(
false) {}
133 bool addPassed(
unsigned Reg) {
136 if (regsKilled.count(Reg) || regsLiveOut.count(Reg))
138 return vregsPassed.insert(Reg).second;
142 bool addPassed(
const RegSet &RS) {
143 bool changed =
false;
144 for (RegSet::const_iterator
I = RS.begin(),
E = RS.end();
I !=
E; ++
I)
152 bool addRequired(
unsigned Reg) {
155 if (regsLiveOut.count(Reg))
157 return vregsRequired.insert(Reg).second;
161 bool addRequired(
const RegSet &RS) {
162 bool changed =
false;
163 for (RegSet::const_iterator
I = RS.begin(),
E = RS.end();
I !=
E; ++
I)
170 bool addRequired(
const RegMap &
RM) {
171 bool changed =
false;
172 for (RegMap::const_iterator
I = RM.begin(),
E = RM.end();
I !=
E; ++
I)
173 if (addRequired(
I->first))
180 return regsLiveOut.count(Reg) || vregsPassed.count(Reg);
187 bool isReserved(
unsigned Reg) {
188 return Reg < regsReserved.size() && regsReserved.test(Reg);
191 bool isAllocatable(
unsigned Reg)
const {
192 return Reg < TRI->getNumRegs() && TRI->isInAllocatableClass(Reg) &&
193 !regsReserved.test(Reg);
202 void visitMachineFunctionBefore();
206 void visitMachineOperand(
const MachineOperand *MO,
unsigned MONum);
210 void visitMachineFunctionAfter();
215 void report(
const char *msg,
const MachineOperand *MO,
unsigned MONum);
218 void report_context(
const LiveRange &LR,
unsigned VRegUnit,
221 void report_context(
const VNInfo &VNI)
const;
222 void report_context(
SlotIndex Pos)
const;
223 void report_context_liverange(
const LiveRange &LR)
const;
224 void report_context_lanemask(
LaneBitmask LaneMask)
const;
225 void report_context_vreg(
unsigned VReg)
const;
226 void report_context_vreg_regunit(
unsigned VRegOrRegUnit)
const;
239 void calcRegsPassed();
242 void calcRegsRequired();
243 void verifyLiveVariables();
244 void verifyLiveIntervals();
248 void verifyLiveRangeSegment(
const LiveRange&,
251 void verifyLiveRange(
const LiveRange&,
unsigned,
254 void verifyStackFrame();
256 void verifySlotIndexes()
const;
262 const std::string Banner;
264 MachineVerifierPass(std::string banner = std::string())
275 unsigned FoundErrors = MachineVerifier(
this, Banner.c_str()).
verify(MF);
286 "Verify generated machine code",
false,
false)
289 return new MachineVerifierPass(Banner);
295 unsigned FoundErrors = MachineVerifier(p, Banner).verify(MF);
296 if (AbortOnErrors && FoundErrors)
298 return FoundErrors == 0;
301 void MachineVerifier::verifySlotIndexes()
const {
302 if (Indexes ==
nullptr)
308 E = Indexes->MBBIndexEnd();
I !=
E; ++
I) {
320 MRI->getNumVirtRegs())
321 report(
"Function has NoVRegs property but there are VReg operands", &MF);
353 verifyProperties(MF);
355 visitMachineFunctionBefore();
358 visitMachineBasicBlockBefore(&*MFI);
362 bool InBundle =
false;
365 MBBE = MFI->instr_end(); MBBI != MBBE; ++MBBI) {
366 if (MBBI->getParent() != &*MFI) {
367 report(
"Bad instruction parent pointer", &*MFI);
368 errs() <<
"Instruction: " << *MBBI;
373 if (InBundle && !MBBI->isBundledWithPred())
374 report(
"Missing BundledPred flag, "
375 "BundledSucc was set on predecessor",
377 if (!InBundle && MBBI->isBundledWithPred())
378 report(
"BundledPred flag is set, "
379 "but BundledSucc not set on predecessor",
383 if (!MBBI->isInsideBundle()) {
385 visitMachineBundleAfter(CurBundle);
387 visitMachineBundleBefore(CurBundle);
388 }
else if (!CurBundle)
389 report(
"No bundle header", &*MBBI);
390 visitMachineInstrBefore(&*MBBI);
391 for (
unsigned I = 0,
E = MBBI->getNumOperands();
I !=
E; ++
I) {
397 report(
"Instruction has operand with wrong parent set", &MI);
400 visitMachineOperand(&Op,
I);
403 visitMachineInstrAfter(&*MBBI);
406 InBundle = MBBI->isBundledWithSucc();
409 visitMachineBundleAfter(CurBundle);
411 report(
"BundledSucc flag set on last instruction in block", &MFI->back());
412 visitMachineBasicBlockAfter(&*MFI);
414 visitMachineFunctionAfter();
427 void MachineVerifier::report(
const char *msg,
const MachineFunction *MF) {
430 if (!foundErrors++) {
432 errs() <<
"# " << Banner <<
'\n';
433 if (LiveInts !=
nullptr)
434 LiveInts->print(
errs());
438 errs() <<
"*** Bad machine code: " << msg <<
" ***\n"
439 <<
"- function: " << MF->
getName() <<
"\n";
447 <<
" (" << (
const void*)MBB <<
')';
449 errs() <<
" [" << Indexes->getMBBStartIdx(MBB)
450 <<
';' << Indexes->getMBBEndIdx(MBB) <<
')';
454 void MachineVerifier::report(
const char *msg,
const MachineInstr *MI) {
457 errs() <<
"- instruction: ";
458 if (Indexes && Indexes->hasIndex(*MI))
459 errs() << Indexes->getInstructionIndex(*MI) <<
'\t';
464 void MachineVerifier::report(
const char *msg,
468 errs() <<
"- operand " << MONum <<
": ";
473 void MachineVerifier::report_context(
SlotIndex Pos)
const {
474 errs() <<
"- at: " << Pos <<
'\n';
477 void MachineVerifier::report_context(
const LiveInterval &LI)
const {
478 errs() <<
"- interval: " << LI <<
'\n';
481 void MachineVerifier::report_context(
const LiveRange &LR,
unsigned VRegUnit,
483 report_context_liverange(LR);
484 report_context_vreg_regunit(VRegUnit);
486 report_context_lanemask(LaneMask);
490 errs() <<
"- segment: " << S <<
'\n';
493 void MachineVerifier::report_context(
const VNInfo &VNI)
const {
494 errs() <<
"- ValNo: " << VNI.
id <<
" (def " << VNI.
def <<
")\n";
497 void MachineVerifier::report_context_liverange(
const LiveRange &LR)
const {
498 errs() <<
"- liverange: " << LR <<
'\n';
501 void MachineVerifier::report_context_vreg(
unsigned VReg)
const {
502 errs() <<
"- v. register: " <<
PrintReg(VReg, TRI) <<
'\n';
505 void MachineVerifier::report_context_vreg_regunit(
unsigned VRegOrUnit)
const {
507 report_context_vreg(VRegOrUnit);
513 void MachineVerifier::report_context_lanemask(
LaneBitmask LaneMask)
const {
518 BBInfo &MInfo = MBBInfoMap[MBB];
519 if (!MInfo.reachable) {
520 MInfo.reachable =
true;
522 SuE = MBB->
succ_end(); SuI != SuE; ++SuI)
527 void MachineVerifier::visitMachineFunctionBefore() {
529 regsReserved =
MRI->reservedRegsFrozen() ?
MRI->getReservedRegs()
530 : TRI->getReservedRegs(*MF);
533 markReachable(&MF->
front());
536 FunctionBlocks.clear();
537 for (
const auto &MBB : *MF) {
538 FunctionBlocks.insert(&MBB);
539 BBInfo &MInfo = MBBInfoMap[&MBB];
542 if (MInfo.Preds.size() != MBB.
pred_size())
543 report(
"MBB has duplicate entries in its predecessor list.", &MBB);
546 if (MInfo.Succs.size() != MBB.
succ_size())
547 report(
"MBB has duplicate entries in its successor list.", &MBB);
551 MRI->verifyUseLists();
569 FirstTerminator =
nullptr;
571 if (!MF->getProperties().hasProperty(
575 for (
const auto &LI : MBB->
liveins()) {
576 if (isAllocatable(LI.PhysReg) && !MBB->
isEHPad() &&
578 report(
"MBB has allocatable live-in, but isn't entry or landing-pad.", MBB);
589 if (!FunctionBlocks.count(*
I))
590 report(
"MBB has successor that isn't part of the function.", MBB);
591 if (!MBBInfoMap[*
I].Preds.count(MBB)) {
592 report(
"Inconsistent CFG", MBB);
593 errs() <<
"MBB is not in the predecessor list of the successor BB#"
594 << (*I)->getNumber() <<
".\n";
601 if (!FunctionBlocks.count(*
I))
602 report(
"MBB has predecessor that isn't part of the function.", MBB);
603 if (!MBBInfoMap[*
I].Succs.count(MBB)) {
604 report(
"Inconsistent CFG", MBB);
605 errs() <<
"MBB is not in the successor list of the predecessor BB#"
606 << (*I)->getNumber() <<
".\n";
612 const Function *Fn = MF->getFunction();
613 if (LandingPadSuccs.
size() > 1 &&
618 report(
"MBB has more than one landing pad successor", MBB);
631 if (MBBI == MF->end()) {
640 report(
"MBB exits via unconditional fall-through but doesn't have "
641 "exactly one CFG successor!", MBB);
643 report(
"MBB exits via unconditional fall-through but its successor "
644 "differs from its CFG successor!", MBB);
648 report(
"MBB exits via unconditional fall-through but ends with a "
649 "barrier instruction!", MBB);
652 report(
"MBB exits via unconditional fall-through but has a condition!",
655 }
else if (TBB && !FBB && Cond.
empty()) {
662 report(
"MBB exits via unconditional branch but doesn't have "
663 "exactly one CFG successor!", MBB);
665 report(
"MBB exits via unconditional branch but the CFG "
666 "successor doesn't match the actual successor!", MBB);
669 report(
"MBB exits via unconditional branch but doesn't contain "
670 "any instructions!", MBB);
672 report(
"MBB exits via unconditional branch but doesn't end with a "
673 "barrier instruction!", MBB);
675 report(
"MBB exits via unconditional branch but the branch isn't a "
676 "terminator instruction!", MBB);
678 }
else if (TBB && !FBB && !Cond.
empty()) {
682 if (MBBI == MF->end()) {
683 report(
"MBB conditionally falls through out of function!", MBB);
687 report(
"MBB exits via conditional branch/fall-through but only has "
688 "one CFG successor!", MBB);
690 report(
"MBB exits via conditional branch/fall-through but the CFG "
691 "successor don't match the actual successor!", MBB);
693 report(
"MBB exits via conditional branch/fall-through but doesn't have "
694 "exactly two CFG successors!", MBB);
696 report(
"MBB exits via conditional branch/fall-through but the CFG "
697 "successors don't match the actual successors!", MBB);
700 report(
"MBB exits via conditional branch/fall-through but doesn't "
701 "contain any instructions!", MBB);
703 report(
"MBB exits via conditional branch/fall-through but ends with a "
704 "barrier instruction!", MBB);
706 report(
"MBB exits via conditional branch/fall-through but the branch "
707 "isn't a terminator instruction!", MBB);
709 }
else if (TBB && FBB) {
715 report(
"MBB exits via conditional branch/branch through but only has "
716 "one CFG successor!", MBB);
718 report(
"MBB exits via conditional branch/branch through but the CFG "
719 "successor don't match the actual successor!", MBB);
721 report(
"MBB exits via conditional branch/branch but doesn't have "
722 "exactly two CFG successors!", MBB);
724 report(
"MBB exits via conditional branch/branch but the CFG "
725 "successors don't match the actual successors!", MBB);
728 report(
"MBB exits via conditional branch/branch but doesn't "
729 "contain any instructions!", MBB);
731 report(
"MBB exits via conditional branch/branch but doesn't end with a "
732 "barrier instruction!", MBB);
734 report(
"MBB exits via conditional branch/branch but the branch "
735 "isn't a terminator instruction!", MBB);
738 report(
"MBB exits via conditinal branch/branch but there's no "
742 report(
"AnalyzeBranch returned invalid data!", MBB);
747 if (
MRI->tracksLiveness()) {
748 for (
const auto &LI : MBB->
liveins()) {
750 report(
"MBB live-in list contains non-physical register", MBB);
755 regsLive.insert(*SubRegs);
764 regsLive.insert(*SubRegs);
771 lastIndex = Indexes->getMBBStartIdx(MBB);
776 void MachineVerifier::visitMachineBundleBefore(
const MachineInstr *MI) {
777 if (Indexes && Indexes->hasIndex(*MI)) {
778 SlotIndex idx = Indexes->getInstructionIndex(*MI);
779 if (!(idx > lastIndex)) {
780 report(
"Instruction index out of order", MI);
781 errs() <<
"Last instruction was at " << lastIndex <<
'\n';
790 if (!FirstTerminator)
791 FirstTerminator =
MI;
792 }
else if (FirstTerminator) {
793 report(
"Non-terminator instruction after the first terminator", MI);
794 errs() <<
"First terminator was:\t" << *FirstTerminator;
800 void MachineVerifier::verifyInlineAsm(
const MachineInstr *MI) {
803 report(
"Too few operands on inline asm", MI);
807 report(
"Asm string must be an external symbol", MI);
809 report(
"Asm flags must be an immediate", MI);
814 report(
"Unknown asm flags", &MI->
getOperand(1), 1);
820 for (
unsigned e = MI->
getNumOperands(); OpNo < e; OpNo += NumOps) {
829 report(
"Missing operands in last group", MI);
839 report(
"Expected implicit register after groups", &MO, OpNo);
843 void MachineVerifier::visitMachineInstrBefore(
const MachineInstr *MI) {
846 report(
"Too few operands", MI);
851 if (MI->
isPHI() && MF->getProperties().hasProperty(
853 report(
"Found PHI instruction with NoPHIs property set", MI);
862 if ((*I)->isLoad() && !MI->
mayLoad())
863 report(
"Missing mayLoad flag", MI);
864 if ((*I)->isStore() && !MI->
mayStore())
865 report(
"Missing mayStore flag", MI);
871 bool mapped = !LiveInts->isNotInMIMap(*MI);
874 report(
"Debug instruction has a slot index", MI);
877 report(
"Instruction inside bundle has a slot index", MI);
880 report(
"Missing slot index", MI);
886 if (isFunctionSelected)
887 report(
"Unexpected generic instruction in a Selected function", MI);
899 if (Types[TypeIdx].
isValid() && Types[TypeIdx] != OpTy)
900 report(
"type mismatch in generic instruction", MI);
901 Types[TypeIdx] = OpTy;
909 report(
"Generic instruction cannot have physical register", MI);
914 if (!
TII->verifyInstruction(*MI, ErrorInfo))
915 report(ErrorInfo.
data(),
MI);
921 case TargetOpcode::G_LOAD:
922 case TargetOpcode::G_STORE:
926 report(
"Generic instruction accessing memory must have one mem operand",
929 case TargetOpcode::STATEPOINT:
933 report(
"meta operands to STATEPOINT not constant!", MI);
936 auto VerifyStackMapConstant = [&](
unsigned Offset) {
940 report(
"stack map constant to STATEPOINT not well formed!", MI);
952 MachineVerifier::visitMachineOperand(
const MachineOperand *MO,
unsigned MONum) {
956 if (MCID.
getOpcode() == TargetOpcode::PATCHPOINT)
957 NumDefs = (MONum == 0 && MO->
isReg()) ? NumDefs : 0;
960 if (MONum < NumDefs) {
963 report(
"Explicit definition must be a register", MO, MONum);
965 report(
"Explicit definition marked as use", MO, MONum);
967 report(
"Explicit definition marked as implicit", MO, MONum);
975 report(
"Explicit operand marked as def", MO, MONum);
977 report(
"Explicit operand marked as implicit", MO, MONum);
983 report(
"Tied use must be a register", MO, MONum);
985 report(
"Operand should be tied", MO, MONum);
987 report(
"Tied def doesn't match MCInstrDesc", MO, MONum);
991 report(
"Tied counterpart must be a register", &MOTied, TiedTo);
994 report(
"Tied physical registers must match.", &MOTied, TiedTo);
997 report(
"Explicit operand should not be tied", MO, MONum);
1001 report(
"Extra explicit operand on non-variadic instruction", MO, MONum);
1006 const unsigned Reg = MO->
getReg();
1010 checkLiveness(MO, MONum);
1016 if (!OtherMO.
isReg())
1017 report(
"Must be tied to a register", MO, MONum);
1019 report(
"Missing tie flags on tied operand", MO, MONum);
1021 report(
"Inconsistent tie links", MO, MONum);
1025 report(
"Explicit def tied to explicit use without tie constraint",
1029 report(
"Explicit def should be tied to implicit use", MO, MONum);
1036 if (!
MRI->isSSA() && MO->
isUse() &&
1039 report(
"Two-address instruction operands must be identical", MO, MONum);
1047 report(
"Illegal subregister index for physical register", MO, MONum);
1051 TII->getRegClass(MCID, MONum, TRI, *MF)) {
1052 if (!DRC->contains(Reg)) {
1053 report(
"Illegal physical register for instruction", MO, MONum);
1054 errs() << TRI->getName(Reg) <<
" is not a "
1055 << TRI->getRegClassName(DRC) <<
" register.\n";
1065 if (isFunctionSelected) {
1066 report(
"Generic virtual register invalid in a Selected function",
1072 LLT Ty =
MRI->getType(Reg);
1074 report(
"Generic virtual register must have a valid type", MO,
1082 if (!RegBank && isFunctionRegBankSelected) {
1083 report(
"Generic virtual register must have a bank in a "
1084 "RegBankSelected function",
1090 if (RegBank && Ty.
isValid() &&
1092 report(
"Register bank is too small for virtual register", MO,
1094 errs() <<
"Register bank " << RegBank->
getName() <<
" too small("
1100 report(
"Generic virtual register does not subregister index", MO,
1109 TII->getRegClass(MCID, MONum, TRI, *MF)) {
1110 report(
"Virtual register does not match instruction constraint", MO,
1112 errs() <<
"Expect register class "
1113 << TRI->getRegClassName(
1114 TII->getRegClass(MCID, MONum, TRI, *MF))
1115 <<
" but got nothing\n";
1123 TRI->getSubClassWithSubReg(RC, SubIdx);
1125 report(
"Invalid subregister index for virtual register", MO, MONum);
1126 errs() <<
"Register class " << TRI->getRegClassName(RC)
1127 <<
" does not support subreg index " << SubIdx <<
"\n";
1131 report(
"Invalid register class for subregister index", MO, MONum);
1132 errs() <<
"Register class " << TRI->getRegClassName(RC)
1133 <<
" does not fully support subreg index " << SubIdx <<
"\n";
1138 TII->getRegClass(MCID, MONum, TRI, *MF)) {
1141 TRI->getLargestLegalSuperClass(RC, *MF);
1143 report(
"No largest legal super class exists.", MO, MONum);
1146 DRC = TRI->getMatchingSuperRegClass(SuperRC, DRC, SubIdx);
1148 report(
"No matching super-reg register class.", MO, MONum);
1153 report(
"Illegal virtual register for instruction", MO, MONum);
1154 errs() <<
"Expected a " << TRI->getRegClassName(DRC)
1155 <<
" register, but got a " << TRI->getRegClassName(RC)
1170 report(
"PHI operand is not in the CFG", MO, MONum);
1174 if (LiveStks && LiveStks->hasInterval(MO->
getIndex()) &&
1175 LiveInts && !LiveInts->isNotInMIMap(*MI)) {
1178 SlotIndex Idx = LiveInts->getInstructionIndex(*MI);
1185 if (stores && loads) {
1188 if (PSV ==
nullptr)
continue;
1191 if (Value ==
nullptr)
continue;
1200 if (loads == stores)
1201 report(
"Missing fixed stack memoperand.", MI);
1204 report(
"Instruction loads from dead spill slot", MO, MONum);
1205 errs() <<
"Live stack: " << LI <<
'\n';
1208 report(
"Instruction stores to dead spill slot", MO, MONum);
1209 errs() <<
"Live stack: " << LI <<
'\n';
1219 void MachineVerifier::checkLivenessAtUse(
const MachineOperand *MO,
1226 report(
"No live segment at use", MO, MONum);
1227 report_context_liverange(LR);
1228 report_context_vreg_regunit(VRegOrUnit);
1229 report_context(UseIdx);
1232 report(
"Live range continues after kill flag", MO, MONum);
1233 report_context_liverange(LR);
1234 report_context_vreg_regunit(VRegOrUnit);
1236 report_context_lanemask(LaneMask);
1237 report_context(UseIdx);
1241 void MachineVerifier::checkLivenessAtDef(
const MachineOperand *MO,
1245 assert(VNI &&
"NULL valno is not allowed");
1246 if (VNI->def != DefIdx) {
1247 report(
"Inconsistent valno->def", MO, MONum);
1248 report_context_liverange(LR);
1249 report_context_vreg_regunit(VRegOrUnit);
1251 report_context_lanemask(LaneMask);
1252 report_context(*VNI);
1253 report_context(DefIdx);
1256 report(
"No live segment at def", MO, MONum);
1257 report_context_liverange(LR);
1258 report_context_vreg_regunit(VRegOrUnit);
1260 report_context_lanemask(LaneMask);
1261 report_context(DefIdx);
1269 bool otherDef =
false;
1275 unsigned Reg = MO.
getReg();
1277 if (*Units == VRegOrUnit) {
1286 report(
"Live range continues after dead def flag", MO, MONum);
1287 report_context_liverange(LR);
1288 report_context_vreg_regunit(VRegOrUnit);
1290 report_context_lanemask(LaneMask);
1296 void MachineVerifier::checkLiveness(
const MachineOperand *MO,
unsigned MONum) {
1298 const unsigned Reg = MO->
getReg();
1303 addRegWithSubRegs(regsKilled, Reg);
1310 report(
"Kill missing from LiveVariables", MO, MONum);
1314 if (LiveInts && !LiveInts->isNotInMIMap(*MI)) {
1315 SlotIndex UseIdx = LiveInts->getInstructionIndex(*MI);
1319 if (
const LiveRange *LR = LiveInts->getCachedRegUnit(*Units))
1320 checkLivenessAtUse(MO, MONum, UseIdx, *LR, *Units);
1325 if (LiveInts->hasInterval(Reg)) {
1328 checkLivenessAtUse(MO, MONum, UseIdx, LI, Reg);
1333 ? TRI->getSubRegIndexLaneMask(SubRegIdx)
1334 :
MRI->getMaxLaneMaskForVReg(Reg);
1337 if ((MOMask & SR.LaneMask).none())
1339 checkLivenessAtUse(MO, MONum, UseIdx, SR, Reg, SR.LaneMask);
1342 LiveInMask |= SR.LaneMask;
1345 if ((LiveInMask & MOMask).none()) {
1346 report(
"No live subrange at use", MO, MONum);
1348 report_context(UseIdx);
1352 report(
"Virtual register has no live interval", MO, MONum);
1358 if (!regsLive.count(Reg)) {
1361 bool Bad = !isReserved(Reg);
1366 if (regsLive.count(*SubRegs)) {
1380 if (!MOP.isImplicit())
1384 if (*SubRegs == Reg) {
1392 report(
"Using an undefined physical register", MO, MONum);
1393 }
else if (
MRI->def_empty(Reg)) {
1394 report(
"Reading virtual register without a def", MO, MONum);
1396 BBInfo &MInfo = MBBInfoMap[MI->
getParent()];
1400 if (MInfo.regsKilled.count(Reg))
1401 report(
"Using a killed virtual register", MO, MONum);
1402 else if (!MI->
isPHI())
1403 MInfo.vregsLiveIn.insert(std::make_pair(Reg, MI));
1412 addRegWithSubRegs(regsDead, Reg);
1414 addRegWithSubRegs(regsDefined, Reg);
1418 std::next(
MRI->def_begin(Reg)) !=
MRI->def_end())
1419 report(
"Multiple virtual register defs in SSA form", MO, MONum);
1422 if (LiveInts && !LiveInts->isNotInMIMap(*MI)) {
1423 SlotIndex DefIdx = LiveInts->getInstructionIndex(*MI);
1427 if (LiveInts->hasInterval(Reg)) {
1429 checkLivenessAtDef(MO, MONum, DefIdx, LI, Reg);
1434 ? TRI->getSubRegIndexLaneMask(SubRegIdx)
1435 :
MRI->getMaxLaneMaskForVReg(Reg);
1437 if ((SR.LaneMask & MOMask).none())
1439 checkLivenessAtDef(MO, MONum, DefIdx, SR, Reg, SR.LaneMask);
1443 report(
"Virtual register has no Live interval", MO, MONum);
1450 void MachineVerifier::visitMachineInstrAfter(
const MachineInstr *MI) {
1457 void MachineVerifier::visitMachineBundleAfter(
const MachineInstr *MI) {
1458 BBInfo &MInfo = MBBInfoMap[MI->
getParent()];
1459 set_union(MInfo.regsKilled, regsKilled);
1460 set_subtract(regsLive, regsKilled); regsKilled.clear();
1462 while (!regMasks.empty()) {
1464 for (RegSet::iterator
I = regsLive.begin(),
E = regsLive.end();
I !=
E; ++
I)
1467 regsDead.push_back(*
I);
1470 set_union(regsLive, regsDefined); regsDefined.clear();
1475 MBBInfoMap[MBB].regsLiveOut = regsLive;
1479 SlotIndex stop = Indexes->getMBBEndIdx(MBB);
1480 if (!(stop > lastIndex)) {
1481 report(
"Block ends before last instruction index", MBB);
1482 errs() <<
"Block ends at " << stop
1483 <<
" last instruction was at " << lastIndex <<
'\n';
1492 void MachineVerifier::calcRegsPassed() {
1496 for (
const auto &MBB : *MF) {
1497 BBInfo &MInfo = MBBInfoMap[&MBB];
1498 if (!MInfo.reachable)
1501 SuE = MBB.
succ_end(); SuI != SuE; ++SuI) {
1502 BBInfo &SInfo = MBBInfoMap[*SuI];
1503 if (SInfo.addPassed(MInfo.regsLiveOut))
1510 while (!todo.
empty()) {
1513 BBInfo &MInfo = MBBInfoMap[MBB];
1515 SuE = MBB->
succ_end(); SuI != SuE; ++SuI) {
1518 BBInfo &SInfo = MBBInfoMap[*SuI];
1519 if (SInfo.addPassed(MInfo.vregsPassed))
1528 void MachineVerifier::calcRegsRequired() {
1531 for (
const auto &MBB : *MF) {
1532 BBInfo &MInfo = MBBInfoMap[&MBB];
1534 PrE = MBB.
pred_end(); PrI != PrE; ++PrI) {
1535 BBInfo &PInfo = MBBInfoMap[*PrI];
1536 if (PInfo.addRequired(MInfo.vregsLiveIn))
1543 while (!todo.
empty()) {
1546 BBInfo &MInfo = MBBInfoMap[MBB];
1548 PrE = MBB->
pred_end(); PrI != PrE; ++PrI) {
1551 BBInfo &SInfo = MBBInfoMap[*PrI];
1552 if (SInfo.addRequired(MInfo.vregsRequired))
1562 for (
const auto &BBI : *MBB) {
1567 for (
unsigned i = 1, e = BBI.getNumOperands(); i != e; i += 2) {
1568 unsigned Reg = BBI.getOperand(i).getReg();
1573 BBInfo &PrInfo = MBBInfoMap[Pre];
1574 if (PrInfo.reachable && !PrInfo.isLiveOut(Reg))
1575 report(
"PHI operand is not live-out from predecessor",
1576 &BBI.getOperand(i), i);
1581 PrE = MBB->pred_end(); PrI != PrE; ++PrI) {
1582 if (!seen.
count(*PrI)) {
1583 report(
"Missing PHI operand", &BBI);
1584 errs() <<
"BB#" << (*PrI)->getNumber()
1585 <<
" is a predecessor according to the CFG.\n";
1591 void MachineVerifier::visitMachineFunctionAfter() {
1594 for (
const auto &MBB : *MF) {
1595 BBInfo &MInfo = MBBInfoMap[&MBB];
1598 if (!MInfo.reachable)
1608 for (
const auto &MBB : *MF) {
1609 BBInfo &MInfo = MBBInfoMap[&MBB];
1610 for (RegSet::iterator
1611 I = MInfo.vregsRequired.begin(),
E = MInfo.vregsRequired.end();
I !=
E;
1613 if (MInfo.regsKilled.count(*
I)) {
1614 report(
"Virtual register killed in block, but needed live out.", &MBB);
1616 <<
" is used after the block.\n";
1621 BBInfo &MInfo = MBBInfoMap[&MF->front()];
1622 for (RegSet::iterator
1623 I = MInfo.vregsRequired.begin(),
E = MInfo.vregsRequired.end();
I !=
E;
1625 report(
"Virtual register defs don't dominate all uses.", MF);
1626 report_context_vreg(*
I);
1631 verifyLiveVariables();
1633 verifyLiveIntervals();
1636 void MachineVerifier::verifyLiveVariables() {
1637 assert(LiveVars &&
"Don't call verifyLiveVariables without LiveVars");
1638 for (
unsigned i = 0, e =
MRI->getNumVirtRegs(); i != e; ++i) {
1641 for (
const auto &MBB : *MF) {
1642 BBInfo &MInfo = MBBInfoMap[&MBB];
1645 if (MInfo.vregsRequired.count(Reg)) {
1647 report(
"LiveVariables: Block missing from AliveBlocks", &MBB);
1649 <<
" must be live through the block.\n";
1653 report(
"LiveVariables: Block should not be in AliveBlocks", &MBB);
1655 <<
" is not needed live through the block.\n";
1662 void MachineVerifier::verifyLiveIntervals() {
1663 assert(LiveInts &&
"Don't call verifyLiveIntervals without LiveInts");
1664 for (
unsigned i = 0, e =
MRI->getNumVirtRegs(); i != e; ++i) {
1668 if (
MRI->reg_nodbg_empty(Reg))
1671 if (!LiveInts->hasInterval(Reg)) {
1672 report(
"Missing live interval for virtual register", MF);
1673 errs() <<
PrintReg(Reg, TRI) <<
" still has defs or uses\n";
1678 assert(Reg == LI.
reg &&
"Invalid reg to interval mapping");
1679 verifyLiveInterval(LI);
1683 for (
unsigned i = 0, e = TRI->getNumRegUnits(); i != e; ++i)
1684 if (
const LiveRange *LR = LiveInts->getCachedRegUnit(i))
1685 verifyLiveRange(*LR, i);
1688 void MachineVerifier::verifyLiveRangeValue(
const LiveRange &LR,
1689 const VNInfo *VNI,
unsigned Reg,
1697 report(
"Value not live at VNInfo def and not marked unused", MF);
1698 report_context(LR, Reg, LaneMask);
1699 report_context(*VNI);
1703 if (DefVNI != VNI) {
1704 report(
"Live segment at def has different VNInfo", MF);
1705 report_context(LR, Reg, LaneMask);
1706 report_context(*VNI);
1712 report(
"Invalid VNInfo definition index", MF);
1713 report_context(LR, Reg, LaneMask);
1714 report_context(*VNI);
1719 if (VNI->
def != LiveInts->getMBBStartIdx(MBB)) {
1720 report(
"PHIDef VNInfo is not defined at MBB start", MBB);
1721 report_context(LR, Reg, LaneMask);
1722 report_context(*VNI);
1730 report(
"No instruction at VNInfo def index", MBB);
1731 report_context(LR, Reg, LaneMask);
1732 report_context(*VNI);
1737 bool hasDef =
false;
1738 bool isEarlyClobber =
false;
1740 if (!MOI->isReg() || !MOI->isDef())
1743 if (MOI->getReg() !=
Reg)
1747 !TRI->hasRegUnit(MOI->getReg(),
Reg))
1750 if (LaneMask.
any() &&
1751 (TRI->getSubRegIndexLaneMask(MOI->getSubReg()) & LaneMask).none())
1754 if (MOI->isEarlyClobber())
1755 isEarlyClobber =
true;
1759 report(
"Defining instruction does not modify register", MI);
1760 report_context(LR, Reg, LaneMask);
1761 report_context(*VNI);
1766 if (isEarlyClobber) {
1768 report(
"Early clobber def must be at an early-clobber slot", MBB);
1769 report_context(LR, Reg, LaneMask);
1770 report_context(*VNI);
1773 report(
"Non-PHI, non-early clobber def must be at a register slot", MBB);
1774 report_context(LR, Reg, LaneMask);
1775 report_context(*VNI);
1780 void MachineVerifier::verifyLiveRangeSegment(
const LiveRange &LR,
1786 assert(VNI &&
"Live segment has no valno");
1789 report(
"Foreign valno in live segment", MF);
1790 report_context(LR, Reg, LaneMask);
1792 report_context(*VNI);
1796 report(
"Live segment valno is marked unused", MF);
1797 report_context(LR, Reg, LaneMask);
1803 report(
"Bad start of live segment, no basic block", MF);
1804 report_context(LR, Reg, LaneMask);
1808 SlotIndex MBBStartIdx = LiveInts->getMBBStartIdx(MBB);
1810 report(
"Live segment must begin at MBB entry or valno def", MBB);
1811 report_context(LR, Reg, LaneMask);
1818 report(
"Bad end of live segment, no basic block", MF);
1819 report_context(LR, Reg, LaneMask);
1825 if (S.
end == LiveInts->getMBBEndIdx(EndMBB))
1837 report(
"Live segment doesn't end at a valid instruction", EndMBB);
1838 report_context(LR, Reg, LaneMask);
1845 report(
"Live segment ends at B slot of an instruction", EndMBB);
1846 report_context(LR, Reg, LaneMask);
1854 report(
"Live segment ending at dead slot spans instructions", EndMBB);
1855 report_context(LR, Reg, LaneMask);
1863 if (I+1 == LR.
end() || (I+1)->start != S.
end) {
1864 report(
"Live segment ending at early clobber slot must be "
1865 "redefined by an EC def in the same instruction", EndMBB);
1866 report_context(LR, Reg, LaneMask);
1876 bool hasRead =
false;
1877 bool hasSubRegDef =
false;
1878 bool hasDeadDef =
false;
1880 if (!MOI->isReg() || MOI->getReg() !=
Reg)
1882 unsigned Sub = MOI->getSubReg();
1883 LaneBitmask SLM = Sub != 0 ? TRI->getSubRegIndexLaneMask(Sub)
1887 hasSubRegDef =
true;
1896 if (LaneMask.
any() && (LaneMask & SLM).none())
1898 if (MOI->readsReg())
1905 if (LaneMask.
none() && !hasDeadDef) {
1906 report(
"Instruction ending live segment on dead slot has no dead flag",
1908 report_context(LR, Reg, LaneMask);
1915 if (!
MRI->shouldTrackSubRegLiveness(Reg) || LaneMask.
any() ||
1917 report(
"Instruction ending live segment doesn't read the register",
1919 report_context(LR, Reg, LaneMask);
1937 assert(LiveInts->isLiveInToMBB(LR, &*MFI));
1941 if (&*MFI == EndMBB)
1949 VNI->
def == LiveInts->getMBBStartIdx(&*MFI);
1953 PE = MFI->pred_end(); PI != PE; ++PI) {
1954 SlotIndex PEnd = LiveInts->getMBBEndIdx(*PI);
1961 if (!PVNI && (LaneMask.
none() || !IsPHI) ) {
1962 report(
"Register not marked live out of predecessor", *PI);
1963 report_context(LR, Reg, LaneMask);
1964 report_context(*VNI);
1965 errs() <<
" live into BB#" << MFI->getNumber()
1966 <<
'@' << LiveInts->getMBBStartIdx(&*MFI) <<
", not live before "
1972 if (!IsPHI && PVNI != VNI) {
1973 report(
"Different value live out of predecessor", *PI);
1974 report_context(LR, Reg, LaneMask);
1975 errs() <<
"Valno #" << PVNI->
id <<
" live out of BB#"
1976 << (*PI)->getNumber() <<
'@' << PEnd <<
"\nValno #" << VNI->
id
1977 <<
" live into BB#" << MFI->getNumber() <<
'@'
1978 << LiveInts->getMBBStartIdx(&*MFI) <<
'\n';
1981 if (&*MFI == EndMBB)
1987 void MachineVerifier::verifyLiveRange(
const LiveRange &LR,
unsigned Reg,
1990 verifyLiveRangeValue(LR, VNI, Reg, LaneMask);
1993 verifyLiveRangeSegment(LR, I, Reg, LaneMask);
1996 void MachineVerifier::verifyLiveInterval(
const LiveInterval &LI) {
1997 unsigned Reg = LI.
reg;
1999 verifyLiveRange(LI, Reg);
2004 if ((Mask & SR.LaneMask).any()) {
2005 report(
"Lane masks of sub ranges overlap in live interval", MF);
2008 if ((SR.LaneMask & ~MaxMask).any()) {
2009 report(
"Subrange lanemask is invalid", MF);
2013 report(
"Subrange must not be empty", MF);
2014 report_context(SR, LI.
reg, SR.LaneMask);
2016 Mask |= SR.LaneMask;
2017 verifyLiveRange(SR, LI.
reg, SR.LaneMask);
2019 report(
"A Subrange is not covered by the main range", MF);
2026 unsigned NumComp = ConEQ.Classify(LI);
2028 report(
"Multiple connected components in live interval", MF);
2030 for (
unsigned comp = 0; comp != NumComp; ++comp) {
2031 errs() << comp <<
": valnos";
2034 if (comp == ConEQ.getEqClass(*I))
2035 errs() <<
' ' << (*I)->id;
2046 struct StackStateOfBB {
2047 StackStateOfBB() : EntryValue(0), ExitValue(0), EntryIsSetup(
false),
2048 ExitIsSetup(
false) { }
2049 StackStateOfBB(
int EntryVal,
int ExitVal,
bool EntrySetup,
bool ExitSetup) :
2050 EntryValue(EntryVal), ExitValue(ExitVal), EntryIsSetup(EntrySetup),
2051 ExitIsSetup(ExitSetup) { }
2063 void MachineVerifier::verifyStackFrame() {
2064 unsigned FrameSetupOpcode =
TII->getCallFrameSetupOpcode();
2065 unsigned FrameDestroyOpcode =
TII->getCallFrameDestroyOpcode();
2066 if (FrameSetupOpcode == ~0u && FrameDestroyOpcode == ~0u)
2070 SPState.
resize(MF->getNumBlockIDs());
2077 DFI != DFE; ++DFI) {
2080 StackStateOfBB BBState;
2082 if (DFI.getPathLength() >= 2) {
2085 "DFS stack predecessor is already visited.\n");
2086 BBState.EntryValue = SPState[StackPred->
getNumber()].ExitValue;
2087 BBState.EntryIsSetup = SPState[StackPred->
getNumber()].ExitIsSetup;
2088 BBState.ExitValue = BBState.EntryValue;
2089 BBState.ExitIsSetup = BBState.EntryIsSetup;
2093 for (
const auto &I : *MBB) {
2094 if (I.getOpcode() == FrameSetupOpcode) {
2095 if (BBState.ExitIsSetup)
2096 report(
"FrameSetup is after another FrameSetup", &I);
2097 BBState.ExitValue -=
TII->getFrameTotalSize(I);
2098 BBState.ExitIsSetup =
true;
2101 if (I.getOpcode() == FrameDestroyOpcode) {
2102 int Size =
TII->getFrameTotalSize(I);
2103 if (!BBState.ExitIsSetup)
2104 report(
"FrameDestroy is not after a FrameSetup", &I);
2105 int AbsSPAdj = BBState.ExitValue < 0 ? -BBState.ExitValue :
2107 if (BBState.ExitIsSetup && AbsSPAdj != Size) {
2108 report(
"FrameDestroy <n> is after FrameSetup <m>", &I);
2109 errs() <<
"FrameDestroy <" << Size <<
"> is after FrameSetup <"
2110 << AbsSPAdj <<
">.\n";
2112 BBState.ExitValue +=
Size;
2113 BBState.ExitIsSetup =
false;
2116 SPState[MBB->getNumber()] = BBState;
2121 E = MBB->pred_end(); I !=
E; ++
I) {
2122 if (Reachable.
count(*I) &&
2123 (SPState[(*I)->getNumber()].ExitValue != BBState.EntryValue ||
2124 SPState[(*I)->getNumber()].ExitIsSetup != BBState.EntryIsSetup)) {
2125 report(
"The exit stack state of a predecessor is inconsistent.", MBB);
2126 errs() <<
"Predecessor BB#" << (*I)->getNumber() <<
" has exit state ("
2127 << SPState[(*I)->getNumber()].ExitValue <<
", "
2128 << SPState[(*I)->getNumber()].ExitIsSetup
2129 <<
"), while BB#" << MBB->getNumber() <<
" has entry state ("
2130 << BBState.EntryValue <<
", " << BBState.EntryIsSetup <<
").\n";
2137 E = MBB->succ_end(); I !=
E; ++
I) {
2138 if (Reachable.
count(*I) &&
2139 (SPState[(*I)->getNumber()].EntryValue != BBState.ExitValue ||
2140 SPState[(*I)->getNumber()].EntryIsSetup != BBState.ExitIsSetup)) {
2141 report(
"The entry stack state of a successor is inconsistent.", MBB);
2142 errs() <<
"Successor BB#" << (*I)->getNumber() <<
" has entry state ("
2143 << SPState[(*I)->getNumber()].EntryValue <<
", "
2144 << SPState[(*I)->getNumber()].EntryIsSetup
2145 <<
"), while BB#" << MBB->getNumber() <<
" has exit state ("
2146 << BBState.ExitValue <<
", " << BBState.ExitIsSetup <<
").\n";
2151 if (!MBB->empty() && MBB->back().isReturn()) {
2152 if (BBState.ExitIsSetup)
2153 report(
"A return block ends with a FrameSetup.", MBB);
2154 if (BBState.ExitValue)
2155 report(
"A return block ends with a nonzero stack adjustment.", MBB);
Pass interface - Implemented by all 'passes'.
bool isInsideBundle() const
Return true if MI is in a bundle (but not the first MI in a bundle).
unsigned succ_size() const
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
bool isEHPad() const
Returns true if the block is a landing pad.
Safe Stack instrumentation pass
bool verify(Pass *p=nullptr, const char *Banner=nullptr, bool AbortOnError=true) const
Run the current MachineFunction through the machine code verifier, useful for debugger use...
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void print(raw_ostream &os, const TargetRegisterInfo *TRI=nullptr, const TargetIntrinsicInfo *IntrinsicInfo=nullptr) const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
iterator_range< livein_iterator > liveins() const
bool isGenericType() const
SlotIndex def
The index of the defining instruction.
BitVector getPristineRegs(const MachineFunction &MF) const
Return a set of physical registers that are pristine.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
iterator_range< mop_iterator > uses()
Returns a range that includes all operands that are register uses.
bool hasProperty(Property P) const
MachineBasicBlock * getMBB() const
static unsigned index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
iterator_range< const_set_bits_iterator > set_bits() const
static LaneBitmask getAll()
DWARF-like instruction based exceptions.
LiveInterval - This class represents the liveness of a register, or stack slot.
Describe properties that are true of each instruction in the target description file.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
static bool matchPair(MachineBasicBlock::const_succ_iterator i, const MachineBasicBlock *a, const MachineBasicBlock *b)
bool isKill() const
Return true if the live-in value is killed by this instruction.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
A live range for subregisters.
MachineBasicBlock reference.
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
This represents a simple continuous liveness interval for a value.
VarInfo - This represents the regions where a virtual register is live in the program.
bool isRegister() const
isRegister - Returns true if this is a normal register use/def slot.
iterator_range< mmo_iterator > memoperands()
void print(raw_ostream &OS, bool SkipOpers=false, bool SkipDebugLoc=false, const TargetInstrInfo *TII=nullptr) const
Debugging supportPrint this MI to OS.
std::vector< MachineBasicBlock * >::const_iterator const_pred_iterator
VNInfo - Value Number Information.
iterator_range< mop_iterator > operands()
bool isMetadata() const
isMetadata - Tests if this is a MO_Metadata operand.
unsigned getNumValNums() const
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
bool isEarlyClobber() const
isEarlyClobber - Returns true if this is an early-clobber slot.
This class represents the liveness of a register, stack slot, etc.
void initializeMachineVerifierPassPass(PassRegistry &)
Mask of preserved registers.
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...
FunctionPass * createMachineVerifierPass(const std::string &Banner)
createMachineVerifierPass - This pass verifies cenerated machine code instructions for correctness...
A description of a memory reference used in the backend.
void clear()
clear - Removes all bits from the bitvector. Does not change capacity.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information tha...
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
iterator_range< subrange_iterator > subranges()
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
Result of a LiveRange query.
const MachineFunctionProperties & getProperties() const
Get the function properties.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Reg
All possible values of the reg field in the ModR/M byte.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
SmallVectorImpl< IdxMBBPair >::const_iterator MBBIndexIterator
Iterator over the idx2MBBMap (sorted pairs of slot index of basic block begin and basic block) ...
bool isBlock() const
isBlock - Returns true if this is a block boundary slot.
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
SparseBitVector AliveBlocks
AliveBlocks - Set of blocks in which this value is alive completely through.
constexpr bool any() const
LLVM_NODISCARD bool empty() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
bool isUnused() const
Returns true if this value is unused.
const MachineBasicBlock & front() const
bool isDead() const
isDead - Returns true if this is a dead def kill slot.
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
INITIALIZE_PASS(MachineVerifierPass,"machineverifier","Verify generated machine code", false, false) FunctionPass *llvm
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
const MachineBasicBlock * getParent() const
TargetInstrInfo - Interface to description of machine instruction set.
bool isDebugValue() const
This class is intended to be used as a base class for asm properties and features specific to the tar...
mmo_iterator memoperands_end() const
bool isDeadDef() const
Return true if this instruction has a dead def.
bool isEarlyClobber() const
unsigned findTiedOperandIdx(unsigned OpIdx) const
Given the index of a tied register operand, find the operand it is tied to.
Function Alias Analysis false
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
bool isValid() const
Returns true if this is a valid index.
unsigned const MachineRegisterInfo * MRI
VNInfoList::const_iterator const_vni_iterator
LLVM Basic Block Representation.
constexpr bool none() const
df_ext_iterator< T, SetTy > df_ext_end(const T &G, SetTy &S)
bool isOptionalDef() const
Set if this operand is a optional def.
const MachineOperand & getOperand(unsigned i) const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
unsigned getGenericTypeIndex() const
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag...
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
Represent the analysis usage information of a pass.
df_ext_iterator< T, SetTy > df_ext_begin(const T &G, SetTy &S)
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
bool isVariadic(QueryType Type=IgnoreBundle) const
Return true if this instruction can have a variable number of operands.
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
FunctionPass class - This class is used to implement most global optimizations.
ExceptionHandling getExceptionHandlingType() const
std::vector< MachineBasicBlock * >::const_iterator const_succ_iterator
self_iterator getIterator()
LLVM_NODISCARD bool empty() const
succ_iterator succ_begin()
unsigned getSubReg() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
pred_iterator pred_begin()
MCSubRegIterator enumerates all sub-registers of Reg.
bool liveAt(SlotIndex index) const
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specific constraint if it is set.
bool isPredicated(const MachineInstr &MI) const override
Returns true if the instruction is already predicated.
unsigned getOpcode() const
Return the opcode number for this descriptor.
const char * getName() const
Get a user friendly name of this register bank.
std::vector< MachineInstr * > Kills
Kills - List of MachineInstruction's which are the last use of this virtual register (kill it) in the...
unsigned id
The ID number of this value.
Iterator for intrusive lists based on ilist_node.
Printable PrintRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
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...
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
Segments::const_iterator const_iterator
ConnectedVNInfoEqClasses - Helper class that can divide VNInfos in a LiveInterval into equivalence cl...
MachineOperand class - Representation of each machine instruction operand.
static LaneBitmask getNone()
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
This class implements the register bank concept.
int getFrameIndex() const
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
Special value supplied for machine level alias analysis.
static bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel...
void setPreservesAll()
Set by analyses that do not transform their input at all.
Base class for user error types.
VNInfo * getValNumInfo(unsigned ValNo)
getValNumInfo - Returns pointer to the specified val#.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
void set_subtract(S1Ty &S1, const S2Ty &S2)
set_subtract(A, B) - Compute A := A - B
Representation of each machine instruction.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
MI-level Statepoint operands.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getSize() const
Get the maximal size in bits that fits in this register bank.
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream...
INITIALIZE_PASS(HexagonGenMux,"hexagon-gen-mux","Hexagon generate mux instructions", false, false) void HexagonGenMux I isValid()
Abstract Stack Frame Index.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def...
unsigned getReg() const
getReg - Returns the register number.
bool isValid() const
isValid - Returns true until all the operands have been visited.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual const TargetInstrInfo * getInstrInfo() const
LLVM Value Representation.
static LLVM_ATTRIBUTE_UNUSED Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const MCOperandInfo * OpInfo
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Primary interface to the complete machine description for the target machine.
static bool isLiveOut(const MachineBasicBlock &MBB, unsigned Reg)
bool isRegTiedToDefOperand(unsigned UseOpIdx, unsigned *DefOpIdx=nullptr) const
Return true if the use operand of the specified index is tied to a def operand.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
unsigned getVarIdx() const
Get starting index of non call related arguments (calling convention, statepoint flags, vm state and gc state).
StringRef - Represent a constant reference to a string, i.e.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
A specialized PseudoSourceValue for holding FixedStack values, which must include a frame index...
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
VNInfo * valueIn() const
Return the value that is live-in to the instruction.
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
This holds information about one operand of a machine instruction, indicating the register class for ...
bool hasSubRanges() const
Returns true if subregister liveness information is available.
SlotIndex - An opaque wrapper around machine indexes.
Instructions::const_iterator const_instr_iterator
bool covers(const LiveRange &Other) const
Returns true if all segments of the Other live range are completely covered by this live range...
bool set_union(S1Ty &S1, const S2Ty &S2)
set_union(A, B) - Compute A := A u B, return whether A changed.
unsigned pred_size() const
bool isBarrier(QueryType Type=AnyInBundle) const
Returns true if the specified instruction stops control flow from executing the instruction immediate...
VNInfo * getVNInfoBefore(SlotIndex Idx) const
getVNInfoBefore - Return the VNInfo that is live up to but not necessarilly including Idx...
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.