[LLVMdev] how to change one operand of an LLVM instruction
lattner at apple.com
Tue Sep 8 14:57:44 PDT 2009
On Sep 8, 2009, at 2:46 PM, Susan Horwitz wrote:
> I am trying to implement node splitting to transform irreducible
> CFGS to
> reducible ones. This means making copies of some basic blocks,
> which in
> turn means making copies of individual instructions. I can use the
> "clone" function to make an exact copy, but then I need to change some
> operands. For example, when I copy
> %1 = ...
> %2 = add %1, 5
> I get
> %3 = ...
> %4 = add %1, 5
> and I need to change the %1 operand in the copy to be %3.
> The only way I see to do this is to create a new instruction instead
> of a
> clone, using a big switch on the opcode (since different instructions'
> constructors have different parameters).
> Anyone know of an easier way to do this?
Are you using CloneBasicBlock? If so, you should pass it a ValueMap.
You can then iterate over the instructions in the new basicblock and
update the instruction operand references.
Check out CloneFunction.cpp for some examples.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev