[LLVMdev] instructions copy (original) (raw)

Jingyue Wu jingyue at google.com
Sun Jul 12 09:55:56 PDT 2015


Hi Yuxi,

Yes, you need to remap virtual registers. In your example, the clone of "store %1, %a" still uses the old %1 right after cloning, so you need to set the first operand to the clone of "load %b".

You may want to mimic llvm::CloneFunctionInto <http://llvm.org/docs/doxygen/html/CloneFunction_8cpp_source.html#l00077>. In particular, CloneBasicBlock clones instructions in a basic block and creates a mapping from original to cloned. Then, RemapInstruction applies the mapping to the operands of the cloned instructions.

Jingyue

On Sat, Jul 11, 2015 at 4:15 PM Yuxi Chen <chenyuxi at uchicago.edu> wrote:

Hi,

I want to copy some dependent statements, like a = b, b = c, from one basicblock to another basicblocks. Because of SSA, a = b, will be like %1 = load %b, store %1, %a. If I just use clone() method in Instruction class, it will be like = load %b, store , %a. If I need remap the virtual registers, this map just will affect the whole module? And how to use it? I am a bit confused. Any suggestion will be appreciated. Best, Yuxi Uchicago


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/20150712/c98a8062/attachment.html>



More information about the llvm-dev mailing list