<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><div style="RIGHT: auto"><SPAN style="RIGHT: auto">Hi,</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">The link and the information shared was helpful.</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">I will make my problem definition more clear. </SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">While I am "asm printing" target code, I also want to emit scope related information. </SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">Scope related information includes, </SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">- for each scope, start line, end line, start column, end column</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">and </SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">- scope heirarchy. </SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">As scope is delimited by "{" and "}" (for an input C/C++ code), hence wanted to collect "endline" for scope. </SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">When I went through the ".ll" emitted by llc, i could find the "startline" in metadata. </SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">For this I could think of 2 approaches</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">1. Create a pass in llvm, to collect this information from the llvm instructions, by simply traversing them.</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"> Identifying line number for each instruction and checking on the lexical block it points to. Also would maintain the parent/child lexical block relation using metadata information.</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"> My "startline" is least line number associated with lexical block, and "endline" number is max line number associated with lexical block.</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">2. While "asm printing", traverse through the machine instruction and collect the information in similar way as 1. </SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">I am not sure whether I should collect it from Clang AST nodes. <VAR id=yui-ie-cursor></VAR></SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">Regards,</SPAN></div>
<div style="RIGHT: auto"><SPAN style="RIGHT: auto">Pankaj</SPAN></div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto"> </div>
<DIV style="FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif; FONT-SIZE: 10pt">
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><FONT size=2 face=Arial>
<DIV style="BORDER-BOTTOM: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; PADDING-BOTTOM: 0px; LINE-HEIGHT: 0; MARGIN: 5px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; HEIGHT: 0px; FONT-SIZE: 0px; BORDER-TOP: #ccc 1px solid; BORDER-RIGHT: #ccc 1px solid; PADDING-TOP: 0px" class=hr contentEditable=false readonly="true"></DIV><B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Devang Patel <dpatel@apple.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Pankaj Gode <godepankaj@yahoo.com><BR><B><SPAN style="FONT-WEIGHT: bold">Cc:</SPAN></B> "llvmdev@cs.uiuc.edu" <llvmdev@cs.uiuc.edu><BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Tuesday, October 4, 2011 10:08 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [LLVMdev] collect end line number for scope<BR></FONT><BR>
<DIV style="RIGHT: auto" id=yiv809494079>
<DIV style="RIGHT: auto">Pankaj,
<DIV style="RIGHT: auto"><BR style="RIGHT: auto">
<DIV style="RIGHT: auto">
<DIV style="RIGHT: auto">On Oct 3, 2011, at 4:36 AM, Pankaj Gode wrote:</DIV><BR class=yiv809494079Apple-interchange-newline>
<BLOCKQUOTE style="RIGHT: auto" type="cite">
<DIV style="RIGHT: auto">
<DIV style="BACKGROUND-COLOR: rgb(255,255,255); FONT-FAMILY: courier, monaco, monospace, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 10pt">
<DIV style="RIGHT: auto">Hi All,</DIV>
<DIV style="RIGHT: auto"> </DIV>
<DIV style="RIGHT: auto">int global;</DIV>
<DIV style="RIGHT: auto">int func( int t)</DIV>
<DIV style="RIGHT: auto">{ </DIV>
<DIV style="RIGHT: auto"> //scope 1</DIV>
<DIV style="RIGHT: auto"> {</DIV>
<DIV style="RIGHT: auto"> ....</DIV>
<DIV> } <-----</DIV>
<DIV style="RIGHT: auto"> return x;</DIV>
<DIV style="RIGHT: auto">} <VAR id=yiv809494079yui-ie-cursor></VAR></DIV>
<DIV style="RIGHT: auto"> </DIV>
<DIV style="RIGHT: auto">For the above code, i want to collect endline (indicated by <---) for the scope. Can we get this information from the Dwarf Information in llvm 2.9 ? </DIV>
<DIV> </DIV></DIV></DIV></BLOCKQUOTE></DIV><BR>
<DIV style="RIGHT: auto">If there is no code generated for a source line with just "}", so you are not going to get that line number in debug info (because there is not any llvm instruction). You can access the line number for the last statement/expression in the scope. See http://llvm.org/docs/SourceLevelDebugging.html#ccxx_compile_units for a code snippet on how to get line number from an llvm instruction.</DIV>
<DIV style="RIGHT: auto"><BR style="RIGHT: auto"></DIV>
<DIV style="RIGHT: auto">What exactly are you trying to do? Depending on your needs, you may be able to access clang AST nodes to get exact line and column number information for "}" irrespective of debug info.</DIV>
<DIV style="RIGHT: auto"><BR style="RIGHT: auto"></DIV>
<DIV style="RIGHT: auto">-</DIV>
<DIV style="RIGHT: auto">Devang</DIV></DIV></DIV></DIV><BR><BR></DIV></DIV></div></body></html>