[LLVMdev] instructions copy
Yuxi Chen
chenyuxi at uchicago.edu
Sun Jul 12 17:21:49 PDT 2015
Hi John,
I really appreciate your reply. Right now, I write some programming like CloneBasicBlock(), it works.
Thanks,
Yuxi
________________________________
From: John Criswell [jtcriswel at gmail.com]
Sent: Sunday, July 12, 2015 11:59 AM
To: Yuxi Chen; llvmdev at cs.uiuc.edu
Cc: llvmdev-bounces at cs.uiuc.edu
Subject: Re: [LLVMdev] instructions copy
Dear Yuxi,
I haven't used the clone() method of the Instruction class, but if I had to guess, the problem is that you're not changing the operands of the new instructions to reference the new instructions. When you clone an instruction, the operands of the new instruction are identical to the operands of the old instruction.
In your example, if you clone the store, the store is still referencing %1 from the original LoadInst in the original basic block. You need to change the new store's operand to be the new LoadInst that you created in your new BasicBlock.
You may also want to look at the llvm::CloneBasicBlock() function. This utility function clones basic blocks; you can take a look at what it does and see how it works.
Regards,
John Criswell
On 7/11/15 6:13 PM, 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<mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
http://www.cs.rochester.edu/u/criswell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150713/f5733234/attachment.html>
More information about the llvm-dev
mailing list