[LLVMdev] IR code modification/transformation

James Molloy james.molloy at arm.com
Thu Aug 11 03:28:12 PDT 2011


Hi,

So it sounds like you need to replace the ADD instruction with a SUB, right?

Look at replaceAllUsesWith(), that should do what you want.

James

> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of Rinaldini Julien
> Sent: 11 August 2011 11:12
> To: llvmdev at cs.uiuc.edu
> Subject: [LLVMdev] IR code modification/transformation
> 
> Hi,
> 
> I have a question about the llvm passes.
> 
> I'm iterating over a basicblock and I can get an instruction and print
> it.
> Now, I want to iterate over the instruction and be able to modify the
> values of the instruction.
> 
> For example, if my instruction is an add "<result> = add i32 4, %var" I
> want to transform it in a sub "<result> = sub i32 4, %var".
> 
> I looked up on getOperands() and getAllMetadata() and some others
> methods, but none work.
> 
> Can you help me with that please?
> 
> Thx
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev








More information about the llvm-dev mailing list