<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">With ToT clang I get output that looks something like this:<div><br></div><div><div>0x00000051:     TAG_subprogram [2] *</div><div>                 AT_sibling( {0x000000be} )</div><div>                 AT_name( "func" )</div><div>                 AT_decl_file( "/Users/echristo/bar.c" )</div><div>                 AT_decl_line( 2 )</div><div>                 AT_prototyped( 0x01 )</div><div>                 AT_type( {0x000000be} ( int ) )</div><div>                 AT_external( 0x01 )</div><div>                 AT_low_pc( 0x0000000000000000 )</div><div>                 AT_high_pc( 0x0000000000000017 )</div><div>                 AT_frame_base( rbp )</div><div><br></div><div>0x00000075:         TAG_formal_parameter [3]  </div><div>                     AT_name( "t" )</div><div>                     AT_decl_file( "/Users/echristo/bar.c" )</div><div>                     AT_decl_line( 1 )</div><div>                     AT_type( {0x000000be} ( int ) )</div><div>                     AT_location( fbreg -4 )</div><div><br></div><div>0x00000081:         TAG_lexical_block [4] *</div><div>                     AT_low_pc( 0x0000000000000007 )</div><div>                     AT_high_pc( 0x0000000000000017 )</div><div><br></div><div>0x00000092:             TAG_variable [5]  </div><div>                         AT_name( "x" )</div><div>                         AT_decl_file( "/Users/echristo/bar.c" )</div><div>                         AT_decl_line( 3 )</div><div>                         AT_type( {0x000000be} ( int ) )</div><div>                         AT_location( fbreg -8 )</div><div><br></div><div>0x0000009e:             TAG_lexical_block [4] *</div><div>                         AT_low_pc( 0x0000000000000007 )</div><div>                         AT_high_pc( 0x0000000000000012 )</div><div><br></div><div>0x000000af:                 TAG_variable [5]  </div><div>                             AT_name( "a" )</div><div>                             AT_decl_file( "/Users/echristo/bar.c" )</div><div>                             AT_decl_line( 6 )</div><div>                             AT_type( {0x000000be} ( int ) )</div><div>                             AT_location( fbreg -12 )</div><div><br></div><div>using your test case from below slightly modified to make sure that a was actually used.</div><div><br></div><div>Which appears to be exactly what you were looking for? And yes, it matches the dbg.declare instruction.</div><div><br></div><div>-eric</div><div><br></div><div><div>On Oct 13, 2011, at 1:43 AM, Pankaj Gode wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><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"><br style="RIGHT: auto" class="yui-cursor"></span></div>
<div style="RIGHT: auto">Hi,</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">I want to list some additional information on this.</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">The variable collection I am looking at is, "variables 'declared' in scope".</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">1. When I traverse the MachineInstructions in the LexicalScopes ranges, and check for variables, I get variables used in this scope.   </div>
<div style="RIGHT: auto">   The variables listed include variables which may not have been declared in the scope. (for example "int t", which is not declared in scope1, is listed.)</div>
<div style="RIGHT: auto">   I do this by checking if the instruction uses memoperands then I collect name of value.</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">So, for the example below</div>
<div style="RIGHT: auto">int func( int t)</div>
<div style="RIGHT: auto">{  </div>
<div style="RIGHT: auto">  int x;</div>
<div style="RIGHT: auto">  //scope 1</div>
<div style="RIGHT: auto">  { </div>
<div style="RIGHT: auto">     int a;</div>
<div style="RIGHT: auto">     ....</div>
<div style="RIGHT: auto">  } </div>
<div style="RIGHT: auto">  return x;</div>
<div style="RIGHT: auto">} <var id="yiv2040551241yui-ie-cursor"></var></div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">what I am expecting is as below:</div>
<div style="RIGHT: auto"><scope name>: <list of variables declared in scope></div>
<div style="RIGHT: auto">func scope: t, x</div>
<div style="RIGHT: auto">scope 1: a</div>
<div style="RIGHT: auto">   </div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">2. I checked the "CodeGen/AsmPrinter/DwarfDebug.cpp" as reference, to find mapping of "MachineInstruction" to "llvm.dbg.declare", to extract variables declared in scope.</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">I am not sure whether there is any other way to get to variables declared in scope. </div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">Regards,</div>
<div style="RIGHT: auto">Pankaj</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">
<div style="RIGHT: auto" id="yiv2040551241">
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">
<div style="RIGHT: auto">
<div style="RIGHT: auto">On Oct 12, 2011, at 3:14 AM, Pankaj Gode wrote:</div><br class="yiv2040551241Apple-interchange-newline">
<blockquote style="RIGHT: auto" type="cite">
<div style="RIGHT: auto">
<div style="BACKGROUND-COLOR: #fff; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif; COLOR: #000; FONT-SIZE: 10pt">
<div style="RIGHT: auto"><var id="yui-ie-cursor"></var>Hi all,</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">Using "CodeGen/LexicalScopes" pass, I could collect scope information i.e. start and end line numbers.</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">I also want to collect information of variables within the scope. </div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">For the below example:</div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto">int global;</div>
<div style="RIGHT: auto">int func( int t)</div>
<div>{  </div>
<div>  //scope 1</div>
<div style="RIGHT: auto">  { </div>
<div>     int a;</div>
<div>     ....</div>
<div style="RIGHT: auto">  } </div>
<div>  return x;</div>
<div>} <var id="yiv2040551241yui-ie-cursor"></var></div>
<div style="RIGHT: auto"> </div>
<div><var id="yiv2040551241yui-ie-cursor"></var>For "scope 1", I should be able to collect that "a" is a local variable in scope1 and should also be able to identify whether "a" is static or non-static.</div>
<div style="RIGHT: auto"> </div>
<div>Regards,<br>Pankaj</div></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" rel="nofollow" target="_blank" ymailto="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></div><br><br></div></div></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></body></html>