<font face="verdana,sans-serif">Could you give an example of the old instruction cannot be removed safely? Since the new instruction would produce the same context/result of the old one, I suppose it is safe to remove the old one when the new instruction is ready (inserted after the old one). Anything I missed here?</font><div>
<font face="verdana,sans-serif"><br></font></div><div><font face="verdana,sans-serif">Thanks,</font></div><div><font face="verdana,sans-serif">-Thomson<br></font><br><div class="gmail_quote">On Mon, Jun 18, 2012 at 7:31 PM, Christoph Erhardt <span dir="ltr"><<a href="mailto:christoph@sicherha.de" target="_blank">christoph@sicherha.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Thomson,<br>
<div class="im"><br>
> Ok. So it seems CI->eraseFromParent() removed the old instruction and<br>
> the new one is inserted right after this one in the inner function in<br>
> the case of printf->puts. There is another line<br>
> CI->repalceAllUsesWith(Result). I think this line could also do the<br>
> replacement besides inserting the new one in the inner function. What's<br>
> the difference of these 2 replacement methods?<br>
</div>whenever an instruction is replaced, all other instructions that use its<br>
result (as an input operand) have to be told to use the result of the<br>
new instruction instead. That's what CI->replaceAllUsesWith(Result)<br>
does. Only then can the old instruction be removed from the basic block.<br>
<br>
Best regards,<br>
Christoph<br>
</blockquote></div><br>
</div>