[llvm] r221953 - CodeGen: assert an instruction is being inserted with the correct iterator.
Tim Northover
tnorthover at apple.com
Thu Nov 13 16:35:00 PST 2014
Author: tnorthover
Date: Thu Nov 13 18:34:59 2014
New Revision: 221953
URL: http://llvm.org/viewvc/llvm-project?rev=221953&view=rev
Log:
CodeGen: assert an instruction is being inserted with the correct iterator.
When "MBB->Insert(It, ...)" is called, we want It to be pointing inside the
correct basic block. No actual failures at the moment, but it's caused problems
before.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=221953&r1=221952&r2=221953&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Thu Nov 13 18:34:59 2014
@@ -486,11 +486,15 @@ public:
/// Insert a range of instructions into the instruction list before I.
template<typename IT>
void insert(iterator I, IT S, IT E) {
+ assert((I == end() || I->getParent() == this) &&
+ "iterator points outside of basic block");
Insts.insert(I.getInstrIterator(), S, E);
}
/// Insert MI into the instruction list before I.
iterator insert(iterator I, MachineInstr *MI) {
+ assert((I == end() || I->getParent() == this) &&
+ "iterator points outside of basic block");
assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
"Cannot insert instruction with bundle flags");
return Insts.insert(I.getInstrIterator(), MI);
@@ -498,6 +502,8 @@ public:
/// Insert MI into the instruction list after I.
iterator insertAfter(iterator I, MachineInstr *MI) {
+ assert((I == end() || I->getParent() == this) &&
+ "iterator points outside of basic block");
assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
"Cannot insert instruction with bundle flags");
return Insts.insertAfter(I.getInstrIterator(), MI);
More information about the llvm-commits
mailing list