Verify that machine instruction parent pointers are consistent.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 12 Jan 2011 21:27:41 +0000 (21:27 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 12 Jan 2011 21:27:41 +0000 (21:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123322 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineVerifier.cpp

index 83c980d51f0de0b06f5d6178f24fd11a2abc184d..cceb4b6b7309575597b8034cf63579ed71280b13 100644 (file)
@@ -273,6 +273,11 @@ bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) {
     visitMachineBasicBlockBefore(MFI);
     for (MachineBasicBlock::const_iterator MBBI = MFI->begin(),
            MBBE = MFI->end(); MBBI != MBBE; ++MBBI) {
+      if (MBBI->getParent() != MFI) {
+        report("Bad instruction parent pointer", MFI);
+        *OS << "Instruction: " << *MBBI;
+        continue;
+      }
       visitMachineInstrBefore(MBBI);
       for (unsigned I = 0, E = MBBI->getNumOperands(); I != E; ++I)
         visitMachineOperand(&MBBI->getOperand(I), I);