[LLVMdev] Removing Instructions

Michael Kiperberg mkiperberg at gmail.com
Sat Feb 26 11:48:23 PST 2011


I try to write a pass that clones a function and then removes some instruction from the clone, the clone is then added to the module (the parent of the source function).
I call removeFromParent() on the appropriate instruction and it is actually removed (I see it in module's dump). However I get a failed assertion at Module Verifier which says:
---
Instruction referencing instruction not embedded in a basic block!
<existing instruction>
<removed instruction>
---
The problem is, the existing instruction holds a reference to the removed instruction in its UseList, i.e. the removed instruction needs the result if the existing instruction (so the removal is legal).
Should I go over all the UseList`s and remove the reference?

Thanks,
Michael.



More information about the llvm-dev mailing list