[LLVMdev] instructions copy

Yuxi Chen chenyuxi at uchicago.edu
Sun Jul 12 17:20:26 PDT 2015


Hi Jingyue,

Thanks for your reply. Yep, I just mimic some programming like llvm::CloneFUnctionInto. It works.

Best,
Yuxi
________________________________
From: Jingyue Wu [jingyue at google.com]
Sent: Sunday, July 12, 2015 11:55 AM
To: Yuxi Chen
Cc: LLVM Developers Mailing List
Subject: Re: [LLVMdev] instructions copy

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<mailto: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 <badref> = load %b, store <badref>, %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<mailto: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/20150713/d2638891/attachment.html>


More information about the llvm-dev mailing list