[LLVMdev] How to check if an Instruction is still in a Function

Duncan Sands baldrick at free.fr
Tue Mar 2 00:56:50 PST 2010


Hi Jianzhou,

> Well. I just found that this is not quite safe sometimes.
> After an instruction is removed via 'eraseFromParent',
> the instruction will be deleted, and become 'dangling'.
> LLVM does not set this removed instruction as NULL.
> In this case, instr->get_parent()->get_parent() gives
> me 'seq fault'.

you should not access an instruction after it has been deleted.  This is
sometimes quite problematic, so LLVM has a callback infrastructure that
you can use to be informed when your instruction is deleted.  Take a look
at llvm/Support/ValueHandle.h

Best wishes,

Duncan.



More information about the llvm-dev mailing list