[llvm-py] Replace instructions

26 views
Skip to first unread message

Sebastian Muniz

unread,
May 24, 2010, 11:20:11 AM5/24/10
to llvm-py: Python Bindings for LLVM
Hello guys,

I have a question and may be you can help me. Is there a way to
replace an existing instruction in a function with another instruction
that takes care of the use-defs?

I found a couple of functions called ReplaceInstWithInst() and
ReplaceInstWithValue() in llvm/Transforms/Utils/BasicBlockUtils.h that
might do the trick. Here is the link to the programmers manual page:

http://llvm.org/docs/ProgrammersManual.html#schanges_replacing

Any ideas?

Thanks in advance.

~cheers, topo

Mahadevan R

unread,
May 24, 2010, 11:44:17 PM5/24/10
to llv...@googlegroups.com
Hi topo,

>   I have a question and may be you can help me. Is there a way to
> replace an existing instruction in a function with another instruction
> that takes care of the use-defs?

Use the C++ API: Value::replaceAllUsesWith(Value * replacement).
Instruction is-a Value.

For llvm-py you'll have to wrap it first ;-)

Regards,
-MD.
Reply all
Reply to author
Forward
0 new messages