<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 11/10/11 11:48 AM, Ryan Taylor wrote:
    <blockquote
cite="mid:CABgVvXu6aEUhD+1GrRnP1i0nksdG3En9HZ=mY+0L=gtU5fv3wg@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      John,<br>
      <br>
        Thanks, this does not compile though, I get this error:<br>
    </blockquote>
    <br>
    First, please CC the llvmdev list.  That way, others having the same
    question can see the conversation, and others on the list can help
    correct any errors I make.<br>
    :)<br>
    <br>
    <blockquote
cite="mid:CABgVvXu6aEUhD+1GrRnP1i0nksdG3En9HZ=mY+0L=gtU5fv3wg@mail.gmail.com"
      type="cite"><br>
      cdfg_pass.cpp:511:11: error: ‘class llvm::Function’ has no member
      named ‘getDeclaration’<br>
    </blockquote>
    <br>
    Sorry.  I believe the method name is Function::isDeclaration().<br>
    <br>
    BTW, you should double-check my answers (and other people's answers)
    against the LLVM doxygen documentation.  This is because:<br>
    <br>
    1) I often don't take the time to consult the documentation to
    ensure I have every detail correct.<br>
    2) The LLVM API is fluid, so some details of it may have changed
    since I last used a particular feature.<br>
    <br>
    <blockquote
cite="mid:CABgVvXu6aEUhD+1GrRnP1i0nksdG3En9HZ=mY+0L=gtU5fv3wg@mail.gmail.com"
      type="cite"><br>
      Also, when I try to pass the pointer to getAnalysis I get this
      error:<br>
      <br>
      cdfg_pass.cpp:512:41: error: no matching function for call to
      ‘<unnamed>::CDFGPass::getAnalysis(llvm::Function*&)’<br>
    </blockquote>
    <br>
    First, double check that it's a Function * and not a Function &
    that is required.<br>
    <br>
    Second, what type of pass is your pass?  Is it a ModulePass, a
    FunctionPass, or some other type of pass?  For a FunctionPass, no
    argument is necessary.  For a ModulePass, a Function argument is
    necessary.  For other types of passes, I do not know: you'll either
    have to wait for someone else to respond or just figure it out using
    trial and error.<br>
    <br>
    Third, are you including the header file that provides the
    definition of LoopInfo?  If not, that could be a problem.<br>
    <br>
    -- John T.<br>
    <br>
    <blockquote
cite="mid:CABgVvXu6aEUhD+1GrRnP1i0nksdG3En9HZ=mY+0L=gtU5fv3wg@mail.gmail.com"
      type="cite"><br>
      Here is the code I'm using:<br>
      <br>
              Function *F = CGNode->getFunction();<br>
              errs()<<"#Get Loop Info\n";<br>
              if (!(F->getDeclaration()))<br>
                      LoopInfo &LI = getAnalysis<LoopInfo>(F);<br>
      <br>
      <br>
      <div class="gmail_quote">On Thu, Nov 10, 2011 at 9:13 AM, John
        Criswell <span dir="ltr"><<a moz-do-not-send="true"
            href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex;">
          <div bgcolor="#FFFFFF" text="#000000">
            <div class="im"> On 11/10/11 11:06 AM, Ryan Taylor wrote:
              <blockquote type="cite"> LLVMers,<br>
                <br>
                   I am doing a CallGraphPass but would like to get the
                LoopInfo of the functions inside this pass, is this
                possible? Currently I have a function inside the
                CallGraph struct:<br>
                <br>
                    void getAnalysisUsage(AnalysisUsage &AU) const {<br>
                        AU.addRequired<LoopInfo>();<br>
                        AU.addPreserved<LoopInfo>();<br>
                    }<br>
                <br>
                And later inside the pass I am calling:<br>
                <br>
                LoopInfo &LI = getAnalysis<LoopInfo>();<br>
                <br>
                I have also tried to pass the Function pointer to
                getAnalysis but that doesn't work either. With the above
                code my error is:<br>
              </blockquote>
              <br>
            </div>
            1) You may need to pass a Function pointer or reference if
            your pass is not a FunctionPass (e.g., if it is a
            ModulePass).<br>
            <br>
            2) If you have to specify a Function pointer or reference,
            you need to make sure that the Function is *not* a
            declaration:<br>
            <br>
            if (!(F->getDeclaration()))<br>
                getAnalysis<LoopInfo>(F);<br>
            <br>
            -- John T.<br>
            <br>
            <blockquote type="cite">
              <div class="im"> <br>
                UNREACHABLE executed!<br>
                0  opt             0x00000000008edc2f<br>
                1  opt             0x00000000008edfda<br>
                2  libpthread.so.0 0x00007f9c8e69bc60<br>
                3  libc.so.6       0x00007f9c8d986d05 gsignal + 53<br>
                4  libc.so.6       0x00007f9c8d98aab6 abort + 390<br>
                5  opt             0x00000000008da974
                llvm::llvm_unreachable_internal(char const*, char
                const*, unsigned int) + 356<br>
                6  opt             0x000000000087e046<br>
                7  opt             0x0000000000882b45
                llvm::PMDataManager::add(llvm::Pass*, bool) + 741<br>
                8  opt             0x000000000087f413
                llvm::PassManager::add(llvm::Pass*) + 259<br>
                9  opt             0x00000000004ab9be main + 2174<br>
                10 libc.so.6       0x00007f9c8d971eff __libc_start_main
                + 255<br>
                11 opt             0x000000000049f5f9<br>
                Stack dump:<br>
                <br>
                <br>
                Any help would be appreciated, thanks!<br>
                <br>
                <br>
                <fieldset></fieldset>
                <br>
              </div>
              <pre>_______________________________________________
LLVM Developers mailing list
<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>
<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>
</pre>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </div>
      <br>
    </blockquote>
    <br>
  </body>
</html>