Oh! I made a mistake by not using setDebugInfo() function present in the Instruction class. Now it's working fully.<br>So, the solution is:- <br>To set the line number for an instruction -<br>1. Add a function in DebugLoc class located in llvm/Support/DebugLoc.h. Set the line number there to the private variable called LineCol.<br>
2. Call the added function. And then pass the modified DebugLoc object to the seDebugInfo method for the instruction.<br><br clear="all">Abhirup Ghosh<br>M. Tech<br>Department of Computer Science & Engg.<br>IIT, Bombay<br>
email - <a href="mailto:abhirupju@gmail.com">abhirupju@gmail.com</a> , <a href="mailto:abhirup@cse.iitb.ac.in">abhirup@cse.iitb.ac.in</a><br>Contact - 9920735181 / 9434362120<br>
<br><br><div class="gmail_quote">On Fri, Mar 25, 2011 at 5:45 PM, Abhirup Ghosh <span dir="ltr"><<a href="mailto:abhirupju@gmail.com">abhirupju@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks for the help. <br>I thought I'd solved the problem (setting the line number information in the instruction metadata) by inserting my own function for setting line number in llvm/Support/DebugLoc.h. I have added  a function setLine(unsigned) in DebugLoc class. The function simply sets the LineCol variable as needed. But there is a problem.<br>

<br>Whenever I'm checking the line number(calling getLine()) from the function where I've called setLine(...) function, it returns the changed line number but whenever I call the getLine() function from other functions then it is returning the previous value not the changed. Is the change in the LineCol variable is not permanent or is this variable not at all linked with the debug information?<br>

<br>How can I set the line number information for the instructions?<div class="im"><br><br><br clear="all">Abhirup Ghosh<br>M. Tech<br>Department of Computer Science & Engg.<br>IIT, Bombay<br>email - <a href="mailto:abhirupju@gmail.com" target="_blank">abhirupju@gmail.com</a> , <a href="mailto:abhirup@cse.iitb.ac.in" target="_blank">abhirup@cse.iitb.ac.in</a><br>

Contact - 9920735181<br>
<br><br></div><div><div></div><div class="h5"><div class="gmail_quote">On Mon, Mar 14, 2011 at 1:45 PM, Frits van Bommel <span dir="ltr"><<a href="mailto:fvbommel@gmail.com" target="_blank">fvbommel@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>On Mon, Mar 14, 2011 at 8:56 AM, Abhirup Ghosh <<a href="mailto:abhirupju@gmail.com" target="_blank">abhirupju@gmail.com</a>> wrote:<br>
> Hi,<br>
>       I am new to LLVM infrastructure. Recently I am trying to set the debug<br>
> info for an instruction. The main aim is to set the source line number of an<br>
> instruction. Can anyone please show how to do that?<br>
>       I think  that setMetadata method in Instruction class is to be used.<br>
> But how do I create MDNode* consisting of desired source line number. Source<br>
> line number can be extracted from the instruction-debug-info using<br>
> getMetadata method and then using getLineNumber method from DILocation<br>
> class. Unfortunately DILocation class does not have any function like<br>
> setLinenumber.<br>
<br>
</div>You may want to check out Instruction::setDebugLoc().<br>
llvm/Support/DebugLoc.h and llvm/Analysis/DIBuilder.h will likely be<br>
helpful as well.<br>
</blockquote></div><br>
</div></div></blockquote></div><br>