Howto properly discard parentless instructions

Hi there,

i am currently working on a transformation pass where i replace some function calls. I use replaceAllUsesWith() to replace them.

After that i want to clean up like this:

delete callInst;

If the instruction is not deleted an error occurs when running the pass (parentless instruction). So is it okay to do it this way or is there a better way to do it?



Refer to [1], maybe you can try Instruction::eraseFromParent().