Justin M. LaPre
2011-May-06 23:30 UTC
[LLVMdev] ReplaceInstWithInst appears to invalidate BB iterator?
Hello, I have a call to ReplaceInstWithInst(Instruction *From, Instruction *To) inside of a for loop iterating through a BasicBlock::iterator. On the very next pass after I replace the instruction, the iterator appears to be invalidated. Is this supposed to happen or am I doing something silly? Is there a more appropriate way to do this? Thanks, -Justin
Duncan Sands
2011-May-07 12:35 UTC
[LLVMdev] ReplaceInstWithInst appears to invalidate BB iterator?
Hi Justin,> I have a call to ReplaceInstWithInst(Instruction *From, Instruction *To) inside of a for loop iterating through a BasicBlock::iterator. On the very next pass after I replace the instruction, the iterator appears to be invalidated. Is this supposed to happen or am I doing something silly? Is there a more appropriate way to do this? Thanks,since ReplaceInstWithInst deletes (i.e. frees) the instruction "From", any iterators referring to From will be invalidated. Ciao, Duncan.