[LLVMdev] Instruction Insertion

John Criswell criswell at cs.uiuc.edu
Thu Aug 11 08:22:01 PDT 2011


On 8/11/11 5:06 AM, Grégory Ruch wrote:
> Hi everybody,
>
> I'm trying to implement a LLVM Pass that insert instructions into a 
> basicblock.
>
> I'm using a FunctionPass and I want to add somthing like this :
>
> %tmp = alloca i32, align 4
> %tmp2 = alloca i32, align 4
>
> store i32 10, i32* %tmp
> store i32 2, i32* %tmp2
>
> %tmp3 = add i32 %tmp, %tmp2
>
> I try to follow the official tuto, I think this part is out of date. 
> http://llvm.org/docs/ProgrammersManual.html#simplechanges
> I'm using IRBuilder to create an alloc instruction but I can not for now.

First, there are two ways to insert instructions:

1) Use the IRBuilder class to create instructions.
2) Use the LLVM internal API directly and use a method of the AllocaInst 
class.

Either way, you should read the LLVM doxygen documentation of the class 
you want to use to get the latest API for it.  So, in this case, either 
read the doxygen documentation on IRBuilder or the documentation on 
AllocaInst.

Doxygen docs are at http://llvm.org/doxygen/hierarchy.html.

-- John T.

>
> Someone could help me to get started ?
>
> Thanks !
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110811/74c1aa12/attachment.html>


More information about the llvm-dev mailing list