<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><font face="Courier New, Courier, monospace">As far as I can
        tell, the web page only has an example saying </font></p>
    <p></p>
    <pre><font face="Courier New, Courier, monospace">;;
;; Define the anchor for subprograms.
;;
!6 = metadata !{
  ...</font></pre>
    <pre><font face="Courier New, Courier, monospace">  null,              ;; List of function variables (emitted when optimizing)
  1                  ;; Line number of the opening '{' of the function
}</font></pre>
    <pre>
</pre>
    <p><font face="Courier New, Courier, monospace">I didn't fully get
        what that meant when reading it for the first time and thought
        that I should use it with an optimization pass. I understand </font><font
        face="Courier New, Courier, monospace"><font face="Courier New,
          Courier, monospace">now</font> why it says that. It's not very
        instrumental in terms of how to use it, but it makes sense after
        I understand it.<br>
        <br>
      </font></p>
    <p><font face="Courier New, Courier, monospace">Thanks,<br>
        Lu<br>
      </font></p>
    <pre>
</pre>
    <div class="moz-cite-prefix">On 11/03/2013 02:58 PM, David Blaikie
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAENS6EvAoNUHd+bJ6Lc+iNs-swiQimkANRPe8z=iTWED+=4=Gw@mail.gmail.com"
      type="cite">
      <p dir="ltr">+llvmdev because I accidentally dropped it</p>
      <div class="gmail_quote">On Nov 3, 2013 6:57 AM, "David Blaikie"
        <<a moz-do-not-send="true" href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>>

        wrote:<br type="attribution">
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <p dir="ltr">You're welcome to provide a patch or I might get
            to it myself. Also this should be described in <a
              moz-do-not-send="true"
              href="http://llvm.org/docs/SourceLevelDebugging.html"
              target="_blank">http://llvm.org/docs/SourceLevelDebugging.html</a>
            if it isn't already</p>
          <div class="gmail_quote">On Nov 3, 2013 12:11 AM, "lu zhao"
            <<a moz-do-not-send="true"
              href="mailto:luzhao@cs.utah.edu" target="_blank">luzhao@cs.utah.edu</a>>

            wrote:<br type="attribution">
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text="#000000" bgcolor="#FFFFFF"> Hi David,<br>
                <br>
                Thank you! Your suggested method works.<br>
                <br>
                I think that you or someone should write what you said
                in the comments for the getVariable() function. :)<br>
                <br>
                Best,<br>
                Lu<br>
                <br>
                <div>On 11/03/2013 06:30 AM, David Blaikie wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr"><br>
                    <div class="gmail_extra"><br>
                      <br>
                      <div class="gmail_quote">On Sat, Nov 2, 2013 at
                        4:17 PM, lu zhao <span dir="ltr"><<a
                            moz-do-not-send="true"
                            href="mailto:luzhao@cs.utah.edu"
                            target="_blank">luzhao@cs.utah.edu</a>></span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div text="#000000" bgcolor="#FFFFFF"> <font
                              face="Courier New, Courier, monospace">Hi,<br>
                              <br>
                              If I have an instance of DISubprogram, can
                              I get the debug info of local variables of
                              the function, including parameters?<br>
                              <br>
                              I tried to use the getVariables() function
                              defined in DISubprogram, but it seemed to
                              return an empty DIArray node when I ran my
                              pass alone using opt. Do I need to enable
                              any other analysis passes in order to
                              populate the data?<br>
                              <br>
                              My related snippet of code is like the
                              following:<br>
                              <br>
                                  NamedMDNode *M_Nodes =
                              M.getNamedMetadata("<a
                                moz-do-not-send="true"
                                href="http://llvm.dbg.cu"
                                target="_blank">llvm.dbg.cu</a>");<br>
                                  for (unsigned i = 0, e =
                              M_Nodes->getNumOperands(); i != e; ++i)
                              {<br>
                                    DIArray SPs = CU.getSubprograms();<br>
                                    for (unsigned i = 0, e =
                              SPs.getNumElements(); i != e; ++ i) {<br>
                                      DISubprogram
                              SP(SPs.getElement(i));<br>
                                      DIArray Vars = SP.getVariables();<br>
                                      for (unsigned i2 = 0, e2 =
                              Vars.getNumElements(); i2 != e2; ++i2) {<br>
                                        DIVariable
                              DV(Vars.getElement(i));<br>
                                        DV.print(errs()); errs()
                              << " : "; DV.getType().dump();<br>
                                      }<br>
                                    }<br>
                                  }<br>
                              <br>
                              In addition, can I use DebegInfo to get
                              the list of parameters (var names and
                              types) of a subprogram? or I have to parse
                              the underlying metadata and build the
                              relationship?<br>
                            </font></div>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>Basically this /\. We use the variables
                          list (the getVariables function you mentioned)
                          to persist the variables in optimized (above
                          -O0) builds, but at -O0 we save metadata space
                          by not emitting the list and relying on the
                          dbg_value/declare intrinsics to keep the
                          variable metadata alive and the variables to
                          refer to their scope (lexical blocks (that
                          refer to subprograms) or subprograms).<br>
                          <br>
                          So you'd have to walk all the instructions
                          looking for dbg_declare/value (I forget which,
                          perhaps both) and trace those back to the
                          DIVariables, etc... </div>
                        <div> </div>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div text="#000000" bgcolor="#FFFFFF"><font
                              face="Courier New, Courier, monospace"> <br>
                              Thanks,<br>
                              Lu<br>
                              <br>
                            </font> </div>
                          <br>
_______________________________________________<br>
                          LLVM Developers mailing list<br>
                          <a moz-do-not-send="true"
                            href="mailto:LLVMdev@cs.uiuc.edu"
                            target="_blank">LLVMdev@cs.uiuc.edu</a>    
                              <a moz-do-not-send="true"
                            href="http://llvm.cs.uiuc.edu"
                            target="_blank">http://llvm.cs.uiuc.edu</a><br>
                          <a moz-do-not-send="true"
                            href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev"
                            target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
                          <br>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                  </div>
                </blockquote>
                <br>
              </div>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>