[LLVMdev] Question About inserting Instruction?
Vladimir Prus
ghost at cs.msu.su
Wed May 11 03:41:55 PDT 2005
On Wednesday 11 May 2005 14:21, Qiuyu Zhang wrote:
> I am working on a project with LLVM. What I need to do is to
> generate/insert some dummy/dead basic blocls which never have chance to be
> executed and put some instructions in those dummy/dead basic blocks.
>
> So far, the dummy/dead BB insertion is done. I am trying insert
> instructions in those dummy/dead BB. Actually, I can insert the legal
> instructions to dummy/dead BB, however, I really want to insert some
> illegal instructions/any thing into those BB since those instructions have
> no chance to be executed. I am not sure if it could be done or not.
>
> For example,
> Correct way:
> Instruction *NewInst = new LoadInst(...);
> NewBB->getInstList().push_back(NewInst);
>
> what I need just put some junk data in the BB, not instructions. From
> assemble code level, it looks like the following,
.....
> what I tried is to make *NewInst point to random memory(cast to
> Instuction pointer) and push_back to instList. But I failed to do it.
>
> Instruction *NewInst = ;
> NewBB->getInstList().push_back(NewInst);
>
> So I was wondering if it is allowed in LLVM or not, if so, how to do that?
>
> Let me know if my question is not clear.
Actually, it's not clear. Why do you want to put bogus Instruction* pointers
into basic blocks? If you are not going to ever use those instructions, you
can create/insert instances of UnreachableInst, or any other instruction you
like.
If you do want to use the inserted instructions in any way, then inserting
bogus Instruction* pointers would just crash your application.
- Volodya
>
> Thanks
> Qiuyu
More information about the llvm-dev
mailing list