[LLVMdev] ReplaceInstWithInst appears to invalidate BB iterator?

Duncan Sands
Sat, 07 May 2011 12:35:16 -0000

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.