<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Dear Yuxi,<br>
<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
On 7/11/15 6:13 PM, Yuxi Chen wrote:<br>
</div>
<blockquote
cite="mid:83E2887150EB424E8D7877B912AE1FF128B12E9E@xm-mbx-07-prod.ad.uchicago.edu"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
<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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="moz-txt-link-freetext" href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cs.rochester.edu_u_criswell&d=AwMD-g&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=4B1uRLADI_tSHpM7OQcIGltGUh5AKTdNZaOJb34RI3I&s=HdDjZm2cOUXHtKckMRHrmI0Spd3IBt5eC-9r73tqH0s&e=">http://www.cs.rochester.edu/u/criswell</a></pre>
</body>
</html>