[LLVMdev] Which pass converts call printf to puts?

Thomson lilotom at gmail.com
Mon Jun 18 04:47:52 PDT 2012


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?

Thanks,
-Thomson

On Mon, Jun 18, 2012 at 7:31 PM, Christoph Erhardt <christoph at sicherha.de>wrote:

> Hi Thomson,
>
> > Ok. So it seems CI->eraseFromParent() removed the old instruction and
> > the new one is inserted right after this one in the inner function in
> > the case of printf->puts. There is another line
> > CI->repalceAllUsesWith(Result). I think this line could also do the
> > replacement besides inserting the new one in the inner function.  What's
> > the difference of these 2 replacement methods?
> whenever an instruction is replaced, all other instructions that use its
> result (as an input operand) have to be told to use the result of the
> new instruction instead. That's what CI->replaceAllUsesWith(Result)
> does. Only then can the old instruction be removed from the basic block.
>
> Best regards,
> Christoph
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120618/f993ef47/attachment.html>


More information about the llvm-dev mailing list