1 //===-- MachineVerifier.cpp - Machine Code Verifier -----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Pass to verify generated machine code. The following is checked:
12 // Operand counts: All explicit operands must be present.
14 // Register classes: All physical and virtual register operands must be
15 // compatible with the register class required by the instruction descriptor.
17 // Register live intervals: Registers must be defined only once, and must be
18 // defined before use.
20 // The machine code verifier is enabled from LLVMTargetMachine.cpp with the
21 // command-line option -verify-machineinstrs, or by defining the environment
22 // variable LLVM_VERIFY_MACHINEINSTRS to the name of a file that will receive
23 // the verifier errors.
24 //===----------------------------------------------------------------------===//
26 #include "llvm/Instructions.h"
27 #include "llvm/Function.h"
28 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
29 #include "llvm/CodeGen/LiveVariables.h"
30 #include "llvm/CodeGen/LiveStackAnalysis.h"
31 #include "llvm/CodeGen/MachineInstrBundle.h"
32 #include "llvm/CodeGen/MachineFunctionPass.h"
33 #include "llvm/CodeGen/MachineFrameInfo.h"
34 #include "llvm/CodeGen/MachineMemOperand.h"
35 #include "llvm/CodeGen/MachineRegisterInfo.h"
36 #include "llvm/CodeGen/Passes.h"
37 #include "llvm/MC/MCAsmInfo.h"
38 #include "llvm/Target/TargetMachine.h"
39 #include "llvm/Target/TargetRegisterInfo.h"
40 #include "llvm/Target/TargetInstrInfo.h"
41 #include "llvm/ADT/DenseSet.h"
42 #include "llvm/ADT/SetOperations.h"
43 #include "llvm/ADT/SmallVector.h"
44 #include "llvm/Support/Debug.h"
45 #include "llvm/Support/ErrorHandling.h"
46 #include "llvm/Support/raw_ostream.h"
50 struct MachineVerifier {
52 MachineVerifier(Pass *pass, const char *b) :
55 OutFileName(getenv("LLVM_VERIFY_MACHINEINSTRS"))
58 bool runOnMachineFunction(MachineFunction &MF);
62 const char *const OutFileName;
64 const MachineFunction *MF;
65 const TargetMachine *TM;
66 const TargetInstrInfo *TII;
67 const TargetRegisterInfo *TRI;
68 const MachineRegisterInfo *MRI;
72 typedef SmallVector<unsigned, 16> RegVector;
73 typedef SmallVector<const uint32_t*, 4> RegMaskVector;
74 typedef DenseSet<unsigned> RegSet;
75 typedef DenseMap<unsigned, const MachineInstr*> RegMap;
77 const MachineInstr *FirstTerminator;
79 BitVector regsReserved;
80 BitVector regsAllocatable;
82 RegVector regsDefined, regsDead, regsKilled;
83 RegMaskVector regMasks;
84 RegSet regsLiveInButUnused;
88 // Add Reg and any sub-registers to RV
89 void addRegWithSubRegs(RegVector &RV, unsigned Reg) {
91 if (TargetRegisterInfo::isPhysicalRegister(Reg))
92 for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs)
93 RV.push_back(*SubRegs);
97 // Is this MBB reachable from the MF entry point?
100 // Vregs that must be live in because they are used without being
101 // defined. Map value is the user.
104 // Regs killed in MBB. They may be defined again, and will then be in both
105 // regsKilled and regsLiveOut.
108 // Regs defined in MBB and live out. Note that vregs passing through may
109 // be live out without being mentioned here.
112 // Vregs that pass through MBB untouched. This set is disjoint from
113 // regsKilled and regsLiveOut.
116 // Vregs that must pass through MBB because they are needed by a successor
117 // block. This set is disjoint from regsLiveOut.
118 RegSet vregsRequired;
120 BBInfo() : reachable(false) {}
122 // Add register to vregsPassed if it belongs there. Return true if
124 bool addPassed(unsigned Reg) {
125 if (!TargetRegisterInfo::isVirtualRegister(Reg))
127 if (regsKilled.count(Reg) || regsLiveOut.count(Reg))
129 return vregsPassed.insert(Reg).second;
132 // Same for a full set.
133 bool addPassed(const RegSet &RS) {
134 bool changed = false;
135 for (RegSet::const_iterator I = RS.begin(), E = RS.end(); I != E; ++I)
141 // Add register to vregsRequired if it belongs there. Return true if
143 bool addRequired(unsigned Reg) {
144 if (!TargetRegisterInfo::isVirtualRegister(Reg))
146 if (regsLiveOut.count(Reg))
148 return vregsRequired.insert(Reg).second;
151 // Same for a full set.
152 bool addRequired(const RegSet &RS) {
153 bool changed = false;
154 for (RegSet::const_iterator I = RS.begin(), E = RS.end(); I != E; ++I)
160 // Same for a full map.
161 bool addRequired(const RegMap &RM) {
162 bool changed = false;
163 for (RegMap::const_iterator I = RM.begin(), E = RM.end(); I != E; ++I)
164 if (addRequired(I->first))
169 // Live-out registers are either in regsLiveOut or vregsPassed.
170 bool isLiveOut(unsigned Reg) const {
171 return regsLiveOut.count(Reg) || vregsPassed.count(Reg);
175 // Extra register info per MBB.
176 DenseMap<const MachineBasicBlock*, BBInfo> MBBInfoMap;
178 bool isReserved(unsigned Reg) {
179 return Reg < regsReserved.size() && regsReserved.test(Reg);
182 bool isAllocatable(unsigned Reg) {
183 return Reg < regsAllocatable.size() && regsAllocatable.test(Reg);
186 // Analysis information if available
187 LiveVariables *LiveVars;
188 LiveIntervals *LiveInts;
189 LiveStacks *LiveStks;
190 SlotIndexes *Indexes;
192 void visitMachineFunctionBefore();
193 void visitMachineBasicBlockBefore(const MachineBasicBlock *MBB);
194 void visitMachineBundleBefore(const MachineInstr *MI);
195 void visitMachineInstrBefore(const MachineInstr *MI);
196 void visitMachineOperand(const MachineOperand *MO, unsigned MONum);
197 void visitMachineInstrAfter(const MachineInstr *MI);
198 void visitMachineBundleAfter(const MachineInstr *MI);
199 void visitMachineBasicBlockAfter(const MachineBasicBlock *MBB);
200 void visitMachineFunctionAfter();
202 void report(const char *msg, const MachineFunction *MF);
203 void report(const char *msg, const MachineBasicBlock *MBB);
204 void report(const char *msg, const MachineInstr *MI);
205 void report(const char *msg, const MachineOperand *MO, unsigned MONum);
207 void checkLiveness(const MachineOperand *MO, unsigned MONum);
208 void markReachable(const MachineBasicBlock *MBB);
209 void calcRegsPassed();
210 void checkPHIOps(const MachineBasicBlock *MBB);
212 void calcRegsRequired();
213 void verifyLiveVariables();
214 void verifyLiveIntervals();
217 struct MachineVerifierPass : public MachineFunctionPass {
218 static char ID; // Pass ID, replacement for typeid
219 const char *const Banner;
221 MachineVerifierPass(const char *b = 0)
222 : MachineFunctionPass(ID), Banner(b) {
223 initializeMachineVerifierPassPass(*PassRegistry::getPassRegistry());
226 void getAnalysisUsage(AnalysisUsage &AU) const {
227 AU.setPreservesAll();
228 MachineFunctionPass::getAnalysisUsage(AU);
231 bool runOnMachineFunction(MachineFunction &MF) {
232 MF.verify(this, Banner);
239 char MachineVerifierPass::ID = 0;
240 INITIALIZE_PASS(MachineVerifierPass, "machineverifier",
241 "Verify generated machine code", false, false)
243 FunctionPass *llvm::createMachineVerifierPass(const char *Banner) {
244 return new MachineVerifierPass(Banner);
247 void MachineFunction::verify(Pass *p, const char *Banner) const {
248 MachineVerifier(p, Banner)
249 .runOnMachineFunction(const_cast<MachineFunction&>(*this));
252 bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) {
253 raw_ostream *OutFile = 0;
255 std::string ErrorInfo;
256 OutFile = new raw_fd_ostream(OutFileName, ErrorInfo,
257 raw_fd_ostream::F_Append);
258 if (!ErrorInfo.empty()) {
259 errs() << "Error opening '" << OutFileName << "': " << ErrorInfo << '\n';
271 TM = &MF.getTarget();
272 TII = TM->getInstrInfo();
273 TRI = TM->getRegisterInfo();
274 MRI = &MF.getRegInfo();
281 LiveInts = PASS->getAnalysisIfAvailable<LiveIntervals>();
282 // We don't want to verify LiveVariables if LiveIntervals is available.
284 LiveVars = PASS->getAnalysisIfAvailable<LiveVariables>();
285 LiveStks = PASS->getAnalysisIfAvailable<LiveStacks>();
286 Indexes = PASS->getAnalysisIfAvailable<SlotIndexes>();
289 visitMachineFunctionBefore();
290 for (MachineFunction::const_iterator MFI = MF.begin(), MFE = MF.end();
292 visitMachineBasicBlockBefore(MFI);
293 // Keep track of the current bundle header.
294 const MachineInstr *CurBundle = 0;
295 for (MachineBasicBlock::const_instr_iterator MBBI = MFI->instr_begin(),
296 MBBE = MFI->instr_end(); MBBI != MBBE; ++MBBI) {
297 if (MBBI->getParent() != MFI) {
298 report("Bad instruction parent pointer", MFI);
299 *OS << "Instruction: " << *MBBI;
302 // Is this a bundle header?
303 if (!MBBI->isInsideBundle()) {
305 visitMachineBundleAfter(CurBundle);
307 visitMachineBundleBefore(CurBundle);
308 } else if (!CurBundle)
309 report("No bundle header", MBBI);
310 visitMachineInstrBefore(MBBI);
311 for (unsigned I = 0, E = MBBI->getNumOperands(); I != E; ++I)
312 visitMachineOperand(&MBBI->getOperand(I), I);
313 visitMachineInstrAfter(MBBI);
316 visitMachineBundleAfter(CurBundle);
317 visitMachineBasicBlockAfter(MFI);
319 visitMachineFunctionAfter();
323 else if (foundErrors)
324 report_fatal_error("Found "+Twine(foundErrors)+" machine code errors.");
332 regsLiveInButUnused.clear();
335 return false; // no changes
338 void MachineVerifier::report(const char *msg, const MachineFunction *MF) {
341 if (!foundErrors++) {
343 *OS << "# " << Banner << '\n';
344 MF->print(*OS, Indexes);
346 *OS << "*** Bad machine code: " << msg << " ***\n"
347 << "- function: " << MF->getFunction()->getName() << "\n";
350 void MachineVerifier::report(const char *msg, const MachineBasicBlock *MBB) {
352 report(msg, MBB->getParent());
353 *OS << "- basic block: " << MBB->getName()
355 << " (BB#" << MBB->getNumber() << ")";
357 *OS << " [" << Indexes->getMBBStartIdx(MBB)
358 << ';' << Indexes->getMBBEndIdx(MBB) << ')';
362 void MachineVerifier::report(const char *msg, const MachineInstr *MI) {
364 report(msg, MI->getParent());
365 *OS << "- instruction: ";
366 if (Indexes && Indexes->hasIndex(MI))
367 *OS << Indexes->getInstructionIndex(MI) << '\t';
371 void MachineVerifier::report(const char *msg,
372 const MachineOperand *MO, unsigned MONum) {
374 report(msg, MO->getParent());
375 *OS << "- operand " << MONum << ": ";
380 void MachineVerifier::markReachable(const MachineBasicBlock *MBB) {
381 BBInfo &MInfo = MBBInfoMap[MBB];
382 if (!MInfo.reachable) {
383 MInfo.reachable = true;
384 for (MachineBasicBlock::const_succ_iterator SuI = MBB->succ_begin(),
385 SuE = MBB->succ_end(); SuI != SuE; ++SuI)
390 void MachineVerifier::visitMachineFunctionBefore() {
391 lastIndex = SlotIndex();
392 regsReserved = TRI->getReservedRegs(*MF);
394 // A sub-register of a reserved register is also reserved
395 for (int Reg = regsReserved.find_first(); Reg>=0;
396 Reg = regsReserved.find_next(Reg)) {
397 for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs) {
398 // FIXME: This should probably be:
399 // assert(regsReserved.test(*SubRegs) && "Non-reserved sub-register");
400 regsReserved.set(*SubRegs);
404 regsAllocatable = TRI->getAllocatableSet(*MF);
406 markReachable(&MF->front());
409 // Does iterator point to a and b as the first two elements?
410 static bool matchPair(MachineBasicBlock::const_succ_iterator i,
411 const MachineBasicBlock *a, const MachineBasicBlock *b) {
420 MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) {
424 // If this block has allocatable physical registers live-in, check that
425 // it is an entry block or landing pad.
426 for (MachineBasicBlock::livein_iterator LI = MBB->livein_begin(),
427 LE = MBB->livein_end();
430 if (isAllocatable(reg) && !MBB->isLandingPad() &&
431 MBB != MBB->getParent()->begin()) {
432 report("MBB has allocable live-in, but isn't entry or landing-pad.", MBB);
437 // Count the number of landing pad successors.
438 SmallPtrSet<MachineBasicBlock*, 4> LandingPadSuccs;
439 for (MachineBasicBlock::const_succ_iterator I = MBB->succ_begin(),
440 E = MBB->succ_end(); I != E; ++I) {
441 if ((*I)->isLandingPad())
442 LandingPadSuccs.insert(*I);
445 const MCAsmInfo *AsmInfo = TM->getMCAsmInfo();
446 const BasicBlock *BB = MBB->getBasicBlock();
447 if (LandingPadSuccs.size() > 1 &&
449 AsmInfo->getExceptionHandlingType() == ExceptionHandling::SjLj &&
450 BB && isa<SwitchInst>(BB->getTerminator())))
451 report("MBB has more than one landing pad successor", MBB);
453 // Call AnalyzeBranch. If it succeeds, there several more conditions to check.
454 MachineBasicBlock *TBB = 0, *FBB = 0;
455 SmallVector<MachineOperand, 4> Cond;
456 if (!TII->AnalyzeBranch(*const_cast<MachineBasicBlock *>(MBB),
458 // Ok, AnalyzeBranch thinks it knows what's going on with this block. Let's
459 // check whether its answers match up with reality.
461 // Block falls through to its successor.
462 MachineFunction::const_iterator MBBI = MBB;
464 if (MBBI == MF->end()) {
465 // It's possible that the block legitimately ends with a noreturn
466 // call or an unreachable, in which case it won't actually fall
467 // out the bottom of the function.
468 } else if (MBB->succ_size() == LandingPadSuccs.size()) {
469 // It's possible that the block legitimately ends with a noreturn
470 // call or an unreachable, in which case it won't actuall fall
472 } else if (MBB->succ_size() != 1+LandingPadSuccs.size()) {
473 report("MBB exits via unconditional fall-through but doesn't have "
474 "exactly one CFG successor!", MBB);
475 } else if (!MBB->isSuccessor(MBBI)) {
476 report("MBB exits via unconditional fall-through but its successor "
477 "differs from its CFG successor!", MBB);
479 if (!MBB->empty() && getBundleStart(&MBB->back())->isBarrier() &&
480 !TII->isPredicated(getBundleStart(&MBB->back()))) {
481 report("MBB exits via unconditional fall-through but ends with a "
482 "barrier instruction!", MBB);
485 report("MBB exits via unconditional fall-through but has a condition!",
488 } else if (TBB && !FBB && Cond.empty()) {
489 // Block unconditionally branches somewhere.
490 if (MBB->succ_size() != 1+LandingPadSuccs.size()) {
491 report("MBB exits via unconditional branch but doesn't have "
492 "exactly one CFG successor!", MBB);
493 } else if (!MBB->isSuccessor(TBB)) {
494 report("MBB exits via unconditional branch but the CFG "
495 "successor doesn't match the actual successor!", MBB);
498 report("MBB exits via unconditional branch but doesn't contain "
499 "any instructions!", MBB);
500 } else if (!getBundleStart(&MBB->back())->isBarrier()) {
501 report("MBB exits via unconditional branch but doesn't end with a "
502 "barrier instruction!", MBB);
503 } else if (!getBundleStart(&MBB->back())->isTerminator()) {
504 report("MBB exits via unconditional branch but the branch isn't a "
505 "terminator instruction!", MBB);
507 } else if (TBB && !FBB && !Cond.empty()) {
508 // Block conditionally branches somewhere, otherwise falls through.
509 MachineFunction::const_iterator MBBI = MBB;
511 if (MBBI == MF->end()) {
512 report("MBB conditionally falls through out of function!", MBB);
513 } if (MBB->succ_size() != 2) {
514 report("MBB exits via conditional branch/fall-through but doesn't have "
515 "exactly two CFG successors!", MBB);
516 } else if (!matchPair(MBB->succ_begin(), TBB, MBBI)) {
517 report("MBB exits via conditional branch/fall-through but the CFG "
518 "successors don't match the actual successors!", MBB);
521 report("MBB exits via conditional branch/fall-through but doesn't "
522 "contain any instructions!", MBB);
523 } else if (getBundleStart(&MBB->back())->isBarrier()) {
524 report("MBB exits via conditional branch/fall-through but ends with a "
525 "barrier instruction!", MBB);
526 } else if (!getBundleStart(&MBB->back())->isTerminator()) {
527 report("MBB exits via conditional branch/fall-through but the branch "
528 "isn't a terminator instruction!", MBB);
530 } else if (TBB && FBB) {
531 // Block conditionally branches somewhere, otherwise branches
533 if (MBB->succ_size() != 2) {
534 report("MBB exits via conditional branch/branch but doesn't have "
535 "exactly two CFG successors!", MBB);
536 } else if (!matchPair(MBB->succ_begin(), TBB, FBB)) {
537 report("MBB exits via conditional branch/branch but the CFG "
538 "successors don't match the actual successors!", MBB);
541 report("MBB exits via conditional branch/branch but doesn't "
542 "contain any instructions!", MBB);
543 } else if (!getBundleStart(&MBB->back())->isBarrier()) {
544 report("MBB exits via conditional branch/branch but doesn't end with a "
545 "barrier instruction!", MBB);
546 } else if (!getBundleStart(&MBB->back())->isTerminator()) {
547 report("MBB exits via conditional branch/branch but the branch "
548 "isn't a terminator instruction!", MBB);
551 report("MBB exits via conditinal branch/branch but there's no "
555 report("AnalyzeBranch returned invalid data!", MBB);
560 for (MachineBasicBlock::livein_iterator I = MBB->livein_begin(),
561 E = MBB->livein_end(); I != E; ++I) {
562 if (!TargetRegisterInfo::isPhysicalRegister(*I)) {
563 report("MBB live-in list contains non-physical register", MBB);
567 for (MCSubRegIterator SubRegs(*I, TRI); SubRegs.isValid(); ++SubRegs)
568 regsLive.insert(*SubRegs);
570 regsLiveInButUnused = regsLive;
572 const MachineFrameInfo *MFI = MF->getFrameInfo();
573 assert(MFI && "Function has no frame info");
574 BitVector PR = MFI->getPristineRegs(MBB);
575 for (int I = PR.find_first(); I>0; I = PR.find_next(I)) {
577 for (MCSubRegIterator SubRegs(I, TRI); SubRegs.isValid(); ++SubRegs)
578 regsLive.insert(*SubRegs);
585 lastIndex = Indexes->getMBBStartIdx(MBB);
588 // This function gets called for all bundle headers, including normal
589 // stand-alone unbundled instructions.
590 void MachineVerifier::visitMachineBundleBefore(const MachineInstr *MI) {
591 if (Indexes && Indexes->hasIndex(MI)) {
592 SlotIndex idx = Indexes->getInstructionIndex(MI);
593 if (!(idx > lastIndex)) {
594 report("Instruction index out of order", MI);
595 *OS << "Last instruction was at " << lastIndex << '\n';
600 // Ensure non-terminators don't follow terminators.
601 // Ignore predicated terminators formed by if conversion.
602 // FIXME: If conversion shouldn't need to violate this rule.
603 if (MI->isTerminator() && !TII->isPredicated(MI)) {
604 if (!FirstTerminator)
605 FirstTerminator = MI;
606 } else if (FirstTerminator) {
607 report("Non-terminator instruction after the first terminator", MI);
608 *OS << "First terminator was:\t" << *FirstTerminator;
612 void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
613 const MCInstrDesc &MCID = MI->getDesc();
614 if (MI->getNumOperands() < MCID.getNumOperands()) {
615 report("Too few operands", MI);
616 *OS << MCID.getNumOperands() << " operands expected, but "
617 << MI->getNumExplicitOperands() << " given.\n";
620 // Check the MachineMemOperands for basic consistency.
621 for (MachineInstr::mmo_iterator I = MI->memoperands_begin(),
622 E = MI->memoperands_end(); I != E; ++I) {
623 if ((*I)->isLoad() && !MI->mayLoad())
624 report("Missing mayLoad flag", MI);
625 if ((*I)->isStore() && !MI->mayStore())
626 report("Missing mayStore flag", MI);
629 // Debug values must not have a slot index.
630 // Other instructions must have one, unless they are inside a bundle.
632 bool mapped = !LiveInts->isNotInMIMap(MI);
633 if (MI->isDebugValue()) {
635 report("Debug instruction has a slot index", MI);
636 } else if (MI->isInsideBundle()) {
638 report("Instruction inside bundle has a slot index", MI);
641 report("Missing slot index", MI);
646 if (!TII->verifyInstruction(MI, ErrorInfo))
647 report(ErrorInfo.data(), MI);
651 MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
652 const MachineInstr *MI = MO->getParent();
653 const MCInstrDesc &MCID = MI->getDesc();
654 const MCOperandInfo &MCOI = MCID.OpInfo[MONum];
656 // The first MCID.NumDefs operands must be explicit register defines
657 if (MONum < MCID.getNumDefs()) {
659 report("Explicit definition must be a register", MO, MONum);
660 else if (!MO->isDef() && !MCOI.isOptionalDef())
661 report("Explicit definition marked as use", MO, MONum);
662 else if (MO->isImplicit())
663 report("Explicit definition marked as implicit", MO, MONum);
664 } else if (MONum < MCID.getNumOperands()) {
665 // Don't check if it's the last operand in a variadic instruction. See,
666 // e.g., LDM_RET in the arm back end.
668 !(MI->isVariadic() && MONum == MCID.getNumOperands()-1)) {
669 if (MO->isDef() && !MCOI.isOptionalDef())
670 report("Explicit operand marked as def", MO, MONum);
671 if (MO->isImplicit())
672 report("Explicit operand marked as implicit", MO, MONum);
675 // ARM adds %reg0 operands to indicate predicates. We'll allow that.
676 if (MO->isReg() && !MO->isImplicit() && !MI->isVariadic() && MO->getReg())
677 report("Extra explicit operand on non-variadic instruction", MO, MONum);
680 switch (MO->getType()) {
681 case MachineOperand::MO_Register: {
682 const unsigned Reg = MO->getReg();
685 if (MRI->tracksLiveness() && !MI->isDebugValue())
686 checkLiveness(MO, MONum);
688 // Verify two-address constraints after leaving SSA form.
690 if (!MRI->isSSA() && MO->isUse() &&
691 MI->isRegTiedToDefOperand(MONum, &DefIdx) &&
692 Reg != MI->getOperand(DefIdx).getReg())
693 report("Two-address instruction operands must be identical", MO, MONum);
695 // Check register classes.
696 if (MONum < MCID.getNumOperands() && !MO->isImplicit()) {
697 unsigned SubIdx = MO->getSubReg();
699 if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
701 report("Illegal subregister index for physical register", MO, MONum);
704 if (const TargetRegisterClass *DRC =
705 TII->getRegClass(MCID, MONum, TRI, *MF)) {
706 if (!DRC->contains(Reg)) {
707 report("Illegal physical register for instruction", MO, MONum);
708 *OS << TRI->getName(Reg) << " is not a "
709 << DRC->getName() << " register.\n";
714 const TargetRegisterClass *RC = MRI->getRegClass(Reg);
716 const TargetRegisterClass *SRC =
717 TRI->getSubClassWithSubReg(RC, SubIdx);
719 report("Invalid subregister index for virtual register", MO, MONum);
720 *OS << "Register class " << RC->getName()
721 << " does not support subreg index " << SubIdx << "\n";
725 report("Invalid register class for subregister index", MO, MONum);
726 *OS << "Register class " << RC->getName()
727 << " does not fully support subreg index " << SubIdx << "\n";
731 if (const TargetRegisterClass *DRC =
732 TII->getRegClass(MCID, MONum, TRI, *MF)) {
734 const TargetRegisterClass *SuperRC =
735 TRI->getLargestLegalSuperClass(RC);
737 report("No largest legal super class exists.", MO, MONum);
740 DRC = TRI->getMatchingSuperRegClass(SuperRC, DRC, SubIdx);
742 report("No matching super-reg register class.", MO, MONum);
746 if (!RC->hasSuperClassEq(DRC)) {
747 report("Illegal virtual register for instruction", MO, MONum);
748 *OS << "Expected a " << DRC->getName() << " register, but got a "
749 << RC->getName() << " register\n";
757 case MachineOperand::MO_RegisterMask:
758 regMasks.push_back(MO->getRegMask());
761 case MachineOperand::MO_MachineBasicBlock:
762 if (MI->isPHI() && !MO->getMBB()->isSuccessor(MI->getParent()))
763 report("PHI operand is not in the CFG", MO, MONum);
766 case MachineOperand::MO_FrameIndex:
767 if (LiveStks && LiveStks->hasInterval(MO->getIndex()) &&
768 LiveInts && !LiveInts->isNotInMIMap(MI)) {
769 LiveInterval &LI = LiveStks->getInterval(MO->getIndex());
770 SlotIndex Idx = LiveInts->getInstructionIndex(MI);
771 if (MI->mayLoad() && !LI.liveAt(Idx.getRegSlot(true))) {
772 report("Instruction loads from dead spill slot", MO, MONum);
773 *OS << "Live stack: " << LI << '\n';
775 if (MI->mayStore() && !LI.liveAt(Idx.getRegSlot())) {
776 report("Instruction stores to dead spill slot", MO, MONum);
777 *OS << "Live stack: " << LI << '\n';
787 void MachineVerifier::checkLiveness(const MachineOperand *MO, unsigned MONum) {
788 const MachineInstr *MI = MO->getParent();
789 const unsigned Reg = MO->getReg();
791 // Both use and def operands can read a register.
792 if (MO->readsReg()) {
793 regsLiveInButUnused.erase(Reg);
796 addRegWithSubRegs(regsKilled, Reg);
798 // Check that LiveVars knows this kill.
799 if (LiveVars && TargetRegisterInfo::isVirtualRegister(Reg) &&
801 LiveVariables::VarInfo &VI = LiveVars->getVarInfo(Reg);
802 if (std::find(VI.Kills.begin(), VI.Kills.end(), MI) == VI.Kills.end())
803 report("Kill missing from LiveVariables", MO, MONum);
806 // Check LiveInts liveness and kill.
807 if (LiveInts && !LiveInts->isNotInMIMap(MI)) {
808 SlotIndex UseIdx = LiveInts->getInstructionIndex(MI);
809 // Check the cached regunit intervals.
810 if (TargetRegisterInfo::isPhysicalRegister(Reg) && !isReserved(Reg)) {
811 for (MCRegUnitIterator Units(Reg, TRI); Units.isValid(); ++Units) {
812 if (const LiveInterval *LI = LiveInts->getCachedRegUnit(*Units)) {
813 LiveRangeQuery LRQ(*LI, UseIdx);
814 if (!LRQ.valueIn()) {
815 report("No live range at use", MO, MONum);
816 *OS << UseIdx << " is not live in " << PrintRegUnit(*Units, TRI)
817 << ' ' << *LI << '\n';
819 if (MO->isKill() && !LRQ.isKill()) {
820 report("Live range continues after kill flag", MO, MONum);
821 *OS << PrintRegUnit(*Units, TRI) << ' ' << *LI << '\n';
827 if (TargetRegisterInfo::isVirtualRegister(Reg)) {
828 if (LiveInts->hasInterval(Reg)) {
829 // This is a virtual register interval.
830 const LiveInterval &LI = LiveInts->getInterval(Reg);
831 LiveRangeQuery LRQ(LI, UseIdx);
832 if (!LRQ.valueIn()) {
833 report("No live range at use", MO, MONum);
834 *OS << UseIdx << " is not live in " << LI << '\n';
836 // Check for extra kill flags.
837 // Note that we allow missing kill flags for now.
838 if (MO->isKill() && !LRQ.isKill()) {
839 report("Live range continues after kill flag", MO, MONum);
840 *OS << "Live range: " << LI << '\n';
843 report("Virtual register has no live interval", MO, MONum);
848 // Use of a dead register.
849 if (!regsLive.count(Reg)) {
850 if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
851 // Reserved registers may be used even when 'dead'.
852 if (!isReserved(Reg))
853 report("Using an undefined physical register", MO, MONum);
854 } else if (MRI->def_empty(Reg)) {
855 report("Reading virtual register without a def", MO, MONum);
857 BBInfo &MInfo = MBBInfoMap[MI->getParent()];
858 // We don't know which virtual registers are live in, so only complain
859 // if vreg was killed in this MBB. Otherwise keep track of vregs that
860 // must be live in. PHI instructions are handled separately.
861 if (MInfo.regsKilled.count(Reg))
862 report("Using a killed virtual register", MO, MONum);
863 else if (!MI->isPHI())
864 MInfo.vregsLiveIn.insert(std::make_pair(Reg, MI));
871 // TODO: verify that earlyclobber ops are not used.
873 addRegWithSubRegs(regsDead, Reg);
875 addRegWithSubRegs(regsDefined, Reg);
878 if (MRI->isSSA() && TargetRegisterInfo::isVirtualRegister(Reg) &&
879 llvm::next(MRI->def_begin(Reg)) != MRI->def_end())
880 report("Multiple virtual register defs in SSA form", MO, MONum);
882 // Check LiveInts for a live range, but only for virtual registers.
883 if (LiveInts && TargetRegisterInfo::isVirtualRegister(Reg) &&
884 !LiveInts->isNotInMIMap(MI)) {
885 SlotIndex DefIdx = LiveInts->getInstructionIndex(MI);
886 DefIdx = DefIdx.getRegSlot(MO->isEarlyClobber());
887 if (LiveInts->hasInterval(Reg)) {
888 const LiveInterval &LI = LiveInts->getInterval(Reg);
889 if (const VNInfo *VNI = LI.getVNInfoAt(DefIdx)) {
890 assert(VNI && "NULL valno is not allowed");
891 if (VNI->def != DefIdx) {
892 report("Inconsistent valno->def", MO, MONum);
893 *OS << "Valno " << VNI->id << " is not defined at "
894 << DefIdx << " in " << LI << '\n';
897 report("No live range at def", MO, MONum);
898 *OS << DefIdx << " is not live in " << LI << '\n';
901 report("Virtual register has no Live interval", MO, MONum);
907 void MachineVerifier::visitMachineInstrAfter(const MachineInstr *MI) {
910 // This function gets called after visiting all instructions in a bundle. The
911 // argument points to the bundle header.
912 // Normal stand-alone instructions are also considered 'bundles', and this
913 // function is called for all of them.
914 void MachineVerifier::visitMachineBundleAfter(const MachineInstr *MI) {
915 BBInfo &MInfo = MBBInfoMap[MI->getParent()];
916 set_union(MInfo.regsKilled, regsKilled);
917 set_subtract(regsLive, regsKilled); regsKilled.clear();
918 // Kill any masked registers.
919 while (!regMasks.empty()) {
920 const uint32_t *Mask = regMasks.pop_back_val();
921 for (RegSet::iterator I = regsLive.begin(), E = regsLive.end(); I != E; ++I)
922 if (TargetRegisterInfo::isPhysicalRegister(*I) &&
923 MachineOperand::clobbersPhysReg(Mask, *I))
924 regsDead.push_back(*I);
926 set_subtract(regsLive, regsDead); regsDead.clear();
927 set_union(regsLive, regsDefined); regsDefined.clear();
931 MachineVerifier::visitMachineBasicBlockAfter(const MachineBasicBlock *MBB) {
932 MBBInfoMap[MBB].regsLiveOut = regsLive;
936 SlotIndex stop = Indexes->getMBBEndIdx(MBB);
937 if (!(stop > lastIndex)) {
938 report("Block ends before last instruction index", MBB);
939 *OS << "Block ends at " << stop
940 << " last instruction was at " << lastIndex << '\n';
946 // Calculate the largest possible vregsPassed sets. These are the registers that
947 // can pass through an MBB live, but may not be live every time. It is assumed
948 // that all vregsPassed sets are empty before the call.
949 void MachineVerifier::calcRegsPassed() {
950 // First push live-out regs to successors' vregsPassed. Remember the MBBs that
951 // have any vregsPassed.
952 SmallPtrSet<const MachineBasicBlock*, 8> todo;
953 for (MachineFunction::const_iterator MFI = MF->begin(), MFE = MF->end();
955 const MachineBasicBlock &MBB(*MFI);
956 BBInfo &MInfo = MBBInfoMap[&MBB];
957 if (!MInfo.reachable)
959 for (MachineBasicBlock::const_succ_iterator SuI = MBB.succ_begin(),
960 SuE = MBB.succ_end(); SuI != SuE; ++SuI) {
961 BBInfo &SInfo = MBBInfoMap[*SuI];
962 if (SInfo.addPassed(MInfo.regsLiveOut))
967 // Iteratively push vregsPassed to successors. This will converge to the same
968 // final state regardless of DenseSet iteration order.
969 while (!todo.empty()) {
970 const MachineBasicBlock *MBB = *todo.begin();
972 BBInfo &MInfo = MBBInfoMap[MBB];
973 for (MachineBasicBlock::const_succ_iterator SuI = MBB->succ_begin(),
974 SuE = MBB->succ_end(); SuI != SuE; ++SuI) {
977 BBInfo &SInfo = MBBInfoMap[*SuI];
978 if (SInfo.addPassed(MInfo.vregsPassed))
984 // Calculate the set of virtual registers that must be passed through each basic
985 // block in order to satisfy the requirements of successor blocks. This is very
986 // similar to calcRegsPassed, only backwards.
987 void MachineVerifier::calcRegsRequired() {
988 // First push live-in regs to predecessors' vregsRequired.
989 SmallPtrSet<const MachineBasicBlock*, 8> todo;
990 for (MachineFunction::const_iterator MFI = MF->begin(), MFE = MF->end();
992 const MachineBasicBlock &MBB(*MFI);
993 BBInfo &MInfo = MBBInfoMap[&MBB];
994 for (MachineBasicBlock::const_pred_iterator PrI = MBB.pred_begin(),
995 PrE = MBB.pred_end(); PrI != PrE; ++PrI) {
996 BBInfo &PInfo = MBBInfoMap[*PrI];
997 if (PInfo.addRequired(MInfo.vregsLiveIn))
1002 // Iteratively push vregsRequired to predecessors. This will converge to the
1003 // same final state regardless of DenseSet iteration order.
1004 while (!todo.empty()) {
1005 const MachineBasicBlock *MBB = *todo.begin();
1007 BBInfo &MInfo = MBBInfoMap[MBB];
1008 for (MachineBasicBlock::const_pred_iterator PrI = MBB->pred_begin(),
1009 PrE = MBB->pred_end(); PrI != PrE; ++PrI) {
1012 BBInfo &SInfo = MBBInfoMap[*PrI];
1013 if (SInfo.addRequired(MInfo.vregsRequired))
1019 // Check PHI instructions at the beginning of MBB. It is assumed that
1020 // calcRegsPassed has been run so BBInfo::isLiveOut is valid.
1021 void MachineVerifier::checkPHIOps(const MachineBasicBlock *MBB) {
1022 SmallPtrSet<const MachineBasicBlock*, 8> seen;
1023 for (MachineBasicBlock::const_iterator BBI = MBB->begin(), BBE = MBB->end();
1024 BBI != BBE && BBI->isPHI(); ++BBI) {
1027 for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2) {
1028 unsigned Reg = BBI->getOperand(i).getReg();
1029 const MachineBasicBlock *Pre = BBI->getOperand(i + 1).getMBB();
1030 if (!Pre->isSuccessor(MBB))
1033 BBInfo &PrInfo = MBBInfoMap[Pre];
1034 if (PrInfo.reachable && !PrInfo.isLiveOut(Reg))
1035 report("PHI operand is not live-out from predecessor",
1036 &BBI->getOperand(i), i);
1039 // Did we see all predecessors?
1040 for (MachineBasicBlock::const_pred_iterator PrI = MBB->pred_begin(),
1041 PrE = MBB->pred_end(); PrI != PrE; ++PrI) {
1042 if (!seen.count(*PrI)) {
1043 report("Missing PHI operand", BBI);
1044 *OS << "BB#" << (*PrI)->getNumber()
1045 << " is a predecessor according to the CFG.\n";
1051 void MachineVerifier::visitMachineFunctionAfter() {
1054 for (MachineFunction::const_iterator MFI = MF->begin(), MFE = MF->end();
1055 MFI != MFE; ++MFI) {
1056 BBInfo &MInfo = MBBInfoMap[MFI];
1058 // Skip unreachable MBBs.
1059 if (!MInfo.reachable)
1065 // Now check liveness info if available
1068 // Check for killed virtual registers that should be live out.
1069 for (MachineFunction::const_iterator MFI = MF->begin(), MFE = MF->end();
1070 MFI != MFE; ++MFI) {
1071 BBInfo &MInfo = MBBInfoMap[MFI];
1072 for (RegSet::iterator
1073 I = MInfo.vregsRequired.begin(), E = MInfo.vregsRequired.end(); I != E;
1075 if (MInfo.regsKilled.count(*I)) {
1076 report("Virtual register killed in block, but needed live out.", MFI);
1077 *OS << "Virtual register " << PrintReg(*I)
1078 << " is used after the block.\n";
1083 BBInfo &MInfo = MBBInfoMap[&MF->front()];
1084 for (RegSet::iterator
1085 I = MInfo.vregsRequired.begin(), E = MInfo.vregsRequired.end(); I != E;
1087 report("Virtual register def doesn't dominate all uses.",
1088 MRI->getVRegDef(*I));
1092 verifyLiveVariables();
1094 verifyLiveIntervals();
1097 void MachineVerifier::verifyLiveVariables() {
1098 assert(LiveVars && "Don't call verifyLiveVariables without LiveVars");
1099 for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
1100 unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
1101 LiveVariables::VarInfo &VI = LiveVars->getVarInfo(Reg);
1102 for (MachineFunction::const_iterator MFI = MF->begin(), MFE = MF->end();
1103 MFI != MFE; ++MFI) {
1104 BBInfo &MInfo = MBBInfoMap[MFI];
1106 // Our vregsRequired should be identical to LiveVariables' AliveBlocks
1107 if (MInfo.vregsRequired.count(Reg)) {
1108 if (!VI.AliveBlocks.test(MFI->getNumber())) {
1109 report("LiveVariables: Block missing from AliveBlocks", MFI);
1110 *OS << "Virtual register " << PrintReg(Reg)
1111 << " must be live through the block.\n";
1114 if (VI.AliveBlocks.test(MFI->getNumber())) {
1115 report("LiveVariables: Block should not be in AliveBlocks", MFI);
1116 *OS << "Virtual register " << PrintReg(Reg)
1117 << " is not needed live through the block.\n";
1124 void MachineVerifier::verifyLiveIntervals() {
1125 assert(LiveInts && "Don't call verifyLiveIntervals without LiveInts");
1126 for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
1127 unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
1129 // Spilling and splitting may leave unused registers around. Skip them.
1130 if (MRI->reg_nodbg_empty(Reg))
1133 if (!LiveInts->hasInterval(Reg)) {
1134 report("Missing live interval for virtual register", MF);
1135 *OS << PrintReg(Reg, TRI) << " still has defs or uses\n";
1139 const LiveInterval &LI = LiveInts->getInterval(Reg);
1140 assert(Reg == LI.reg && "Invalid reg to interval mapping");
1142 for (LiveInterval::const_vni_iterator I = LI.vni_begin(), E = LI.vni_end();
1145 const VNInfo *DefVNI = LI.getVNInfoAt(VNI->def);
1148 if (!VNI->isUnused()) {
1149 report("Valno not live at def and not marked unused", MF);
1150 *OS << "Valno #" << VNI->id << " in " << LI << '\n';
1155 if (VNI->isUnused())
1158 if (DefVNI != VNI) {
1159 report("Live range at def has different valno", MF);
1160 *OS << "Valno #" << VNI->id << " is defined at " << VNI->def
1161 << " where valno #" << DefVNI->id << " is live in " << LI << '\n';
1165 const MachineBasicBlock *MBB = LiveInts->getMBBFromIndex(VNI->def);
1167 report("Invalid definition index", MF);
1168 *OS << "Valno #" << VNI->id << " is defined at " << VNI->def
1169 << " in " << LI << '\n';
1173 if (VNI->isPHIDef()) {
1174 if (VNI->def != LiveInts->getMBBStartIdx(MBB)) {
1175 report("PHIDef value is not defined at MBB start", MF);
1176 *OS << "Valno #" << VNI->id << " is defined at " << VNI->def
1177 << ", not at the beginning of BB#" << MBB->getNumber()
1178 << " in " << LI << '\n';
1182 const MachineInstr *MI = LiveInts->getInstructionFromIndex(VNI->def);
1184 report("No instruction at def index", MF);
1185 *OS << "Valno #" << VNI->id << " is defined at " << VNI->def
1186 << " in " << LI << '\n';
1190 bool hasDef = false;
1191 bool isEarlyClobber = false;
1192 for (ConstMIBundleOperands MOI(MI); MOI.isValid(); ++MOI) {
1193 if (!MOI->isReg() || !MOI->isDef())
1195 if (TargetRegisterInfo::isVirtualRegister(LI.reg)) {
1196 if (MOI->getReg() != LI.reg)
1199 if (!TargetRegisterInfo::isPhysicalRegister(MOI->getReg()) ||
1200 !TRI->regsOverlap(LI.reg, MOI->getReg()))
1204 if (MOI->isEarlyClobber())
1205 isEarlyClobber = true;
1209 report("Defining instruction does not modify register", MI);
1210 *OS << "Valno #" << VNI->id << " in " << LI << '\n';
1213 // Early clobber defs begin at USE slots, but other defs must begin at
1215 if (isEarlyClobber) {
1216 if (!VNI->def.isEarlyClobber()) {
1217 report("Early clobber def must be at an early-clobber slot", MF);
1218 *OS << "Valno #" << VNI->id << " is defined at " << VNI->def
1219 << " in " << LI << '\n';
1221 } else if (!VNI->def.isRegister()) {
1222 report("Non-PHI, non-early clobber def must be at a register slot",
1224 *OS << "Valno #" << VNI->id << " is defined at " << VNI->def
1225 << " in " << LI << '\n';
1230 for (LiveInterval::const_iterator I = LI.begin(), E = LI.end(); I!=E; ++I) {
1231 const VNInfo *VNI = I->valno;
1232 assert(VNI && "Live range has no valno");
1234 if (VNI->id >= LI.getNumValNums() || VNI != LI.getValNumInfo(VNI->id)) {
1235 report("Foreign valno in live range", MF);
1237 *OS << " has a valno not in " << LI << '\n';
1240 if (VNI->isUnused()) {
1241 report("Live range valno is marked unused", MF);
1243 *OS << " in " << LI << '\n';
1246 const MachineBasicBlock *MBB = LiveInts->getMBBFromIndex(I->start);
1248 report("Bad start of live segment, no basic block", MF);
1250 *OS << " in " << LI << '\n';
1253 SlotIndex MBBStartIdx = LiveInts->getMBBStartIdx(MBB);
1254 if (I->start != MBBStartIdx && I->start != VNI->def) {
1255 report("Live segment must begin at MBB entry or valno def", MBB);
1257 *OS << " in " << LI << '\n' << "Basic block starts at "
1258 << MBBStartIdx << '\n';
1261 const MachineBasicBlock *EndMBB =
1262 LiveInts->getMBBFromIndex(I->end.getPrevSlot());
1264 report("Bad end of live segment, no basic block", MF);
1266 *OS << " in " << LI << '\n';
1270 // No more checks for live-out segments.
1271 if (I->end == LiveInts->getMBBEndIdx(EndMBB))
1274 // The live segment is ending inside EndMBB
1275 const MachineInstr *MI =
1276 LiveInts->getInstructionFromIndex(I->end.getPrevSlot());
1278 report("Live segment doesn't end at a valid instruction", EndMBB);
1280 *OS << " in " << LI << '\n' << "Basic block starts at "
1281 << MBBStartIdx << '\n';
1285 // The block slot must refer to a basic block boundary.
1286 if (I->end.isBlock()) {
1287 report("Live segment ends at B slot of an instruction", MI);
1289 *OS << " in " << LI << '\n';
1292 if (I->end.isDead()) {
1293 // Segment ends on the dead slot.
1294 // That means there must be a dead def.
1295 if (!SlotIndex::isSameInstr(I->start, I->end)) {
1296 report("Live segment ending at dead slot spans instructions", MI);
1298 *OS << " in " << LI << '\n';
1302 // A live segment can only end at an early-clobber slot if it is being
1303 // redefined by an early-clobber def.
1304 if (I->end.isEarlyClobber()) {
1305 if (I+1 == E || (I+1)->start != I->end) {
1306 report("Live segment ending at early clobber slot must be "
1307 "redefined by an EC def in the same instruction", MI);
1309 *OS << " in " << LI << '\n';
1313 // The following checks only apply to virtual registers. Physreg liveness
1314 // is too weird to check.
1315 if (TargetRegisterInfo::isVirtualRegister(LI.reg)) {
1316 // A live range can end with either a redefinition, a kill flag on a
1317 // use, or a dead flag on a def.
1318 bool hasRead = false;
1319 bool hasDeadDef = false;
1320 for (ConstMIBundleOperands MOI(MI); MOI.isValid(); ++MOI) {
1321 if (!MOI->isReg() || MOI->getReg() != LI.reg)
1323 if (MOI->readsReg())
1325 if (MOI->isDef() && MOI->isDead())
1329 if (I->end.isDead()) {
1331 report("Instruction doesn't have a dead def operand", MI);
1333 *OS << " in " << LI << '\n';
1337 report("Instruction ending live range doesn't read the register",
1340 *OS << " in " << LI << '\n';
1345 // Now check all the basic blocks in this live segment.
1346 MachineFunction::const_iterator MFI = MBB;
1347 // Is this live range the beginning of a non-PHIDef VN?
1348 if (I->start == VNI->def && !VNI->isPHIDef()) {
1349 // Not live-in to any blocks.
1356 assert(LiveInts->isLiveInToMBB(LI, MFI));
1357 // We don't know how to track physregs into a landing pad.
1358 if (TargetRegisterInfo::isPhysicalRegister(LI.reg) &&
1359 MFI->isLandingPad()) {
1360 if (&*MFI == EndMBB)
1366 // Is VNI a PHI-def in the current block?
1367 bool IsPHI = VNI->isPHIDef() &&
1368 VNI->def == LiveInts->getMBBStartIdx(MFI);
1370 // Check that VNI is live-out of all predecessors.
1371 for (MachineBasicBlock::const_pred_iterator PI = MFI->pred_begin(),
1372 PE = MFI->pred_end(); PI != PE; ++PI) {
1373 SlotIndex PEnd = LiveInts->getMBBEndIdx(*PI);
1374 const VNInfo *PVNI = LI.getVNInfoBefore(PEnd);
1376 // All predecessors must have a live-out value.
1378 report("Register not marked live out of predecessor", *PI);
1379 *OS << "Valno #" << VNI->id << " live into BB#" << MFI->getNumber()
1380 << '@' << LiveInts->getMBBStartIdx(MFI) << ", not live before "
1381 << PEnd << " in " << LI << '\n';
1385 // Only PHI-defs can take different predecessor values.
1386 if (!IsPHI && PVNI != VNI) {
1387 report("Different value live out of predecessor", *PI);
1388 *OS << "Valno #" << PVNI->id << " live out of BB#"
1389 << (*PI)->getNumber() << '@' << PEnd
1390 << "\nValno #" << VNI->id << " live into BB#" << MFI->getNumber()
1391 << '@' << LiveInts->getMBBStartIdx(MFI) << " in "
1392 << PrintReg(Reg) << ": " << LI << '\n';
1395 if (&*MFI == EndMBB)
1401 // Check the LI only has one connected component.
1402 if (TargetRegisterInfo::isVirtualRegister(LI.reg)) {
1403 ConnectedVNInfoEqClasses ConEQ(*LiveInts);
1404 unsigned NumComp = ConEQ.Classify(&LI);
1406 report("Multiple connected components in live interval", MF);
1407 *OS << NumComp << " components in " << LI << '\n';
1408 for (unsigned comp = 0; comp != NumComp; ++comp) {
1409 *OS << comp << ": valnos";
1410 for (LiveInterval::const_vni_iterator I = LI.vni_begin(),
1411 E = LI.vni_end(); I!=E; ++I)
1412 if (comp == ConEQ.getEqClass(*I))
1413 *OS << ' ' << (*I)->id;