95 struct MachineVerifier {
96 MachineVerifier(
Pass *
pass,
const char *b) : PASS(
pass), Banner(
b) {}
101 : Banner(
b), LiveVars(LiveVars), LiveInts(LiveInts), LiveStks(LiveStks),
106 Pass *
const PASS =
nullptr;
115 unsigned foundErrors = 0;
118 bool isFunctionRegBankSelected =
false;
119 bool isFunctionSelected =
false;
120 bool isFunctionTracksDebugUserValues =
false;
130 BlockSet FunctionBlocks;
134 RegVector regsDefined, regsDead, regsKilled;
135 RegMaskVector regMasks;
140 void addRegWithSubRegs(RegVector &RV,
Register Reg) {
142 if (
Reg.isPhysical())
148 bool reachable =
false;
169 RegSet vregsRequired;
172 BlockSet Preds, Succs;
179 if (!
Reg.isVirtual())
181 if (regsLiveOut.count(Reg))
183 return vregsRequired.insert(Reg).second;
187 bool addRequired(
const RegSet &RS) {
188 bool Changed =
false;
190 Changed |= addRequired(Reg);
195 bool addRequired(
const RegMap &RM) {
196 bool Changed =
false;
197 for (
const auto &
I : RM)
198 Changed |= addRequired(
I.first);
204 return regsLiveOut.count(Reg) || vregsPassed.count(Reg);
212 return Reg.id() < regsReserved.
size() && regsReserved.
test(
Reg.id());
215 bool isAllocatable(
Register Reg)
const {
216 return Reg.id() <
TRI->getNumRegs() &&
TRI->isInAllocatableClass(Reg) &&
231 void visitMachineFunctionBefore();
247 void visitMachineOperand(
const MachineOperand *MO,
unsigned MONum);
250 void visitMachineFunctionAfter();
255 void report(
const char *msg,
const MachineOperand *MO,
unsigned MONum,
263 void report_context(
const VNInfo &VNI)
const;
264 void report_context(
SlotIndex Pos)
const;
265 void report_context(
MCPhysReg PhysReg)
const;
266 void report_context_liverange(
const LiveRange &LR)
const;
267 void report_context_lanemask(
LaneBitmask LaneMask)
const;
268 void report_context_vreg(
Register VReg)
const;
269 void report_context_vreg_regunit(
Register VRegOrUnit)
const;
280 Register VRegOrUnit,
bool SubRangeCheck =
false,
284 void calcRegsPassed();
287 void calcRegsRequired();
288 void verifyLiveVariables();
289 void verifyLiveIntervals();
293 void verifyLiveRangeSegment(
const LiveRange &,
299 void verifyStackFrame();
301 void verifySlotIndexes()
const;
308 const std::string Banner;
310 MachineVerifierPass(std::string banner = std::string())
329 MachineFunctionProperties::Property::FailsVerification))
332 unsigned FoundErrors = MachineVerifier(
this, Banner.c_str()).verify(MF);
341char MachineVerifierPass::ID = 0;
344 "Verify generated machine code",
false,
false)
347 return new MachineVerifierPass(Banner);
357 unsigned FoundErrors = MachineVerifier(
nullptr, Banner.c_str()).verify(MF);
365 unsigned FoundErrors = MachineVerifier(p, Banner).verify(MF);
366 if (AbortOnErrors && FoundErrors)
368 return FoundErrors == 0;
372 const char *Banner,
bool AbortOnErrors)
const {
374 unsigned FoundErrors =
375 MachineVerifier(Banner,
nullptr, LiveInts,
nullptr, Indexes).verify(MF);
376 if (AbortOnErrors && FoundErrors)
378 return FoundErrors == 0;
381void MachineVerifier::verifySlotIndexes()
const {
382 if (Indexes ==
nullptr)
400 MRI->getNumVirtRegs())
401 report(
"Function has NoVRegs property but there are VReg operands", &MF);
420 if (isFunctionFailedISel)
441 verifyProperties(MF);
443 visitMachineFunctionBefore();
445 visitMachineBasicBlockBefore(&
MBB);
449 bool InBundle =
false;
452 if (
MI.getParent() != &
MBB) {
453 report(
"Bad instruction parent pointer", &
MBB);
454 errs() <<
"Instruction: " <<
MI;
459 if (InBundle && !
MI.isBundledWithPred())
460 report(
"Missing BundledPred flag, "
461 "BundledSucc was set on predecessor",
463 if (!InBundle &&
MI.isBundledWithPred())
464 report(
"BundledPred flag is set, "
465 "but BundledSucc not set on predecessor",
469 if (!
MI.isInsideBundle()) {
471 visitMachineBundleAfter(CurBundle);
473 visitMachineBundleBefore(CurBundle);
474 }
else if (!CurBundle)
475 report(
"No bundle header", &
MI);
476 visitMachineInstrBefore(&
MI);
477 for (
unsigned I = 0, E =
MI.getNumOperands();
I != E; ++
I) {
479 if (
Op.getParent() != &
MI) {
482 report(
"Instruction has operand with wrong parent set", &
MI);
485 visitMachineOperand(&
Op,
I);
489 InBundle =
MI.isBundledWithSucc();
492 visitMachineBundleAfter(CurBundle);
494 report(
"BundledSucc flag set on last instruction in block", &
MBB.
back());
495 visitMachineBasicBlockAfter(&
MBB);
497 visitMachineFunctionAfter();
510void MachineVerifier::report(
const char *msg,
const MachineFunction *MF) {
513 if (!foundErrors++) {
515 errs() <<
"# " << Banner <<
'\n';
516 if (LiveInts !=
nullptr)
521 errs() <<
"*** Bad machine code: " << msg <<
" ***\n"
522 <<
"- function: " << MF->
getName() <<
"\n";
536void MachineVerifier::report(
const char *msg,
const MachineInstr *
MI) {
538 report(msg,
MI->getParent());
539 errs() <<
"- instruction: ";
545void MachineVerifier::report(
const char *msg,
const MachineOperand *MO,
546 unsigned MONum,
LLT MOVRegType) {
549 errs() <<
"- operand " << MONum <<
": ";
555 report(Msg.
str().c_str(),
MI);
558void MachineVerifier::report_context(
SlotIndex Pos)
const {
559 errs() <<
"- at: " << Pos <<
'\n';
562void MachineVerifier::report_context(
const LiveInterval &LI)
const {
563 errs() <<
"- interval: " << LI <<
'\n';
568 report_context_liverange(LR);
569 report_context_vreg_regunit(VRegUnit);
571 report_context_lanemask(LaneMask);
575 errs() <<
"- segment: " << S <<
'\n';
578void MachineVerifier::report_context(
const VNInfo &VNI)
const {
579 errs() <<
"- ValNo: " << VNI.
id <<
" (def " << VNI.
def <<
")\n";
582void MachineVerifier::report_context_liverange(
const LiveRange &LR)
const {
583 errs() <<
"- liverange: " << LR <<
'\n';
586void MachineVerifier::report_context(
MCPhysReg PReg)
const {
590void MachineVerifier::report_context_vreg(
Register VReg)
const {
594void MachineVerifier::report_context_vreg_regunit(
Register VRegOrUnit)
const {
596 report_context_vreg(VRegOrUnit);
602void MachineVerifier::report_context_lanemask(
LaneBitmask LaneMask)
const {
607 BBInfo &MInfo = MBBInfoMap[
MBB];
608 if (!MInfo.reachable) {
609 MInfo.reachable =
true;
615void MachineVerifier::visitMachineFunctionBefore() {
617 regsReserved =
MRI->reservedRegsFrozen() ?
MRI->getReservedRegs()
618 :
TRI->getReservedRegs(*MF);
621 markReachable(&MF->
front());
624 FunctionBlocks.clear();
625 for (
const auto &
MBB : *MF) {
626 FunctionBlocks.insert(&
MBB);
627 BBInfo &MInfo = MBBInfoMap[&
MBB];
631 report(
"MBB has duplicate entries in its predecessor list.", &
MBB);
635 report(
"MBB has duplicate entries in its successor list.", &
MBB);
639 MRI->verifyUseLists();
647 FirstTerminator =
nullptr;
648 FirstNonPHI =
nullptr;
650 if (!MF->getProperties().hasProperty(
655 if (isAllocatable(LI.PhysReg) && !
MBB->
isEHPad() &&
658 report(
"MBB has allocatable live-in, but isn't entry, landing-pad, or "
659 "inlineasm-br-indirect-target.",
661 report_context(LI.PhysReg);
668 report(
"ir-block-address-taken is associated with basic block not used by "
677 LandingPadSuccs.
insert(succ);
678 if (!FunctionBlocks.count(succ))
679 report(
"MBB has successor that isn't part of the function.",
MBB);
680 if (!MBBInfoMap[succ].Preds.count(
MBB)) {
681 report(
"Inconsistent CFG",
MBB);
682 errs() <<
"MBB is not in the predecessor list of the successor "
689 if (!FunctionBlocks.count(Pred))
690 report(
"MBB has predecessor that isn't part of the function.",
MBB);
691 if (!MBBInfoMap[Pred].Succs.count(
MBB)) {
692 report(
"Inconsistent CFG",
MBB);
693 errs() <<
"MBB is not in the successor list of the predecessor "
701 if (LandingPadSuccs.
size() > 1 &&
706 report(
"MBB has more than one landing pad successor",
MBB);
719 report(
"MBB exits via unconditional fall-through but ends with a "
720 "barrier instruction!",
MBB);
723 report(
"MBB exits via unconditional fall-through but has a condition!",
726 }
else if (
TBB && !FBB &&
Cond.empty()) {
729 report(
"MBB exits via unconditional branch but doesn't contain "
730 "any instructions!",
MBB);
732 report(
"MBB exits via unconditional branch but doesn't end with a "
733 "barrier instruction!",
MBB);
735 report(
"MBB exits via unconditional branch but the branch isn't a "
736 "terminator instruction!",
MBB);
738 }
else if (
TBB && !FBB && !
Cond.empty()) {
741 report(
"MBB exits via conditional branch/fall-through but doesn't "
742 "contain any instructions!",
MBB);
744 report(
"MBB exits via conditional branch/fall-through but ends with a "
745 "barrier instruction!",
MBB);
747 report(
"MBB exits via conditional branch/fall-through but the branch "
748 "isn't a terminator instruction!",
MBB);
750 }
else if (
TBB && FBB) {
754 report(
"MBB exits via conditional branch/branch but doesn't "
755 "contain any instructions!",
MBB);
757 report(
"MBB exits via conditional branch/branch but doesn't end with a "
758 "barrier instruction!",
MBB);
760 report(
"MBB exits via conditional branch/branch but the branch "
761 "isn't a terminator instruction!",
MBB);
764 report(
"MBB exits via conditional branch/branch but there's no "
768 report(
"analyzeBranch returned invalid data!",
MBB);
774 report(
"MBB exits via jump or conditional branch, but its target isn't a "
778 report(
"MBB exits via conditional branch, but its target isn't a CFG "
785 bool Fallthrough = !
TBB || (!
Cond.empty() && !FBB);
790 if (!
Cond.empty() && !FBB) {
793 report(
"MBB conditionally falls through out of function!",
MBB);
795 report(
"MBB exits via conditional branch/fall-through but the CFG "
796 "successors don't match the actual successors!",
803 if (SuccMBB ==
TBB || SuccMBB == FBB)
811 if (SuccMBB->isEHPad() || SuccMBB->isInlineAsmBrIndirectTarget())
813 report(
"MBB has unexpected successors which are not branch targets, "
814 "fallthrough, EHPads, or inlineasm_br targets.",
820 if (
MRI->tracksLiveness()) {
823 report(
"MBB live-in list contains non-physical register",
MBB);
847void MachineVerifier::visitMachineBundleBefore(
const MachineInstr *
MI) {
850 if (!(idx > lastIndex)) {
851 report(
"Instruction index out of order",
MI);
852 errs() <<
"Last instruction was at " << lastIndex <<
'\n';
858 if (
MI->isTerminator()) {
859 if (!FirstTerminator)
860 FirstTerminator =
MI;
861 }
else if (FirstTerminator) {
864 if (FirstTerminator->
getOpcode() != TargetOpcode::G_INVOKE_REGION_START) {
865 report(
"Non-terminator instruction after the first terminator",
MI);
866 errs() <<
"First terminator was:\t" << *FirstTerminator;
875 if (
MI->getNumOperands() < 2) {
876 report(
"Too few operands on inline asm",
MI);
879 if (!
MI->getOperand(0).isSymbol())
880 report(
"Asm string must be an external symbol",
MI);
881 if (!
MI->getOperand(1).isImm())
882 report(
"Asm flags must be an immediate",
MI);
886 if (!isUInt<6>(
MI->getOperand(1).getImm()))
887 report(
"Unknown asm flags", &
MI->getOperand(1), 1);
893 for (
unsigned e =
MI->getNumOperands(); OpNo <
e; OpNo += NumOps) {
899 NumOps = 1 +
F.getNumOperandRegisters();
902 if (OpNo >
MI->getNumOperands())
903 report(
"Missing operands in last group",
MI);
906 if (OpNo < MI->getNumOperands() &&
MI->getOperand(OpNo).isMetadata())
910 for (
unsigned e =
MI->getNumOperands(); OpNo < e; ++OpNo) {
913 report(
"Expected implicit register after groups", &MO, OpNo);
916 if (
MI->getOpcode() == TargetOpcode::INLINEASM_BR) {
929 if (!IndirectTargetMBB) {
930 report(
"INLINEASM_BR indirect target does not exist", &MO, i);
935 report(
"INLINEASM_BR indirect target missing from successor list", &MO,
939 report(
"INLINEASM_BR indirect target predecessor list missing parent",
945bool MachineVerifier::verifyAllRegOpsScalar(
const MachineInstr &
MI,
950 const auto Reg = Op.getReg();
951 if (Reg.isPhysical())
953 return !MRI.getType(Reg).isScalar();
956 report(
"All register operands must have scalar types", &
MI);
963bool MachineVerifier::verifyVectorElementMatch(
LLT Ty0,
LLT Ty1,
966 report(
"operand types must be all-vector or all-scalar",
MI);
976 report(
"operand types must preserve number of vector elements",
MI);
983bool MachineVerifier::verifyGIntrinsicSideEffects(
const MachineInstr *
MI) {
984 auto Opcode =
MI->getOpcode();
985 bool NoSideEffects = Opcode == TargetOpcode::G_INTRINSIC ||
986 Opcode == TargetOpcode::G_INTRINSIC_CONVERGENT;
987 unsigned IntrID = cast<GIntrinsic>(
MI)->getIntrinsicID();
988 if (IntrID != 0 && IntrID < Intrinsic::num_intrinsics) {
990 MF->getFunction().getContext(),
static_cast<Intrinsic::ID>(IntrID));
991 bool DeclHasSideEffects = !
Attrs.getMemoryEffects().doesNotAccessMemory();
992 if (NoSideEffects && DeclHasSideEffects) {
994 " used with intrinsic that accesses memory"),
998 if (!NoSideEffects && !DeclHasSideEffects) {
999 report(
Twine(
TII->getName(Opcode),
" used with readnone intrinsic"),
MI);
1007bool MachineVerifier::verifyGIntrinsicConvergence(
const MachineInstr *
MI) {
1008 auto Opcode =
MI->getOpcode();
1009 bool NotConvergent = Opcode == TargetOpcode::G_INTRINSIC ||
1010 Opcode == TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS;
1011 unsigned IntrID = cast<GIntrinsic>(
MI)->getIntrinsicID();
1012 if (IntrID != 0 && IntrID < Intrinsic::num_intrinsics) {
1014 MF->getFunction().getContext(),
static_cast<Intrinsic::ID>(IntrID));
1015 bool DeclIsConvergent =
Attrs.hasFnAttr(Attribute::Convergent);
1016 if (NotConvergent && DeclIsConvergent) {
1017 report(
Twine(
TII->getName(Opcode),
" used with a convergent intrinsic"),
1021 if (!NotConvergent && !DeclIsConvergent) {
1023 Twine(
TII->getName(Opcode),
" used with a non-convergent intrinsic"),
1032void MachineVerifier::verifyPreISelGenericInstruction(
const MachineInstr *
MI) {
1033 if (isFunctionSelected)
1034 report(
"Unexpected generic instruction in a Selected function",
MI);
1037 unsigned NumOps =
MI->getNumOperands();
1040 if (
MI->isBranch() && !
MI->isIndirectBranch()) {
1041 bool HasMBB =
false;
1050 report(
"Branch instruction is missing a basic block operand or "
1051 "isIndirectBranch property",
1060 if (!MCID.
operands()[
I].isGenericType())
1064 size_t TypeIdx = MCID.
operands()[
I].getGenericTypeIndex();
1065 Types.resize(std::max(TypeIdx + 1,
Types.size()));
1069 report(
"generic instruction must use register operands",
MI);
1079 if (!Types[TypeIdx].
isValid())
1080 Types[TypeIdx] = OpTy;
1081 else if (Types[TypeIdx] != OpTy)
1082 report(
"Type mismatch in generic instruction", MO,
I, OpTy);
1085 report(
"Generic instruction is missing a virtual register type", MO,
I);
1090 for (
unsigned I = 0;
I <
MI->getNumOperands(); ++
I) {
1093 report(
"Generic instruction cannot have physical register", MO,
I);
1105 unsigned Opc =
MI->getOpcode();
1107 case TargetOpcode::G_ASSERT_SEXT:
1108 case TargetOpcode::G_ASSERT_ZEXT: {
1109 std::string OpcName =
1110 Opc == TargetOpcode::G_ASSERT_ZEXT ?
"G_ASSERT_ZEXT" :
"G_ASSERT_SEXT";
1111 if (!
MI->getOperand(2).isImm()) {
1112 report(
Twine(OpcName,
" expects an immediate operand #2"),
MI);
1118 LLT SrcTy =
MRI->getType(Src);
1119 int64_t
Imm =
MI->getOperand(2).getImm();
1121 report(
Twine(OpcName,
" size must be >= 1"),
MI);
1126 report(
Twine(OpcName,
" size must be less than source bit width"),
MI);
1134 if ((SrcRB && DstRB && SrcRB != DstRB) || (DstRB && !SrcRB)) {
1135 report(
Twine(OpcName,
" cannot change register bank"),
MI);
1141 if (DstRC && DstRC !=
MRI->getRegClassOrNull(Src)) {
1143 Twine(OpcName,
" source and destination register classes must match"),
1151 case TargetOpcode::G_CONSTANT:
1152 case TargetOpcode::G_FCONSTANT: {
1153 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1155 report(
"Instruction cannot use a vector result type",
MI);
1157 if (
MI->getOpcode() == TargetOpcode::G_CONSTANT) {
1158 if (!
MI->getOperand(1).isCImm()) {
1159 report(
"G_CONSTANT operand must be cimm",
MI);
1165 report(
"inconsistent constant size",
MI);
1167 if (!
MI->getOperand(1).isFPImm()) {
1168 report(
"G_FCONSTANT operand must be fpimm",
MI);
1175 report(
"inconsistent constant size",
MI);
1181 case TargetOpcode::G_LOAD:
1182 case TargetOpcode::G_STORE:
1183 case TargetOpcode::G_ZEXTLOAD:
1184 case TargetOpcode::G_SEXTLOAD: {
1185 LLT ValTy =
MRI->getType(
MI->getOperand(0).getReg());
1186 LLT PtrTy =
MRI->getType(
MI->getOperand(1).getReg());
1188 report(
"Generic memory instruction must access a pointer",
MI);
1192 if (!
MI->hasOneMemOperand()) {
1193 report(
"Generic instruction accessing memory must have one mem operand",
1197 if (
MI->getOpcode() == TargetOpcode::G_ZEXTLOAD ||
1198 MI->getOpcode() == TargetOpcode::G_SEXTLOAD) {
1201 report(
"Generic extload must have a narrower memory type",
MI);
1202 }
else if (
MI->getOpcode() == TargetOpcode::G_LOAD) {
1205 report(
"load memory size cannot exceed result size",
MI);
1206 }
else if (
MI->getOpcode() == TargetOpcode::G_STORE) {
1209 report(
"store memory size cannot exceed value size",
MI);
1213 if (Opc == TargetOpcode::G_STORE) {
1216 report(
"atomic store cannot use acquire ordering",
MI);
1221 report(
"atomic load cannot use release ordering",
MI);
1227 case TargetOpcode::G_PHI: {
1228 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1233 LLT Ty = MRI->getType(MO.getReg());
1234 if (!Ty.isValid() || (Ty != DstTy))
1238 report(
"Generic Instruction G_PHI has operands with incompatible/missing "
1243 case TargetOpcode::G_BITCAST: {
1244 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1245 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
1250 report(
"bitcast cannot convert between pointers and other types",
MI);
1253 report(
"bitcast sizes must match",
MI);
1256 report(
"bitcast must change the type",
MI);
1260 case TargetOpcode::G_INTTOPTR:
1261 case TargetOpcode::G_PTRTOINT:
1262 case TargetOpcode::G_ADDRSPACE_CAST: {
1263 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1264 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
1268 verifyVectorElementMatch(DstTy, SrcTy,
MI);
1273 if (
MI->getOpcode() == TargetOpcode::G_INTTOPTR) {
1275 report(
"inttoptr result type must be a pointer",
MI);
1277 report(
"inttoptr source type must not be a pointer",
MI);
1278 }
else if (
MI->getOpcode() == TargetOpcode::G_PTRTOINT) {
1280 report(
"ptrtoint source type must be a pointer",
MI);
1282 report(
"ptrtoint result type must not be a pointer",
MI);
1284 assert(
MI->getOpcode() == TargetOpcode::G_ADDRSPACE_CAST);
1286 report(
"addrspacecast types must be pointers",
MI);
1289 report(
"addrspacecast must convert different address spaces",
MI);
1295 case TargetOpcode::G_PTR_ADD: {
1296 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1297 LLT PtrTy =
MRI->getType(
MI->getOperand(1).getReg());
1298 LLT OffsetTy =
MRI->getType(
MI->getOperand(2).getReg());
1303 report(
"gep first operand must be a pointer",
MI);
1306 report(
"gep offset operand must not be a pointer",
MI);
1311 unsigned IndexSizeInBits =
DL.getIndexSize(AS) * 8;
1313 report(
"gep offset operand must match index size for address space",
1321 case TargetOpcode::G_PTRMASK: {
1322 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1323 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
1324 LLT MaskTy =
MRI->getType(
MI->getOperand(2).getReg());
1329 report(
"ptrmask result type must be a pointer",
MI);
1332 report(
"ptrmask mask type must be an integer",
MI);
1334 verifyVectorElementMatch(DstTy, MaskTy,
MI);
1337 case TargetOpcode::G_SEXT:
1338 case TargetOpcode::G_ZEXT:
1339 case TargetOpcode::G_ANYEXT:
1340 case TargetOpcode::G_TRUNC:
1341 case TargetOpcode::G_FPEXT:
1342 case TargetOpcode::G_FPTRUNC: {
1349 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1350 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
1355 report(
"Generic extend/truncate can not operate on pointers",
MI);
1357 verifyVectorElementMatch(DstTy, SrcTy,
MI);
1361 switch (
MI->getOpcode()) {
1363 if (DstSize <= SrcSize)
1364 report(
"Generic extend has destination type no larger than source",
MI);
1366 case TargetOpcode::G_TRUNC:
1367 case TargetOpcode::G_FPTRUNC:
1368 if (DstSize >= SrcSize)
1369 report(
"Generic truncate has destination type no smaller than source",
1375 case TargetOpcode::G_SELECT: {
1376 LLT SelTy =
MRI->getType(
MI->getOperand(0).getReg());
1377 LLT CondTy =
MRI->getType(
MI->getOperand(1).getReg());
1383 verifyVectorElementMatch(SelTy, CondTy,
MI);
1386 case TargetOpcode::G_MERGE_VALUES: {
1391 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1392 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
1394 report(
"G_MERGE_VALUES cannot operate on vectors",
MI);
1396 const unsigned NumOps =
MI->getNumOperands();
1398 report(
"G_MERGE_VALUES result size is inconsistent",
MI);
1400 for (
unsigned I = 2;
I != NumOps; ++
I) {
1401 if (
MRI->getType(
MI->getOperand(
I).getReg()) != SrcTy)
1402 report(
"G_MERGE_VALUES source types do not match",
MI);
1407 case TargetOpcode::G_UNMERGE_VALUES: {
1408 unsigned NumDsts =
MI->getNumOperands() - 1;
1409 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1410 for (
unsigned i = 1; i < NumDsts; ++i) {
1411 if (
MRI->getType(
MI->getOperand(i).getReg()) != DstTy) {
1412 report(
"G_UNMERGE_VALUES destination types do not match",
MI);
1417 LLT SrcTy =
MRI->getType(
MI->getOperand(NumDsts).getReg());
1423 report(
"G_UNMERGE_VALUES source operand does not match vector "
1424 "destination operands",
1431 report(
"G_UNMERGE_VALUES vector source operand does not match scalar "
1432 "destination operands",
1437 report(
"G_UNMERGE_VALUES scalar source operand does not match scalar "
1438 "destination operands",
1444 case TargetOpcode::G_BUILD_VECTOR: {
1447 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1448 LLT SrcEltTy =
MRI->getType(
MI->getOperand(1).getReg());
1450 report(
"G_BUILD_VECTOR must produce a vector from scalar operands",
MI);
1455 report(
"G_BUILD_VECTOR result element type must match source type",
MI);
1458 report(
"G_BUILD_VECTOR must have an operand for each elemement",
MI);
1461 if (
MRI->getType(
MI->getOperand(1).getReg()) !=
MRI->getType(MO.
getReg()))
1462 report(
"G_BUILD_VECTOR source operand types are not homogeneous",
MI);
1466 case TargetOpcode::G_BUILD_VECTOR_TRUNC: {
1469 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1470 LLT SrcEltTy =
MRI->getType(
MI->getOperand(1).getReg());
1472 report(
"G_BUILD_VECTOR_TRUNC must produce a vector from scalar operands",
1475 if (
MRI->getType(
MI->getOperand(1).getReg()) !=
MRI->getType(MO.
getReg()))
1476 report(
"G_BUILD_VECTOR_TRUNC source operand types are not homogeneous",
1479 report(
"G_BUILD_VECTOR_TRUNC source operand types are not larger than "
1484 case TargetOpcode::G_CONCAT_VECTORS: {
1487 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1488 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
1490 report(
"G_CONCAT_VECTOR requires vector source and destination operands",
1493 if (
MI->getNumOperands() < 3)
1494 report(
"G_CONCAT_VECTOR requires at least 2 source operands",
MI);
1497 if (
MRI->getType(
MI->getOperand(1).getReg()) !=
MRI->getType(MO.
getReg()))
1498 report(
"G_CONCAT_VECTOR source operand types are not homogeneous",
MI);
1501 report(
"G_CONCAT_VECTOR num dest and source elements should match",
MI);
1504 case TargetOpcode::G_ICMP:
1505 case TargetOpcode::G_FCMP: {
1506 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1507 LLT SrcTy =
MRI->getType(
MI->getOperand(2).getReg());
1512 report(
"Generic vector icmp/fcmp must preserve number of lanes",
MI);
1516 case TargetOpcode::G_EXTRACT: {
1518 if (!
SrcOp.isReg()) {
1519 report(
"extract source must be a register",
MI);
1524 if (!OffsetOp.
isImm()) {
1525 report(
"extract offset must be a constant",
MI);
1529 unsigned DstSize =
MRI->getType(
MI->getOperand(0).getReg()).getSizeInBits();
1531 if (SrcSize == DstSize)
1532 report(
"extract source must be larger than result",
MI);
1534 if (DstSize + OffsetOp.
getImm() > SrcSize)
1535 report(
"extract reads past end of register",
MI);
1538 case TargetOpcode::G_INSERT: {
1540 if (!
SrcOp.isReg()) {
1541 report(
"insert source must be a register",
MI);
1546 if (!OffsetOp.
isImm()) {
1547 report(
"insert offset must be a constant",
MI);
1551 unsigned DstSize =
MRI->getType(
MI->getOperand(0).getReg()).getSizeInBits();
1554 if (DstSize <= SrcSize)
1555 report(
"inserted size must be smaller than total register",
MI);
1557 if (SrcSize + OffsetOp.
getImm() > DstSize)
1558 report(
"insert writes past end of register",
MI);
1562 case TargetOpcode::G_JUMP_TABLE: {
1563 if (!
MI->getOperand(1).isJTI())
1564 report(
"G_JUMP_TABLE source operand must be a jump table index",
MI);
1565 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1567 report(
"G_JUMP_TABLE dest operand must have a pointer type",
MI);
1570 case TargetOpcode::G_BRJT: {
1571 if (!
MRI->getType(
MI->getOperand(0).getReg()).isPointer())
1572 report(
"G_BRJT src operand 0 must be a pointer type",
MI);
1574 if (!
MI->getOperand(1).isJTI())
1575 report(
"G_BRJT src operand 1 must be a jump table index",
MI);
1577 const auto &IdxOp =
MI->getOperand(2);
1578 if (!IdxOp.isReg() ||
MRI->getType(IdxOp.getReg()).isPointer())
1579 report(
"G_BRJT src operand 2 must be a scalar reg type",
MI);
1582 case TargetOpcode::G_INTRINSIC:
1583 case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS:
1584 case TargetOpcode::G_INTRINSIC_CONVERGENT:
1585 case TargetOpcode::G_INTRINSIC_CONVERGENT_W_SIDE_EFFECTS: {
1590 report(
"G_INTRINSIC first src operand must be an intrinsic ID",
MI);
1594 if (!verifyGIntrinsicSideEffects(
MI))
1596 if (!verifyGIntrinsicConvergence(
MI))
1601 case TargetOpcode::G_SEXT_INREG: {
1602 if (!
MI->getOperand(2).isImm()) {
1603 report(
"G_SEXT_INREG expects an immediate operand #2",
MI);
1607 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
1608 int64_t
Imm =
MI->getOperand(2).getImm();
1610 report(
"G_SEXT_INREG size must be >= 1",
MI);
1612 report(
"G_SEXT_INREG size must be less than source bit width",
MI);
1615 case TargetOpcode::G_BSWAP: {
1616 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1618 report(
"G_BSWAP size must be a multiple of 16 bits",
MI);
1621 case TargetOpcode::G_VSCALE: {
1622 if (!
MI->getOperand(1).isCImm()) {
1623 report(
"G_VSCALE operand must be cimm",
MI);
1626 if (
MI->getOperand(1).getCImm()->isZero()) {
1627 report(
"G_VSCALE immediate cannot be zero",
MI);
1632 case TargetOpcode::G_INSERT_SUBVECTOR: {
1634 if (!Src0Op.
isReg()) {
1635 report(
"G_INSERT_SUBVECTOR first source must be a register",
MI);
1640 if (!Src1Op.
isReg()) {
1641 report(
"G_INSERT_SUBVECTOR second source must be a register",
MI);
1646 if (!IndexOp.
isImm()) {
1647 report(
"G_INSERT_SUBVECTOR index must be an immediate",
MI);
1651 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1656 report(
"Destination type must be a vector",
MI);
1661 report(
"First source must be a vector",
MI);
1666 report(
"Second source must be a vector",
MI);
1670 if (DstTy != Src0Ty) {
1671 report(
"Destination type must match the first source vector type",
MI);
1676 report(
"Element type of source vectors must be the same",
MI);
1680 if (IndexOp.
getImm() != 0 &&
1682 report(
"Index must be a multiple of the second source vector's "
1683 "minimum vector length",
1689 case TargetOpcode::G_EXTRACT_SUBVECTOR: {
1691 if (!
SrcOp.isReg()) {
1692 report(
"G_EXTRACT_SUBVECTOR first source must be a register",
MI);
1697 if (!IndexOp.
isImm()) {
1698 report(
"G_EXTRACT_SUBVECTOR index must be an immediate",
MI);
1702 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1706 report(
"Destination type must be a vector",
MI);
1711 report(
"First source must be a vector",
MI);
1716 report(
"Element type of vectors must be the same",
MI);
1720 if (IndexOp.
getImm() != 0 &&
1722 report(
"Index must be a multiple of the source vector's minimum vector "
1730 case TargetOpcode::G_SHUFFLE_VECTOR: {
1733 report(
"Incorrect mask operand type for G_SHUFFLE_VECTOR",
MI);
1737 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1738 LLT Src0Ty =
MRI->getType(
MI->getOperand(1).getReg());
1739 LLT Src1Ty =
MRI->getType(
MI->getOperand(2).getReg());
1741 if (Src0Ty != Src1Ty)
1742 report(
"Source operands must be the same type",
MI);
1745 report(
"G_SHUFFLE_VECTOR cannot change element type",
MI);
1754 if (
static_cast<int>(MaskIdxes.
size()) != DstNumElts)
1755 report(
"Wrong result type for shufflemask",
MI);
1757 for (
int Idx : MaskIdxes) {
1761 if (
Idx >= 2 * SrcNumElts)
1762 report(
"Out of bounds shuffle index",
MI);
1768 case TargetOpcode::G_SPLAT_VECTOR: {
1769 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1770 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
1773 report(
"Destination type must be a scalable vector",
MI);
1778 report(
"Source type must be a scalar",
MI);
1784 report(
"Element type of the destination must be the same size or smaller "
1785 "than the source type",
1792 case TargetOpcode::G_EXTRACT_VECTOR_ELT: {
1793 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1794 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
1795 LLT IdxTy =
MRI->getType(
MI->getOperand(2).getReg());
1798 report(
"Destination type must be a scalar or pointer",
MI);
1803 report(
"First source must be a vector",
MI);
1807 auto TLI = MF->getSubtarget().getTargetLowering();
1809 TLI->getVectorIdxTy(MF->getDataLayout()).getFixedSizeInBits()) {
1810 report(
"Index type must match VectorIdxTy",
MI);
1816 case TargetOpcode::G_INSERT_VECTOR_ELT: {
1817 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1818 LLT VecTy =
MRI->getType(
MI->getOperand(1).getReg());
1819 LLT ScaTy =
MRI->getType(
MI->getOperand(2).getReg());
1820 LLT IdxTy =
MRI->getType(
MI->getOperand(3).getReg());
1823 report(
"Destination type must be a vector",
MI);
1827 if (VecTy != DstTy) {
1828 report(
"Destination type and vector type must match",
MI);
1833 report(
"Inserted element must be a scalar or pointer",
MI);
1837 auto TLI = MF->getSubtarget().getTargetLowering();
1839 TLI->getVectorIdxTy(MF->getDataLayout()).getFixedSizeInBits()) {
1840 report(
"Index type must match VectorIdxTy",
MI);
1846 case TargetOpcode::G_DYN_STACKALLOC: {
1852 report(
"dst operand 0 must be a pointer type",
MI);
1856 if (!AllocOp.
isReg() || !
MRI->getType(AllocOp.
getReg()).isScalar()) {
1857 report(
"src operand 1 must be a scalar reg type",
MI);
1861 if (!AlignOp.
isImm()) {
1862 report(
"src operand 2 must be an immediate type",
MI);
1867 case TargetOpcode::G_MEMCPY_INLINE:
1868 case TargetOpcode::G_MEMCPY:
1869 case TargetOpcode::G_MEMMOVE: {
1871 if (MMOs.
size() != 2) {
1872 report(
"memcpy/memmove must have 2 memory operands",
MI);
1878 report(
"wrong memory operand types",
MI);
1883 report(
"inconsistent memory operand sizes",
MI);
1885 LLT DstPtrTy =
MRI->getType(
MI->getOperand(0).getReg());
1886 LLT SrcPtrTy =
MRI->getType(
MI->getOperand(1).getReg());
1889 report(
"memory instruction operand must be a pointer",
MI);
1894 report(
"inconsistent store address space",
MI);
1896 report(
"inconsistent load address space",
MI);
1898 if (Opc != TargetOpcode::G_MEMCPY_INLINE)
1899 if (!
MI->getOperand(3).isImm() || (
MI->getOperand(3).getImm() & ~1LL))
1900 report(
"'tail' flag (operand 3) must be an immediate 0 or 1",
MI);
1904 case TargetOpcode::G_BZERO:
1905 case TargetOpcode::G_MEMSET: {
1907 std::string
Name = Opc == TargetOpcode::G_MEMSET ?
"memset" :
"bzero";
1908 if (MMOs.
size() != 1) {
1909 report(
Twine(
Name,
" must have 1 memory operand"),
MI);
1914 report(
Twine(
Name,
" memory operand must be a store"),
MI);
1918 LLT DstPtrTy =
MRI->getType(
MI->getOperand(0).getReg());
1920 report(
Twine(
Name,
" operand must be a pointer"),
MI);
1925 report(
"inconsistent " +
Twine(
Name,
" address space"),
MI);
1927 if (!
MI->getOperand(
MI->getNumOperands() - 1).isImm() ||
1928 (
MI->getOperand(
MI->getNumOperands() - 1).getImm() & ~1LL))
1929 report(
"'tail' flag (last operand) must be an immediate 0 or 1",
MI);
1933 case TargetOpcode::G_UBSANTRAP: {
1935 if (!
MI->getOperand(0).isImm()) {
1936 report(
"Crash kind must be an immediate", &KindOp, 0);
1939 int64_t
Kind =
MI->getOperand(0).getImm();
1940 if (!isInt<8>(Kind))
1941 report(
"Crash kind must be 8 bit wide", &KindOp, 0);
1944 case TargetOpcode::G_VECREDUCE_SEQ_FADD:
1945 case TargetOpcode::G_VECREDUCE_SEQ_FMUL: {
1946 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1947 LLT Src1Ty =
MRI->getType(
MI->getOperand(1).getReg());
1948 LLT Src2Ty =
MRI->getType(
MI->getOperand(2).getReg());
1950 report(
"Vector reduction requires a scalar destination type",
MI);
1952 report(
"Sequential FADD/FMUL vector reduction requires a scalar 1st operand",
MI);
1954 report(
"Sequential FADD/FMUL vector reduction must have a vector 2nd operand",
MI);
1957 case TargetOpcode::G_VECREDUCE_FADD:
1958 case TargetOpcode::G_VECREDUCE_FMUL:
1959 case TargetOpcode::G_VECREDUCE_FMAX:
1960 case TargetOpcode::G_VECREDUCE_FMIN:
1961 case TargetOpcode::G_VECREDUCE_FMAXIMUM:
1962 case TargetOpcode::G_VECREDUCE_FMINIMUM:
1963 case TargetOpcode::G_VECREDUCE_ADD:
1964 case TargetOpcode::G_VECREDUCE_MUL:
1965 case TargetOpcode::G_VECREDUCE_AND:
1966 case TargetOpcode::G_VECREDUCE_OR:
1967 case TargetOpcode::G_VECREDUCE_XOR:
1968 case TargetOpcode::G_VECREDUCE_SMAX:
1969 case TargetOpcode::G_VECREDUCE_SMIN:
1970 case TargetOpcode::G_VECREDUCE_UMAX:
1971 case TargetOpcode::G_VECREDUCE_UMIN: {
1972 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1974 report(
"Vector reduction requires a scalar destination type",
MI);
1978 case TargetOpcode::G_SBFX:
1979 case TargetOpcode::G_UBFX: {
1980 LLT DstTy =
MRI->getType(
MI->getOperand(0).getReg());
1982 report(
"Bitfield extraction is not supported on vectors",
MI);
1987 case TargetOpcode::G_SHL:
1988 case TargetOpcode::G_LSHR:
1989 case TargetOpcode::G_ASHR:
1990 case TargetOpcode::G_ROTR:
1991 case TargetOpcode::G_ROTL: {
1992 LLT Src1Ty =
MRI->getType(
MI->getOperand(1).getReg());
1993 LLT Src2Ty =
MRI->getType(
MI->getOperand(2).getReg());
1995 report(
"Shifts and rotates require operands to be either all scalars or "
2002 case TargetOpcode::G_LLROUND:
2003 case TargetOpcode::G_LROUND: {
2004 verifyAllRegOpsScalar(*
MI, *
MRI);
2007 case TargetOpcode::G_IS_FPCLASS: {
2008 LLT DestTy =
MRI->getType(
MI->getOperand(0).getReg());
2011 report(
"Destination must be a scalar or vector of scalars",
MI);
2014 LLT SrcTy =
MRI->getType(
MI->getOperand(1).getReg());
2017 report(
"Source must be a scalar or vector of scalars",
MI);
2020 if (!verifyVectorElementMatch(DestTy, SrcTy,
MI))
2023 if (!TestMO.
isImm()) {
2024 report(
"floating-point class set (operand 2) must be an immediate",
MI);
2029 report(
"Incorrect floating-point class set (operand 2)",
MI);
2034 case TargetOpcode::G_PREFETCH: {
2036 if (!AddrOp.
isReg() || !
MRI->getType(AddrOp.
getReg()).isPointer()) {
2037 report(
"addr operand must be a pointer", &AddrOp, 0);
2042 report(
"rw operand must be an immediate 0-1", &RWOp, 1);
2047 report(
"locality operand must be an immediate 0-3", &LocalityOp, 2);
2052 report(
"cache type operand must be an immediate 0-1", &CacheTypeOp, 3);
2057 case TargetOpcode::G_ASSERT_ALIGN: {
2058 if (
MI->getOperand(2).getImm() < 1)
2059 report(
"alignment immediate must be >= 1",
MI);
2062 case TargetOpcode::G_CONSTANT_POOL: {
2063 if (!
MI->getOperand(1).isCPI())
2064 report(
"Src operand 1 must be a constant pool index",
MI);
2065 if (!
MRI->getType(
MI->getOperand(0).getReg()).isPointer())
2066 report(
"Dst operand 0 must be a pointer",
MI);
2069 case TargetOpcode::G_PTRAUTH_GLOBAL_VALUE: {
2071 if (!AddrOp.
isReg() || !
MRI->getType(AddrOp.
getReg()).isPointer())
2072 report(
"addr operand must be a pointer", &AddrOp, 1);
2080void MachineVerifier::visitMachineInstrBefore(
const MachineInstr *
MI) {
2083 report(
"Too few operands",
MI);
2085 <<
MI->getNumOperands() <<
" given.\n";
2089 report(
"NoConvergent flag expected only on convergent instructions.",
MI);
2092 if (MF->getProperties().hasProperty(
2094 report(
"Found PHI instruction with NoPHIs property set",
MI);
2097 report(
"Found PHI instruction after non-PHI",
MI);
2098 }
else if (FirstNonPHI ==
nullptr)
2102 if (
MI->isInlineAsm())
2103 verifyInlineAsm(
MI);
2106 if (
TII->isUnspillableTerminator(
MI)) {
2107 if (!
MI->getOperand(0).isReg() || !
MI->getOperand(0).isDef())
2108 report(
"Unspillable Terminator does not define a reg",
MI);
2110 if (
Def.isVirtual() &&
2111 !MF->getProperties().hasProperty(
2113 std::distance(
MRI->use_nodbg_begin(Def),
MRI->use_nodbg_end()) > 1)
2114 report(
"Unspillable Terminator expected to have at most one use!",
MI);
2120 if (
MI->isDebugValue() &&
MI->getNumOperands() == 4)
2121 if (!
MI->getDebugLoc())
2122 report(
"Missing DebugLoc for debug instruction",
MI);
2126 if (
MI->isMetaInstruction() &&
MI->peekDebugInstrNum())
2127 report(
"Metadata instruction should not have a value tracking number",
MI);
2131 if (
Op->isLoad() && !
MI->mayLoad())
2132 report(
"Missing mayLoad flag",
MI);
2133 if (
Op->isStore() && !
MI->mayStore())
2134 report(
"Missing mayStore flag",
MI);
2141 if (
MI->isDebugOrPseudoInstr()) {
2143 report(
"Debug instruction has a slot index",
MI);
2144 }
else if (
MI->isInsideBundle()) {
2146 report(
"Instruction inside bundle has a slot index",
MI);
2149 report(
"Missing slot index",
MI);
2155 verifyPreISelGenericInstruction(
MI);
2164 switch (
MI->getOpcode()) {
2165 case TargetOpcode::COPY: {
2171 LLT DstTy =
MRI->getType(DstReg);
2172 LLT SrcTy =
MRI->getType(SrcReg);
2175 if (SrcTy != DstTy) {
2176 report(
"Copy Instruction is illegal with mismatching types",
MI);
2177 errs() <<
"Def = " << DstTy <<
", Src = " << SrcTy <<
"\n";
2192 TRI->getMinimalPhysRegClassLLT(SrcReg, DstTy);
2194 SrcSize =
TRI->getRegSizeInBits(*SrcRC);
2199 TRI->getMinimalPhysRegClassLLT(DstReg, SrcTy);
2201 DstSize =
TRI->getRegSizeInBits(*DstRC);
2219 if (!
DstOp.getSubReg() && !
SrcOp.getSubReg()) {
2220 report(
"Copy Instruction is illegal with mismatching sizes",
MI);
2221 errs() <<
"Def Size = " << DstSize <<
", Src Size = " << SrcSize
2227 case TargetOpcode::STATEPOINT: {
2229 if (!
MI->getOperand(SO.getIDPos()).isImm() ||
2230 !
MI->getOperand(SO.getNBytesPos()).isImm() ||
2231 !
MI->getOperand(SO.getNCallArgsPos()).isImm()) {
2232 report(
"meta operands to STATEPOINT not constant!",
MI);
2236 auto VerifyStackMapConstant = [&](
unsigned Offset) {
2237 if (
Offset >=
MI->getNumOperands()) {
2238 report(
"stack map constant to STATEPOINT is out of range!",
MI);
2241 if (!
MI->getOperand(
Offset - 1).isImm() ||
2242 MI->getOperand(
Offset - 1).getImm() != StackMaps::ConstantOp ||
2244 report(
"stack map constant to STATEPOINT not well formed!",
MI);
2246 VerifyStackMapConstant(SO.getCCIdx());
2247 VerifyStackMapConstant(SO.getFlagsIdx());
2248 VerifyStackMapConstant(SO.getNumDeoptArgsIdx());
2249 VerifyStackMapConstant(SO.getNumGCPtrIdx());
2250 VerifyStackMapConstant(SO.getNumAllocaIdx());
2251 VerifyStackMapConstant(SO.getNumGcMapEntriesIdx());
2255 unsigned FirstGCPtrIdx = SO.getFirstGCPtrIdx();
2256 unsigned LastGCPtrIdx = SO.getNumAllocaIdx() - 2;
2257 for (
unsigned Idx = 0;
Idx <
MI->getNumDefs();
Idx++) {
2259 if (!
MI->isRegTiedToUseOperand(
Idx, &UseOpIdx)) {
2260 report(
"STATEPOINT defs expected to be tied",
MI);
2263 if (UseOpIdx < FirstGCPtrIdx || UseOpIdx > LastGCPtrIdx) {
2264 report(
"STATEPOINT def tied to non-gc operand",
MI);
2271 case TargetOpcode::INSERT_SUBREG: {
2272 unsigned InsertedSize;
2273 if (
unsigned SubIdx =
MI->getOperand(2).getSubReg())
2274 InsertedSize =
TRI->getSubRegIdxSize(SubIdx);
2276 InsertedSize =
TRI->getRegSizeInBits(
MI->getOperand(2).getReg(), *
MRI);
2277 unsigned SubRegSize =
TRI->getSubRegIdxSize(
MI->getOperand(3).getImm());
2278 if (SubRegSize < InsertedSize) {
2279 report(
"INSERT_SUBREG expected inserted value to have equal or lesser "
2280 "size than the subreg it was inserted into",
MI);
2284 case TargetOpcode::REG_SEQUENCE: {
2285 unsigned NumOps =
MI->getNumOperands();
2286 if (!(NumOps & 1)) {
2287 report(
"Invalid number of operands for REG_SEQUENCE",
MI);
2291 for (
unsigned I = 1;
I != NumOps;
I += 2) {
2296 report(
"Invalid register operand for REG_SEQUENCE", &RegOp,
I);
2298 if (!SubRegOp.
isImm() || SubRegOp.
getImm() == 0 ||
2299 SubRegOp.
getImm() >=
TRI->getNumSubRegIndices()) {
2300 report(
"Invalid subregister index operand for REG_SEQUENCE",
2305 Register DstReg =
MI->getOperand(0).getReg();
2307 report(
"REG_SEQUENCE does not support physical register results",
MI);
2309 if (
MI->getOperand(0).getSubReg())
2310 report(
"Invalid subreg result for REG_SEQUENCE",
MI);
2318MachineVerifier::visitMachineOperand(
const MachineOperand *MO,
unsigned MONum) {
2322 if (MCID.
getOpcode() == TargetOpcode::PATCHPOINT)
2323 NumDefs = (MONum == 0 && MO->
isReg()) ? NumDefs : 0;
2326 if (MONum < NumDefs) {
2329 report(
"Explicit definition must be a register", MO, MONum);
2331 report(
"Explicit definition marked as use", MO, MONum);
2333 report(
"Explicit definition marked as implicit", MO, MONum);
2342 report(
"Explicit operand marked as def", MO, MONum);
2344 report(
"Explicit operand marked as implicit", MO, MONum);
2350 report(
"Expected a register operand.", MO, MONum);
2354 !
TII->isPCRelRegisterOperandLegal(*MO)))
2355 report(
"Expected a non-register operand.", MO, MONum);
2362 report(
"Tied use must be a register", MO, MONum);
2364 report(
"Operand should be tied", MO, MONum);
2365 else if (
unsigned(TiedTo) !=
MI->findTiedOperandIdx(MONum))
2366 report(
"Tied def doesn't match MCInstrDesc", MO, MONum);
2369 if (!MOTied.
isReg())
2370 report(
"Tied counterpart must be a register", &MOTied, TiedTo);
2373 report(
"Tied physical registers must match.", &MOTied, TiedTo);
2376 report(
"Explicit operand should not be tied", MO, MONum);
2377 }
else if (!
MI->isVariadic()) {
2380 report(
"Extra explicit operand on non-variadic instruction", MO, MONum);
2387 if (
MI->isDebugInstr() && MO->
isUse()) {
2389 report(
"Register operand must be marked debug", MO, MONum);
2391 report(
"Register operand must not be marked debug", MO, MONum);
2397 if (
MRI->tracksLiveness() && !
MI->isDebugInstr())
2398 checkLiveness(MO, MONum);
2402 report(
"Undef virtual register def operands require a subregister", MO, MONum);
2406 unsigned OtherIdx =
MI->findTiedOperandIdx(MONum);
2408 if (!OtherMO.
isReg())
2409 report(
"Must be tied to a register", MO, MONum);
2411 report(
"Missing tie flags on tied operand", MO, MONum);
2412 if (
MI->findTiedOperandIdx(OtherIdx) != MONum)
2413 report(
"Inconsistent tie links", MO, MONum);
2417 report(
"Explicit def tied to explicit use without tie constraint",
2421 report(
"Explicit def should be tied to implicit use", MO, MONum);
2434 if (MF->getProperties().hasProperty(
2436 MO->
isUse() &&
MI->isRegTiedToDefOperand(MONum, &DefIdx) &&
2437 Reg !=
MI->getOperand(DefIdx).getReg())
2438 report(
"Two-address instruction operands must be identical", MO, MONum);
2443 if (
Reg.isPhysical()) {
2445 report(
"Illegal subregister index for physical register", MO, MONum);
2450 TII->getRegClass(MCID, MONum,
TRI, *MF)) {
2451 if (!DRC->contains(Reg)) {
2452 report(
"Illegal physical register for instruction", MO, MONum);
2454 <<
TRI->getRegClassName(DRC) <<
" register.\n";
2459 if (
MRI->isReserved(Reg)) {
2460 report(
"isRenamable set on reserved register", MO, MONum);
2477 report(
"Generic virtual register use cannot be undef", MO, MONum);
2484 if (isFunctionTracksDebugUserValues || !MO->
isUse() ||
2485 !
MI->isDebugValue() || !
MRI->def_empty(Reg)) {
2487 if (isFunctionSelected) {
2488 report(
"Generic virtual register invalid in a Selected function",
2494 LLT Ty =
MRI->getType(Reg);
2496 report(
"Generic virtual register must have a valid type", MO,
2505 if (!RegBank && isFunctionRegBankSelected) {
2506 report(
"Generic virtual register must have a bank in a "
2507 "RegBankSelected function",
2515 report(
"Register bank is too small for virtual register", MO,
2517 errs() <<
"Register bank " << RegBank->
getName() <<
" too small("
2525 report(
"Generic virtual register does not allow subregister index", MO,
2535 TII->getRegClass(MCID, MONum,
TRI, *MF)) {
2536 report(
"Virtual register does not match instruction constraint", MO,
2538 errs() <<
"Expect register class "
2539 <<
TRI->getRegClassName(
2540 TII->getRegClass(MCID, MONum,
TRI, *MF))
2541 <<
" but got nothing\n";
2549 TRI->getSubClassWithSubReg(RC, SubIdx);
2551 report(
"Invalid subregister index for virtual register", MO, MONum);
2552 errs() <<
"Register class " <<
TRI->getRegClassName(RC)
2553 <<
" does not support subreg index " << SubIdx <<
"\n";
2557 report(
"Invalid register class for subregister index", MO, MONum);
2558 errs() <<
"Register class " <<
TRI->getRegClassName(RC)
2559 <<
" does not fully support subreg index " << SubIdx <<
"\n";
2565 TII->getRegClass(MCID, MONum,
TRI, *MF)) {
2568 TRI->getLargestLegalSuperClass(RC, *MF);
2570 report(
"No largest legal super class exists.", MO, MONum);
2573 DRC =
TRI->getMatchingSuperRegClass(SuperRC, DRC, SubIdx);
2575 report(
"No matching super-reg register class.", MO, MONum);
2580 report(
"Illegal virtual register for instruction", MO, MONum);
2581 errs() <<
"Expected a " <<
TRI->getRegClassName(DRC)
2582 <<
" register, but got a " <<
TRI->getRegClassName(RC)
2597 report(
"PHI operand is not in the CFG", MO, MONum);
2608 bool loads =
MI->mayLoad();
2613 for (
auto *MMO :
MI->memoperands()) {
2615 if (PSV ==
nullptr)
continue;
2617 dyn_cast<FixedStackPseudoSourceValue>(PSV);
2618 if (
Value ==
nullptr)
continue;
2619 if (
Value->getFrameIndex() != FI)
continue;
2628 report(
"Missing fixed stack memoperand.",
MI);
2630 if (loads && !LI.
liveAt(
Idx.getRegSlot(
true))) {
2631 report(
"Instruction loads from dead spill slot", MO, MONum);
2632 errs() <<
"Live stack: " << LI <<
'\n';
2635 report(
"Instruction stores to dead spill slot", MO, MONum);
2636 errs() <<
"Live stack: " << LI <<
'\n';
2642 if (MO->
getCFIIndex() >= MF->getFrameInstructions().size())
2643 report(
"CFI instruction has invalid index", MO, MONum);
2651void MachineVerifier::checkLivenessAtUse(
const MachineOperand *MO,
2662 report(
"No live segment at use", MO, MONum);
2663 report_context_liverange(LR);
2664 report_context_vreg_regunit(VRegOrUnit);
2665 report_context(UseIdx);
2668 report(
"Live range continues after kill flag", MO, MONum);
2669 report_context_liverange(LR);
2670 report_context_vreg_regunit(VRegOrUnit);
2672 report_context_lanemask(LaneMask);
2673 report_context(UseIdx);
2677void MachineVerifier::checkLivenessAtDef(
const MachineOperand *MO,
2692 if (((SubRangeCheck || MO->
getSubReg() == 0) && VNI->def != DefIdx) ||
2694 (VNI->def != DefIdx &&
2695 (!VNI->def.isEarlyClobber() || !DefIdx.
isRegister()))) {
2696 report(
"Inconsistent valno->def", MO, MONum);
2697 report_context_liverange(LR);
2698 report_context_vreg_regunit(VRegOrUnit);
2700 report_context_lanemask(LaneMask);
2701 report_context(*VNI);
2702 report_context(DefIdx);
2705 report(
"No live segment at def", MO, MONum);
2706 report_context_liverange(LR);
2707 report_context_vreg_regunit(VRegOrUnit);
2709 report_context_lanemask(LaneMask);
2710 report_context(DefIdx);
2722 if (SubRangeCheck || MO->
getSubReg() == 0) {
2723 report(
"Live range continues after dead def flag", MO, MONum);
2724 report_context_liverange(LR);
2725 report_context_vreg_regunit(VRegOrUnit);
2727 report_context_lanemask(LaneMask);
2733void MachineVerifier::checkLiveness(
const MachineOperand *MO,
unsigned MONum) {
2736 const unsigned SubRegIdx = MO->
getSubReg();
2739 if (LiveInts &&
Reg.isVirtual()) {
2744 report(
"Live interval for subreg operand has no subranges", MO, MONum);
2746 report(
"Virtual register has no live interval", MO, MONum);
2753 addRegWithSubRegs(regsKilled, Reg);
2758 if (LiveVars &&
Reg.isVirtual() && MO->
isKill() &&
2759 !
MI->isBundledWithPred()) {
2762 report(
"Kill missing from LiveVariables", MO, MONum);
2776 if (
Reg.isPhysical() && !isReserved(Reg)) {
2778 if (
MRI->isReservedRegUnit(Unit))
2781 checkLivenessAtUse(MO, MONum, UseIdx, *LR, Unit);
2785 if (
Reg.isVirtual()) {
2787 checkLivenessAtUse(MO, MONum, UseIdx, *LI, Reg);
2791 ?
TRI->getSubRegIndexLaneMask(SubRegIdx)
2792 :
MRI->getMaxLaneMaskForVReg(Reg);
2795 if ((MOMask & SR.LaneMask).none())
2797 checkLivenessAtUse(MO, MONum, UseIdx, SR, Reg, SR.LaneMask);
2800 LiveInMask |= SR.LaneMask;
2803 if ((LiveInMask & MOMask).
none()) {
2804 report(
"No live subrange at use", MO, MONum);
2805 report_context(*LI);
2806 report_context(UseIdx);
2809 if (
MI->isPHI() && LiveInMask != MOMask) {
2810 report(
"Not all lanes of PHI source live at use", MO, MONum);
2811 report_context(*LI);
2812 report_context(UseIdx);
2819 if (!regsLive.count(Reg)) {
2820 if (
Reg.isPhysical()) {
2822 bool Bad = !isReserved(Reg);
2827 if (regsLive.count(
SubReg)) {
2839 if (!MOP.isReg() || !MOP.isImplicit())
2842 if (!MOP.getReg().isPhysical())
2850 report(
"Using an undefined physical register", MO, MONum);
2851 }
else if (
MRI->def_empty(Reg)) {
2852 report(
"Reading virtual register without a def", MO, MONum);
2854 BBInfo &MInfo = MBBInfoMap[
MI->getParent()];
2858 if (MInfo.regsKilled.count(Reg))
2859 report(
"Using a killed virtual register", MO, MONum);
2860 else if (!
MI->isPHI())
2861 MInfo.vregsLiveIn.insert(std::make_pair(Reg,
MI));
2870 addRegWithSubRegs(regsDead, Reg);
2872 addRegWithSubRegs(regsDefined, Reg);
2875 if (
MRI->isSSA() &&
Reg.isVirtual() &&
2876 std::next(
MRI->def_begin(Reg)) !=
MRI->def_end())
2877 report(
"Multiple virtual register defs in SSA form", MO, MONum);
2884 if (
Reg.isVirtual()) {
2885 checkLivenessAtDef(MO, MONum, DefIdx, *LI, Reg);
2889 ?
TRI->getSubRegIndexLaneMask(SubRegIdx)
2890 :
MRI->getMaxLaneMaskForVReg(Reg);
2892 if ((SR.LaneMask & MOMask).none())
2894 checkLivenessAtDef(MO, MONum, DefIdx, SR, Reg,
true, SR.LaneMask);
2906void MachineVerifier::visitMachineBundleAfter(
const MachineInstr *
MI) {
2907 BBInfo &MInfo = MBBInfoMap[
MI->getParent()];
2908 set_union(MInfo.regsKilled, regsKilled);
2909 set_subtract(regsLive, regsKilled); regsKilled.clear();
2911 while (!regMasks.empty()) {
2914 if (
Reg.isPhysical() &&
2916 regsDead.push_back(Reg);
2919 set_union(regsLive, regsDefined); regsDefined.clear();
2924 MBBInfoMap[
MBB].regsLiveOut = regsLive;
2929 if (!(stop > lastIndex)) {
2930 report(
"Block ends before last instruction index",
MBB);
2931 errs() <<
"Block ends at " << stop
2932 <<
" last instruction was at " << lastIndex <<
'\n';
2947 template <
typename RegSetT>
void add(
const RegSetT &FromRegSet) {
2949 filterAndAdd(FromRegSet, VRegsBuffer);
2954 template <
typename RegSetT>
2955 bool filterAndAdd(
const RegSetT &FromRegSet,
2957 unsigned SparseUniverse = Sparse.size();
2958 unsigned NewSparseUniverse = SparseUniverse;
2959 unsigned NewDenseSize =
Dense.size();
2960 size_t Begin = ToVRegs.
size();
2962 if (!
Reg.isVirtual())
2965 if (
Index < SparseUniverseMax) {
2966 if (
Index < SparseUniverse && Sparse.test(
Index))
2968 NewSparseUniverse = std::max(NewSparseUniverse,
Index + 1);
2983 Sparse.resize(NewSparseUniverse);
2984 Dense.reserve(NewDenseSize);
2985 for (
unsigned I = Begin;
I <
End; ++
I) {
2988 if (
Index < SparseUniverseMax)
2997 static constexpr unsigned SparseUniverseMax = 10 * 1024 * 8;
3017class FilteringVRegSet {
3024 template <
typename RegSetT>
void addToFilter(
const RegSetT &RS) {
3029 template <
typename RegSetT>
bool add(
const RegSetT &RS) {
3032 return Filter.filterAndAdd(RS, VRegs);
3037 size_t size()
const {
return VRegs.
size(); }
3044void MachineVerifier::calcRegsPassed() {
3051 FilteringVRegSet VRegs;
3052 BBInfo &
Info = MBBInfoMap[MB];
3055 VRegs.addToFilter(
Info.regsKilled);
3056 VRegs.addToFilter(
Info.regsLiveOut);
3058 const BBInfo &PredInfo = MBBInfoMap[Pred];
3059 if (!PredInfo.reachable)
3062 VRegs.add(PredInfo.regsLiveOut);
3063 VRegs.add(PredInfo.vregsPassed);
3065 Info.vregsPassed.reserve(VRegs.size());
3066 Info.vregsPassed.insert(VRegs.begin(), VRegs.end());
3073void MachineVerifier::calcRegsRequired() {
3076 for (
const auto &
MBB : *MF) {
3077 BBInfo &MInfo = MBBInfoMap[&
MBB];
3079 BBInfo &PInfo = MBBInfoMap[Pred];
3080 if (PInfo.addRequired(MInfo.vregsLiveIn))
3086 for (
unsigned i = 1, e =
MI.getNumOperands(); i != e; i += 2) {
3088 if (!
MI.getOperand(i).isReg() || !
MI.getOperand(i).readsReg())
3095 BBInfo &PInfo = MBBInfoMap[Pred];
3096 if (PInfo.addRequired(Reg))
3104 while (!todo.
empty()) {
3107 BBInfo &MInfo = MBBInfoMap[
MBB];
3111 BBInfo &SInfo = MBBInfoMap[Pred];
3112 if (SInfo.addRequired(MInfo.vregsRequired))
3121 BBInfo &MInfo = MBBInfoMap[&
MBB];
3131 report(
"Expected first PHI operand to be a register def", &MODef, 0);
3136 report(
"Unexpected flag on PHI operand", &MODef, 0);
3139 report(
"Expected first PHI operand to be a virtual register", &MODef, 0);
3141 for (
unsigned I = 1, E =
Phi.getNumOperands();
I != E;
I += 2) {
3144 report(
"Expected PHI operand to be a register", &MO0,
I);
3149 report(
"Unexpected flag on PHI operand", &MO0,
I);
3153 report(
"Expected PHI operand to be a basic block", &MO1,
I + 1);
3159 report(
"PHI input is not a predecessor block", &MO1,
I + 1);
3163 if (MInfo.reachable) {
3165 BBInfo &PrInfo = MBBInfoMap[&Pre];
3166 if (!MO0.
isUndef() && PrInfo.reachable &&
3167 !PrInfo.isLiveOut(MO0.
getReg()))
3168 report(
"PHI operand is not live-out from predecessor", &MO0,
I);
3173 if (MInfo.reachable) {
3175 if (!seen.
count(Pred)) {
3176 report(
"Missing PHI operand", &Phi);
3178 <<
" is a predecessor according to the CFG.\n";
3187 std::function<
void(
const Twine &Message)> FailureCB) {
3191 for (
const auto &
MBB : MF) {
3203void MachineVerifier::visitMachineFunctionAfter() {
3204 auto FailureCB = [
this](
const Twine &Message) {
3205 report(Message.str().c_str(), MF);
3218 for (
const auto &
MBB : *MF) {
3219 BBInfo &MInfo = MBBInfoMap[&
MBB];
3220 for (
Register VReg : MInfo.vregsRequired)
3221 if (MInfo.regsKilled.count(VReg)) {
3222 report(
"Virtual register killed in block, but needed live out.", &
MBB);
3224 <<
" is used after the block.\n";
3229 BBInfo &MInfo = MBBInfoMap[&MF->front()];
3230 for (
Register VReg : MInfo.vregsRequired) {
3231 report(
"Virtual register defs don't dominate all uses.", MF);
3232 report_context_vreg(VReg);
3237 verifyLiveVariables();
3239 verifyLiveIntervals();
3248 if (
MRI->tracksLiveness())
3249 for (
const auto &
MBB : *MF)
3253 if (hasAliases || isAllocatable(LiveInReg) || isReserved(LiveInReg))
3256 BBInfo &PInfo = MBBInfoMap[Pred];
3257 if (!PInfo.regsLiveOut.count(LiveInReg)) {
3258 report(
"Live in register not found to be live out from predecessor.",
3260 errs() <<
TRI->getName(LiveInReg)
3261 <<
" not found to be live out from "
3267 for (
auto CSInfo : MF->getCallSitesInfo())
3268 if (!CSInfo.first->isCall())
3269 report(
"Call site info referencing instruction that is not call", MF);
3273 if (MF->getFunction().getSubprogram()) {
3275 for (
const auto &
MBB : *MF) {
3276 for (
const auto &
MI :
MBB) {
3277 if (
auto Num =
MI.peekDebugInstrNum()) {
3280 report(
"Instruction has a duplicated value tracking number", &
MI);
3287void MachineVerifier::verifyLiveVariables() {
3288 assert(LiveVars &&
"Don't call verifyLiveVariables without LiveVars");
3289 for (
unsigned I = 0, E =
MRI->getNumVirtRegs();
I != E; ++
I) {
3292 for (
const auto &
MBB : *MF) {
3293 BBInfo &MInfo = MBBInfoMap[&
MBB];
3296 if (MInfo.vregsRequired.count(Reg)) {
3298 report(
"LiveVariables: Block missing from AliveBlocks", &
MBB);
3300 <<
" must be live through the block.\n";
3304 report(
"LiveVariables: Block should not be in AliveBlocks", &
MBB);
3306 <<
" is not needed live through the block.\n";
3313void MachineVerifier::verifyLiveIntervals() {
3314 assert(LiveInts &&
"Don't call verifyLiveIntervals without LiveInts");
3315 for (
unsigned I = 0, E =
MRI->getNumVirtRegs();
I != E; ++
I) {
3319 if (
MRI->reg_nodbg_empty(Reg))
3323 report(
"Missing live interval for virtual register", MF);
3329 assert(Reg == LI.
reg() &&
"Invalid reg to interval mapping");
3330 verifyLiveInterval(LI);
3334 for (
unsigned i = 0, e =
TRI->getNumRegUnits(); i != e; ++i)
3336 verifyLiveRange(*LR, i);
3339void MachineVerifier::verifyLiveRangeValue(
const LiveRange &LR,
3348 report(
"Value not live at VNInfo def and not marked unused", MF);
3349 report_context(LR, Reg, LaneMask);
3350 report_context(*VNI);
3354 if (DefVNI != VNI) {
3355 report(
"Live segment at def has different VNInfo", MF);
3356 report_context(LR, Reg, LaneMask);
3357 report_context(*VNI);
3363 report(
"Invalid VNInfo definition index", MF);
3364 report_context(LR, Reg, LaneMask);
3365 report_context(*VNI);
3371 report(
"PHIDef VNInfo is not defined at MBB start",
MBB);
3372 report_context(LR, Reg, LaneMask);
3373 report_context(*VNI);
3381 report(
"No instruction at VNInfo def index",
MBB);
3382 report_context(LR, Reg, LaneMask);
3383 report_context(*VNI);
3388 bool hasDef =
false;
3389 bool isEarlyClobber =
false;
3391 if (!MOI->isReg() || !MOI->isDef())
3393 if (
Reg.isVirtual()) {
3394 if (MOI->getReg() != Reg)
3397 if (!MOI->getReg().isPhysical() || !
TRI->hasRegUnit(MOI->getReg(), Reg))
3400 if (LaneMask.
any() &&
3401 (
TRI->getSubRegIndexLaneMask(MOI->getSubReg()) & LaneMask).none())
3404 if (MOI->isEarlyClobber())
3405 isEarlyClobber =
true;
3409 report(
"Defining instruction does not modify register",
MI);
3410 report_context(LR, Reg, LaneMask);
3411 report_context(*VNI);
3416 if (isEarlyClobber) {
3418 report(
"Early clobber def must be at an early-clobber slot",
MBB);
3419 report_context(LR, Reg, LaneMask);
3420 report_context(*VNI);
3423 report(
"Non-PHI, non-early clobber def must be at a register slot",
MBB);
3424 report_context(LR, Reg, LaneMask);
3425 report_context(*VNI);
3430void MachineVerifier::verifyLiveRangeSegment(
const LiveRange &LR,
3436 assert(VNI &&
"Live segment has no valno");
3439 report(
"Foreign valno in live segment", MF);
3440 report_context(LR, Reg, LaneMask);
3442 report_context(*VNI);
3446 report(
"Live segment valno is marked unused", MF);
3447 report_context(LR, Reg, LaneMask);
3453 report(
"Bad start of live segment, no basic block", MF);
3454 report_context(LR, Reg, LaneMask);
3460 report(
"Live segment must begin at MBB entry or valno def",
MBB);
3461 report_context(LR, Reg, LaneMask);
3468 report(
"Bad end of live segment, no basic block", MF);
3469 report_context(LR, Reg, LaneMask);
3485 report(
"Live segment doesn't end at a valid instruction", EndMBB);
3486 report_context(LR, Reg, LaneMask);
3493 report(
"Live segment ends at B slot of an instruction", EndMBB);
3494 report_context(LR, Reg, LaneMask);
3502 report(
"Live segment ending at dead slot spans instructions", EndMBB);
3503 report_context(LR, Reg, LaneMask);
3512 if (MF->getProperties().hasProperty(
3515 if (
I + 1 == LR.
end() || (
I + 1)->start != S.
end) {
3516 report(
"Live segment ending at early clobber slot must be "
3517 "redefined by an EC def in the same instruction",
3519 report_context(LR, Reg, LaneMask);
3526 if (
Reg.isVirtual()) {
3529 bool hasRead =
false;
3530 bool hasSubRegDef =
false;
3531 bool hasDeadDef =
false;
3533 if (!MOI->isReg() || MOI->getReg() != Reg)
3535 unsigned Sub = MOI->getSubReg();
3540 hasSubRegDef =
true;
3549 if (LaneMask.
any() && (LaneMask & SLM).none())
3551 if (MOI->readsReg())
3558 if (LaneMask.
none() && !hasDeadDef) {
3560 "Instruction ending live segment on dead slot has no dead flag",
3562 report_context(LR, Reg, LaneMask);
3569 if (!
MRI->shouldTrackSubRegLiveness(Reg) || LaneMask.
any() ||
3571 report(
"Instruction ending live segment doesn't read the register",
3573 report_context(LR, Reg, LaneMask);
3593 if (LaneMask.
any()) {
3601 if (!
Reg.isVirtual() && MFI->isEHPad()) {
3602 if (&*MFI == EndMBB)
3616 if (MFI->isEHPad()) {
3630 if (!PVNI && (LaneMask.
none() || !IsPHI)) {
3633 report(
"Register not marked live out of predecessor", Pred);
3634 report_context(LR, Reg, LaneMask);
3635 report_context(*VNI);
3643 if (!IsPHI && PVNI != VNI) {
3644 report(
"Different value live out of predecessor", Pred);
3645 report_context(LR, Reg, LaneMask);
3646 errs() <<
"Valno #" << PVNI->
id <<
" live out of "
3652 if (&*MFI == EndMBB)
3661 verifyLiveRangeValue(LR, VNI, Reg, LaneMask);
3664 verifyLiveRangeSegment(LR,
I, Reg, LaneMask);
3667void MachineVerifier::verifyLiveInterval(
const LiveInterval &LI) {
3670 verifyLiveRange(LI, Reg);
3676 if ((Mask & SR.LaneMask).any()) {
3677 report(
"Lane masks of sub ranges overlap in live interval", MF);
3680 if ((SR.LaneMask & ~MaxMask).any()) {
3681 report(
"Subrange lanemask is invalid", MF);
3685 report(
"Subrange must not be empty", MF);
3686 report_context(SR, LI.
reg(), SR.LaneMask);
3688 Mask |= SR.LaneMask;
3689 verifyLiveRange(SR, LI.
reg(), SR.LaneMask);
3691 report(
"A Subrange is not covered by the main range", MF);
3699 unsigned NumComp = ConEQ.Classify(LI);
3701 report(
"Multiple connected components in live interval", MF);
3703 for (
unsigned comp = 0; comp != NumComp; ++comp) {
3704 errs() << comp <<
": valnos";
3706 if (comp == ConEQ.getEqClass(
I))
3707 errs() <<
' ' <<
I->id;
3719 struct StackStateOfBB {
3720 StackStateOfBB() =
default;
3721 StackStateOfBB(
int EntryVal,
int ExitVal,
bool EntrySetup,
bool ExitSetup) :
3722 EntryValue(EntryVal), ExitValue(ExitVal), EntryIsSetup(EntrySetup),
3723 ExitIsSetup(ExitSetup) {}
3728 bool EntryIsSetup =
false;
3729 bool ExitIsSetup =
false;
3737void MachineVerifier::verifyStackFrame() {
3738 unsigned FrameSetupOpcode =
TII->getCallFrameSetupOpcode();
3739 unsigned FrameDestroyOpcode =
TII->getCallFrameDestroyOpcode();
3740 if (FrameSetupOpcode == ~0u && FrameDestroyOpcode == ~0u)
3744 SPState.
resize(MF->getNumBlockIDs());
3751 DFI != DFE; ++DFI) {
3754 StackStateOfBB BBState;
3756 if (DFI.getPathLength() >= 2) {
3759 "DFS stack predecessor is already visited.\n");
3760 BBState.EntryValue = SPState[StackPred->
getNumber()].ExitValue;
3761 BBState.EntryIsSetup = SPState[StackPred->
getNumber()].ExitIsSetup;
3762 BBState.ExitValue = BBState.EntryValue;
3763 BBState.ExitIsSetup = BBState.EntryIsSetup;
3767 report(
"Call frame size on entry does not match value computed from "
3771 <<
" does not match value computed from predecessor "
3772 << -BBState.EntryValue <<
'\n';
3776 for (
const auto &
I : *
MBB) {
3777 if (
I.getOpcode() == FrameSetupOpcode) {
3778 if (BBState.ExitIsSetup)
3779 report(
"FrameSetup is after another FrameSetup", &
I);
3780 if (!
MRI->isSSA() && !MF->getFrameInfo().adjustsStack())
3781 report(
"AdjustsStack not set in presence of a frame pseudo "
3782 "instruction.", &
I);
3783 BBState.ExitValue -=
TII->getFrameTotalSize(
I);
3784 BBState.ExitIsSetup =
true;
3787 if (
I.getOpcode() == FrameDestroyOpcode) {
3788 int Size =
TII->getFrameTotalSize(
I);
3789 if (!BBState.ExitIsSetup)
3790 report(
"FrameDestroy is not after a FrameSetup", &
I);
3791 int AbsSPAdj = BBState.ExitValue < 0 ? -BBState.ExitValue :
3793 if (BBState.ExitIsSetup && AbsSPAdj !=
Size) {
3794 report(
"FrameDestroy <n> is after FrameSetup <m>", &
I);
3795 errs() <<
"FrameDestroy <" <<
Size <<
"> is after FrameSetup <"
3796 << AbsSPAdj <<
">.\n";
3798 if (!
MRI->isSSA() && !MF->getFrameInfo().adjustsStack())
3799 report(
"AdjustsStack not set in presence of a frame pseudo "
3800 "instruction.", &
I);
3801 BBState.ExitValue +=
Size;
3802 BBState.ExitIsSetup =
false;
3810 if (Reachable.
count(Pred) &&
3811 (SPState[Pred->
getNumber()].ExitValue != BBState.EntryValue ||
3812 SPState[Pred->
getNumber()].ExitIsSetup != BBState.EntryIsSetup)) {
3813 report(
"The exit stack state of a predecessor is inconsistent.",
MBB);
3815 <<
" has exit state (" << SPState[Pred->
getNumber()].ExitValue
3816 <<
", " << SPState[Pred->
getNumber()].ExitIsSetup <<
"), while "
3818 << BBState.EntryValue <<
", " << BBState.EntryIsSetup <<
").\n";
3825 if (Reachable.
count(Succ) &&
3826 (SPState[Succ->getNumber()].EntryValue != BBState.ExitValue ||
3827 SPState[Succ->getNumber()].EntryIsSetup != BBState.ExitIsSetup)) {
3828 report(
"The entry stack state of a successor is inconsistent.",
MBB);
3830 <<
" has entry state (" << SPState[Succ->getNumber()].EntryValue
3831 <<
", " << SPState[Succ->getNumber()].EntryIsSetup <<
"), while "
3833 << BBState.ExitValue <<
", " << BBState.ExitIsSetup <<
").\n";
3839 if (BBState.ExitIsSetup)
3840 report(
"A return block ends with a FrameSetup.",
MBB);
3841 if (BBState.ExitValue)
3842 report(
"A return block ends with a nonzero stack adjustment.",
MBB);
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static bool isLoad(int Opcode)
static bool isStore(int Opcode)
This file implements the BitVector class.
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
const HexagonInstrInfo * TII
A common definition of LaneBitmask for use in TableGen and CodeGen.
Implement a low-level type suitable for MachineInstr level instruction selection.
This file declares the MIR specialization of the GenericConvergenceVerifier template.
unsigned const TargetRegisterInfo * TRI
static void verifyConvergenceControl(const MachineFunction &MF, MachineDominatorTree &DT, std::function< void(const Twine &Message)> FailureCB)
modulo schedule Modulo Schedule test pass
const char LLVMTargetMachineRef TM
#define INITIALIZE_PASS(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
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isLiveOut(const MachineBasicBlock &MBB, unsigned Reg)
This file defines generic set operations that may be used on set's of different types,...
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
This file describes how to lower LLVM code to machine code.
static unsigned getSize(unsigned Kind)
const fltSemantics & getSemantics() const
Represent the analysis usage information of a pass.
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
LLVM Basic Block Representation.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool test(unsigned Idx) const
void clear()
clear - Removes all bits from the bitvector.
iterator_range< const_set_bits_iterator > set_bits() const
size_type size() const
size - Returns the number of bits in this bitvector.
ConnectedVNInfoEqClasses - Helper class that can divide VNInfos in a LiveInterval into equivalence cl...
ConstMIBundleOperands - Iterate over all operands in a const bundle of machine instructions.
ConstantFP - Floating Point Values [float, double].
const APFloat & getValueAPF() const
This is the shared class of boolean and integer constants.
unsigned getBitWidth() const
getBitWidth - Return the scalar bitwidth of this constant.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Implements a dense probed hash-table based set.
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
Base class for user error types.
A specialized PseudoSourceValue for holding FixedStack values, which must include a frame index.
FunctionPass class - This class is used to implement most global optimizations.
void initialize(raw_ostream *OS, function_ref< void(const Twine &Message)> FailureCB, const FunctionT &F)
void verify(const DominatorTreeT &DT)
void visit(const BlockT &BB)
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....
constexpr bool isScalableVector() const
Returns true if the LLT is a scalable vector.
constexpr unsigned getScalarSizeInBits() const
constexpr bool isScalar() const
constexpr bool isValid() const
constexpr uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
constexpr bool isVector() const
constexpr TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
constexpr bool isPointer() const
constexpr LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
constexpr ElementCount getElementCount() const
constexpr unsigned getAddressSpace() const
constexpr bool isPointerOrPointerVector() const
constexpr LLT getScalarType() const
constexpr TypeSize getSizeInBytes() const
Returns the total size of the type in bytes, i.e.
A live range for subregisters.
LiveInterval - This class represents the liveness of a register, or stack slot.
bool hasSubRanges() const
Returns true if subregister liveness information is available.
iterator_range< subrange_iterator > subranges()
void computeSubRangeUndefs(SmallVectorImpl< SlotIndex > &Undefs, LaneBitmask LaneMask, const MachineRegisterInfo &MRI, const SlotIndexes &Indexes) const
For a given lane mask LaneMask, compute indexes at which the lane is marked undefined by subregister ...
bool hasInterval(Register Reg) const
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Return the first index in the given basic block.
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Returns the instruction associated with the given index.
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
LiveRange * getCachedRegUnit(unsigned Unit)
Return the live range for register unit Unit if it has already been computed, or nullptr if it hasn't...
LiveInterval & getInterval(Register Reg)
bool isNotInMIMap(const MachineInstr &Instr) const
Returns true if the specified machine instr has been removed or was never entered in the map.
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const
void print(raw_ostream &O, const Module *=nullptr) const override
Implement the dump method.
Result of a LiveRange query.
bool isDeadDef() const
Return true if this instruction has a dead def.
VNInfo * valueIn() const
Return the value that is live-in to the instruction.
VNInfo * valueOut() const
Return the value leaving the instruction, if any.
bool isKill() const
Return true if the live-in value is killed by this instruction.
static LLVM_ATTRIBUTE_UNUSED bool isJointlyDominated(const MachineBasicBlock *MBB, ArrayRef< SlotIndex > Defs, const SlotIndexes &Indexes)
A diagnostic function to check if the end of the block MBB is jointly dominated by the blocks corresp...
This class represents the liveness of a register, stack slot, etc.
VNInfo * getValNumInfo(unsigned ValNo)
getValNumInfo - Returns pointer to the specified val#.
bool liveAt(SlotIndex index) const
bool covers(const LiveRange &Other) const
Returns true if all segments of the Other live range are completely covered by this live range.
LiveQueryResult Query(SlotIndex Idx) const
Query Liveness at Idx.
VNInfo * getVNInfoBefore(SlotIndex Idx) const
getVNInfoBefore - Return the VNInfo that is live up to but not necessarilly including Idx,...
unsigned getNumValNums() const
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
LiveInterval & getInterval(int Slot)
bool hasInterval(int Slot) const
VarInfo & getVarInfo(Register Reg)
getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.
TypeSize getValue() const
This class is intended to be used as a base class for asm properties and features specific to the tar...
ExceptionHandling getExceptionHandlingType() const
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
bool isConvergent() const
Return true if this instruction is convergent.
bool variadicOpsAreDefs() const
Return true if variadic operands of this instruction are definitions.
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specified operand constraint if it is present.
unsigned getOpcode() const
Return the opcode number for this descriptor.
This holds information about one operand of a machine instruction, indicating the register class for ...
bool isOptionalDef() const
Set if this operand is a optional def.
uint8_t OperandType
Information about the type of the operand.
MCRegAliasIterator enumerates all registers aliasing Reg.
bool isValid() const
isValid - Returns true until all the operands have been visited.
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
unsigned pred_size() const
bool isEHPad() const
Returns true if the block is a landing pad.
iterator_range< livein_iterator > liveins() const
iterator_range< iterator > phis()
Returns a range that iterates over the phis in the basic block.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
succ_iterator succ_begin()
bool isIRBlockAddressTaken() const
Test whether this block is the target of an IR BlockAddress.
unsigned succ_size() const
BasicBlock * getAddressTakenIRBlock() const
Retrieves the BasicBlock which corresponds to this MachineBasicBlock.
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
pred_iterator pred_begin()
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
unsigned getCallFrameSize() const
Return the call frame size on entry to this basic block.
iterator_range< succ_iterator > successors()
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
iterator_range< pred_iterator > predecessors()
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
BitVector getPristineRegs(const MachineFunction &MF) const
Return a set of physical registers that are pristine.
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.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
bool hasProperty(Property P) const
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.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const MachineFunctionProperties & getProperties() const
Get the function properties.
const MachineBasicBlock & front() const
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.
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream.
BasicBlockListType::const_iterator const_iterator
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool isReturn(QueryType Type=AnyInBundle) const
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
bool isBarrier(QueryType Type=AnyInBundle) const
Returns true if the specified instruction stops control flow from executing the instruction immediate...
A description of a memory reference used in the backend.
LocationSize getSize() const
Return the size in bytes of the memory reference.
const PseudoSourceValue * getPseudoValue() const
AtomicOrdering getSuccessOrdering() const
Return the atomic ordering requirements for this memory operation.
LocationSize getSizeInBits() const
Return the size in bits of the memory reference.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register.
bool isIntrinsicID() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
ArrayRef< int > getShuffleMask() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isValidExcessOperand() const
Return true if this operand can validly be appended to an arbitrary operand list.
bool isShuffleMask() const
unsigned getCFIIndex() const
bool isRenamable() const
isRenamable - Returns true if this register may be renamed, i.e.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
bool isEarlyClobber() const
Register getReg() const
getReg - Returns the register number.
bool isInternalRead() const
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
static bool clobbersPhysReg(const uint32_t *RegMask, MCRegister PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
void print(raw_ostream &os, const TargetRegisterInfo *TRI=nullptr, const TargetIntrinsicInfo *IntrinsicInfo=nullptr) const
Print the MachineOperand to os.
@ MO_CFIIndex
MCCFIInstruction index.
@ MO_RegisterMask
Mask of preserved registers.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_FrameIndex
Abstract Stack Frame Index.
@ MO_Register
Register operand.
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Pass interface - Implemented by all 'passes'.
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information tha...
Special value supplied for machine level alias analysis.
Holds all the information related to register banks.
const RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
unsigned getMaximumSize(unsigned RegBankID) const
Get the maximum size in bits that fits in the given register bank.
This class implements the register bank concept.
const char * getName() const
Get a user friendly name of this register bank.
unsigned getID() const
Get the identifier of this register bank.
Wrapper class representing virtual and physical registers.
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
static unsigned virtReg2Index(Register Reg)
Convert a virtual register number to a 0-based index.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
static constexpr bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
SlotIndex - An opaque wrapper around machine indexes.
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
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.
bool isEarlyClobber() const
isEarlyClobber - Returns true if this is an early-clobber slot.
bool isRegister() const
isRegister - Returns true if this is a normal register use/def slot.
SlotIndex getBoundaryIndex() const
Returns the boundary index for associated with this index.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def.
bool isDead() const
isDead - Returns true if this is a dead def kill slot.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
MBBIndexIterator MBBIndexBegin() const
Returns an iterator for the begin of the idx2MBBMap.
MBBIndexIterator MBBIndexEnd() const
Return an iterator for the end of the idx2MBBMap.
SmallVectorImpl< IdxMBBPair >::const_iterator MBBIndexIterator
Iterator over the idx2MBBMap (sorted pairs of slot index of basic block begin and basic block)
SlotIndex getInstructionIndex(const MachineInstr &MI, bool IgnoreBundle=false) const
Returns the base index for the given instruction.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
bool hasIndex(const MachineInstr &instr) const
Returns true if the given machine instr is mapped to an index, otherwise returns false.
bool erase(PtrType Ptr)
Remove pointer from the set.
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.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MI-level Statepoint operands.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
Primary interface to the complete machine description for the target machine.
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
virtual const RegisterBankInfo * getRegBankInfo() const
If the information for the register banks is available, return it.
virtual const TargetInstrInfo * getInstrInfo() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
VNInfo - Value Number Information.
bool isUnused() const
Returns true if this value is unused.
unsigned id
The ID number of this value.
SlotIndex def
The index of the defining instruction.
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
LLVM Value Representation.
std::pair< iterator, bool > insert(const ValueT &V)
constexpr bool isNonZero() const
static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
static constexpr bool isKnownGE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
self_iterator getIterator()
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
Reg
All possible values of the reg field in the ModR/M byte.
NodeAddr< PhiNode * > Phi
NodeAddr< DefNode * > Def
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
const_iterator end(StringRef path)
Get end iterator over path.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
@ SjLj
setjmp/longjmp based exceptions
bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel.
Printable printRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
void set_subtract(S1Ty &S1, const S2Ty &S2)
set_subtract(A, B) - Compute A := A - B
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
bool isPreISelGenericOptimizationHint(unsigned Opcode)
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch,...
void initializeMachineVerifierPassPass(PassRegistry &)
void verifyMachineFunction(const std::string &Banner, const MachineFunction &MF)
auto reverse(ContainerTy &&C)
detail::ValueMatchesPoly< M > HasValue(M Matcher)
df_ext_iterator< T, SetTy > df_ext_begin(const T &G, SetTy &S)
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
bool set_union(S1Ty &S1, const S2Ty &S2)
set_union(A, B) - Compute A := A u B, return whether A changed.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
AtomicOrdering
Atomic ordering for LLVM's memory model.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
df_ext_iterator< T, SetTy > df_ext_end(const T &G, SetTy &S)
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.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
FunctionPass * createMachineVerifierPass(const std::string &Banner)
createMachineVerifierPass - This pass verifies cenerated machine code instructions for correctness.
Implement std::hash so that hash_code can be used in STL containers.
static unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
static constexpr LaneBitmask getAll()
constexpr bool none() const
constexpr bool any() const
static constexpr LaneBitmask getNone()
This represents a simple continuous liveness interval for a value.
VarInfo - This represents the regions where a virtual register is live in the program.
Pair of physical register and lane mask.