Jianzhou Zhao
2010-Feb-28 19:11 UTC
[LLVMdev] How to check if an Instruction is still in a Function
Hi, Given an instruction ptr instr, and a Function ptr func, can I simply check if func == instr->get_parent()->get_parent() to see if this instruction is still in this Function? We can also look up this instruction in the blocks of this function. But this may take more time. Thanks. -- Jianzhou
Bill Wendling
2010-Mar-02 00:29 UTC
[LLVMdev] How to check if an Instruction is still in a Function
On Feb 28, 2010, at 11:11 AM, Jianzhou Zhao wrote:> Hi, > > Given an instruction ptr instr, and a Function ptr func, > can I simply check if func == instr->get_parent()->get_parent() to see if > this instruction is still in this Function? >Yup! -bw
Jianzhou Zhao
2010-Mar-02 00:55 UTC
[LLVMdev] How to check if an Instruction is still in a Function
On Mon, Mar 1, 2010 at 7:29 PM, Bill Wendling <wendling at apple.com> wrote:> On Feb 28, 2010, at 11:11 AM, Jianzhou Zhao wrote: > >> Hi, >> >> Given an instruction ptr instr, and a Function ptr func, >> can I simply check if func == instr->get_parent()->get_parent() to see if >> this instruction is still in this Function? >> > Yup!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'.> > -bw > >-- Jianzhou
Reasonably Related Threads
- [LLVMdev] How to check if an Instruction is still in a Function
- [LLVMdev] How to check if an Instruction is still in a Function
- [LLVMdev] Reviving the new LLVM concurrency model
- [LLVMdev] Tag number of OCaml Variant in executionengine
- [LLVMdev] Reviving the new LLVM concurrency model