Just to be clear, I have to add a function name printf in the module with no body. And I can call the function. This will automatically call the printf function which is defined in the library.<br><br>Tarun Agrawal<br><br>

<div class="gmail_quote">On Wed, Feb 8, 2012 at 11:34 PM, John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div class="im">
    On 2/8/12 11:55 AM, tarun agrawal wrote:
    <blockquote type="cite">
      
      Hi,<br>
      <br>
      I am trying to insert a instruction for printf or cout. My aim is
      to print a integer and a string value using that instruction,
      which are already there in the code. <br>
      but I am not able to understand how to do it. Any help would be
      great help.<br>
    </blockquote>
    <br></div>
    You want to insert a call instruction that calls the printf
    function.  You'll need to insert a Function for printf (with no
    body) if no printf function exists within the LLVM module you're
    transforming.<br>
    <br>
    So, the code will look something like:<br>
    <br>
    Function * F = M.getOrInsertFunction ("printf", ...);<br>
    CallInst::Create (F, ...);<br>
    <br>
    Be sure to look at the doxygen docs for exact method names and which
    parameters go where; I've skipped over such details above.<br>
    <br>
    -- John T.<br>
    <br>
    <blockquote type="cite"><div class="im">
      <br>
      <br>
      <br>
      Thanks and Regards,<br>
      Tarun Agrawal<br>
      <br>
      <fieldset></fieldset>
      <br>
      </div><pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
    </blockquote>
    <br>
  </div>

</blockquote></div><br>