[LLVMdev] instructions copy

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


Hi Keutoi,

Thanks for your reply. I get your point. But the problem when you copy instuctions, you need to remap the virtual register. A naive way is to keep a map of old virtual registers and new virtual registers, then iterate all cloned instruction, replace the old virtual registers with new virtual registers. 

Thanks again. 
Yuxi
________________________________________
From: keutoi [k3ut0i at gmail.com]
Sent: Sunday, July 12, 2015 3:24 AM
To: Yuxi Chen
Subject: Re: [LLVMdev] instructions copy

I'm Just a beginner so i may be wrong.
Does Block Insert work?
Create a new block with your instructions with (new BasicBlock) and (new BranchInst) , split using SplitBlock and insert.
http://stackoverflow.com/questions/13275577/inserting-a-block-between-two-blocks-in-llvm

If it is possible to just add instructions, can someone please suggest
how this can be done.

It must be possible for inline function instructions.

Thank You.
On Sat, Jul 11, 2015 at 11:13:16PM +0000, Yuxi Chen 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         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


--
keutoi(k3ut0i)
pub fpr D04E 573D 360D 8209 3261  550E 39BE 6531 C533 FD20




More information about the llvm-dev mailing list