<div dir="ltr">Hi Yuxi, <div><br></div><div>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". <div><br></div><div>You may want to mimic <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_docs_doxygen_html_CloneFunction-5F8cpp-5Fsource.html-23l00077&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=lbxYzEhr_T-9IZWGs0H6u-jOYYnV3PSp-3T1_xwl_m4&s=NZknnqa1Gu0Mn4QwY3TlNfW2yCJ0EZjfdQjekNpSSs8&e=">llvm::CloneFunctionInto</a>. 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. </div><div><br></div><div>Jingyue</div><div><br><div class="gmail_quote"><div dir="ltr">On Sat, Jul 11, 2015 at 4:15 PM Yuxi Chen <<a href="mailto:chenyuxi@uchicago.edu">chenyuxi@uchicago.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hi,<br>
<br>
I want to copy some dependent statements, like a = b, b = c, from one basicblock to another basicblocks.<br>
Because of SSA, a = b, will be like %1 = load %b, store %1, %a. <br>
If I just use clone() method in Instruction class, it will be like <badref> = load %b, store <badref>, %a.
<br>
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.
<br>
<br>
Any suggestion will be appreciated. <br>
<br>
Best,<br>
Yuxi<br>
Uchicago<br>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div></div></div></div>