[PATCH] MachineVerifier: Don't crash if MachineOperand has no parent
Matt Arsenault
Matthew.Arsenault at amd.com
Wed Apr 29 15:16:33 PDT 2015
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.
http://reviews.llvm.org/D9355
Files:
lib/CodeGen/MachineVerifier.cpp
Index: lib/CodeGen/MachineVerifier.cpp
===================================================================
--- lib/CodeGen/MachineVerifier.cpp
+++ lib/CodeGen/MachineVerifier.cpp
@@ -329,8 +329,15 @@
} 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)
+ report("Instruction has operand with wrong parent set", &MI);
+
+ visitMachineOperand(&Op, I);
+ }
+
visitMachineInstrAfter(MBBI);
// Was this the last bundled instruction?
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9355.24661.patch
Type: text/x-patch
Size: 853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150429/a5b538aa/attachment.bin>
More information about the llvm-commits
mailing list