diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2015-04-30 19:35:41 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2015-04-30 19:35:41 +0000 |
commit | ee5c2ab73406f419014cb7a3667825fff5b16de8 (patch) | |
tree | edf9a8823d8b77d5c67b2b2f26bb43ce8c99a5bd /llvm/lib/CodeGen/MachineVerifier.cpp | |
parent | 4d8d2ec3ebf2334e8f16b4d702e3e6e6788c4a3e (diff) | |
download | llvm-ee5c2ab73406f419014cb7a3667825fff5b16de8.zip llvm-ee5c2ab73406f419014cb7a3667825fff5b16de8.tar.gz llvm-ee5c2ab73406f419014cb7a3667825fff5b16de8.tar.bz2 |
MachineVerifier: Don't crash if MachineOperand has no parent
If you somehow added a MachineOperand to an instruction
that did not have the parent set, the verifier would
crash since it attempts to use the operand's parent.
llvm-svn: 236249
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 991241e..47e8306 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -329,8 +329,18 @@ bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) { } else if (!CurBundle) report("No bundle header", MBBI); visitMachineInstrBefore(MBBI); - for (unsigned I = 0, E = MBBI->getNumOperands(); I != E; ++I) - visitMachineOperand(&MBBI->getOperand(I), I); + for (unsigned I = 0, E = MBBI->getNumOperands(); I != E; ++I) { + const MachineInstr &MI = *MBBI; + const MachineOperand &Op = MI.getOperand(I); + if (Op.getParent() != &MI) { + // Make sure to use correct addOperand / RmeoveOperand / ChangeTo + // functions when replacing operands of a MachineInstr. + report("Instruction has operand with wrong parent set", &MI); + } + + visitMachineOperand(&Op, I); + } + visitMachineInstrAfter(MBBI); // Was this the last bundled instruction? |