Removing Instructions

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:

removeFromParent() doesn't delete the instruction, it just removes it
from the basic block. This is useful if you want to re-insert it
somewhere else.
However, I think what you're looking for is eraseFromParent(), which
actually deletes the instruction after removing it from its parent.
This also takes care of removing it from the use lists of all of its
operands.