[llvm] r236249 - MachineVerifier: Don't crash if MachineOperand has no parent
Quentin Colombet
qcolombet at apple.com
Thu Apr 30 13:29:38 PDT 2015
> On Apr 30, 2015, at 12:35 PM, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:
>
> Author: arsenm
> Date: Thu Apr 30 14:35:41 2015
> New Revision: 236249
>
> URL: http://llvm.org/viewvc/llvm-project?rev=236249&view=rev
> Log:
> 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.
>
> Modified:
> llvm/trunk/lib/CodeGen/MachineVerifier.cpp
>
> Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=236249&r1=236248&r2=236249&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Thu Apr 30 14:35:41 2015
> @@ -329,8 +329,18 @@ bool MachineVerifier::runOnMachineFuncti
> } 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
Typo: Remove
> + // 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?
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list