<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi Jingyue,
<br>
<br>
Thanks for your reply. Yep, I just mimic some programming like llvm::CloneFUnctionInto. It works.
<br>
<br>
Best,<br>
Yuxi<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF244614"><font face="Tahoma" size="2" color="#000000"><b>From:</b> Jingyue Wu [jingyue@google.com]<br>
<b>Sent:</b> Sunday, July 12, 2015 11:55 AM<br>
<b>To:</b> Yuxi Chen<br>
<b>Cc:</b> LLVM Developers Mailing List<br>
<b>Subject:</b> Re: [LLVMdev] instructions copy<br>
</font><br>
</div>
<div></div>
<div>
<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=AwMFAw&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=GNOVQ7_-tkVZnF-ku1AlieEbpKOcTtW20m8aaqeyCZ0&s=fykochE161vjiup5mfARYIaMSKx4fFfEc-mKs0WPi7k&e=" target="_blank">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" target="_blank">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>
</div>
</div>
</div>
</body>
</html>