<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hi,</p>
<p><br>
</p>
<p>I have been trying to move some instructions between basic blocks , </p>
<p><br>
</p>
<p>After looking at the API , I found<i> llvm::Instruction::clone() </i> but there </p>
<p>is no result value for this.</p>
<p><br>
</p>
<p><br>
</p>
<p>For example- </p>
<p><br>
</p>
<p><u><b>source Basic block :</b></u></p>
<p><br>
</p>
<p></p>
<div>continuation: ; preds = %else, %then</div>
<div> %iftmp = phi i32 [ 5, %then ], [ 9, %else ]</div>
<div> store i32 %iftmp, i32* %datasize</div>
<div><br>
</div>
<div><b style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"> <span style="color: rgb(255, 0, 0);">; 3 instructions below
being copied</span></b><br>
</div>
<div> <b> store i8000000 0, i8000000* %res <span style="color: rgb(255, 0, 0);"></span></b></div>
<div><b> %res4 = load i8000000, i8000000* %res</b></div>
<div><b> ret i8000000 %res4</b></div>
<div><br>
</div>
<div><br>
</div>
<div>After copying the 3 instructions above to destination basic block.</div>
<div><br>
</div>
<u><b>destination basic block :</b></u>
<p></p>
<p><br>
</p>
<p></p>
<div>else: ; preds = %entry</div>
<div> store i8000000 0, i8000000* %res</div>
<div><b> <span style="color: rgb(255, 0, 0);"> %1---->issue</span></b> = load i8000000, i8000000* %res</div>
<div> ret i8000000 <b><span style="color: rgb(255, 0, 0);">%res4 -----> issue , need to get result of instruction above. </span></b></div>
<div> br label %continuation</div>
<div><br>
</div>
<br>
<p></p>
<p><br>
</p>
<p><br>
</p>
<p>I had tried using a simple Instruction::insert() earlier but ran </p>
<p>into an assertion error complaining that the Function contained duplicated instruction.</p>
<p><br>
</p>
<p><u><b>My Question</b></u> : How to copy an instruction ( along with it's name , or the LHS of the instruction ) </p>
<p>Is it possible to do name the LHS of the instruction using clone() ?</p>
<p><br>
</p>
<p>Thanks,</p>
<p>Malhar</p>
<p><br>
</p>
</div>
</body>
</html>