<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Ryan Taylor</b> <span dir="ltr"><<a href="mailto:ryta1203@gmail.com">ryta1203@gmail.com</a>></span><br>Date: Thu, Nov 10, 2011 at 10:31 AM<br>
Subject: Re: [LLVMdev] Problem getting LoopInfo inside non-LoopPass<br>To: Devang Patel <<a href="mailto:dpatel@apple.com">dpatel@apple.com</a>><br><br><br>I need to iterate bottom up on the nodes, but within that I want to break up BBs within a loop. I could just create a loop pass as another opt and call that, I just thought it'd be easier to get the loop info inside the opt I'm already doing.<div class="HOEnZb">
<div class="h5"><br>
<br><div class="gmail_quote">On Thu, Nov 10, 2011 at 10:25 AM, Devang Patel <span dir="ltr"><<a href="mailto:dpatel@apple.com" target="_blank">dpatel@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word">Ryan,<div><br></div><div>Why do your call graph pass need loop info ? Why can't it be a LoopPass ?</div><div>-</div><div>Devang</div><div><div><div><br><div><div>On Nov 10, 2011, at 10:03 AM, Ryan Taylor wrote:</div>

<br><blockquote type="cite">John,<br><br>  This did not work. It compiles (isDeclaration was the name of the function) and I passed a reference (&F) (F is a function pointer). I still get the opt load error from the original message (UNREACHABLE exectuted!).<br>


<br>Thanks.<br><br><div class="gmail_quote">On Thu, Nov 10, 2011 at 10:00 AM, Ryan Taylor <span dir="ltr"><<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


1. Ok will do.<br>2. Ok, will do.<br>3. It's a CallGraphPass. I mentioned this in my first post.<br>4. Yep, I have the header files included, I'm not sure it would compile otherwise (previously). I would get an error like LoopInfo not declared.<br>



<br>I'll try your suggestions, thanks again!<br><br><div class="gmail_quote">On Thu, Nov 10, 2011 at 9:57 AM, John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu" target="_blank">criswell@illinois.edu</a>></span> wrote:<div>


<div><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>
    On 11/10/11 11:48 AM, R<span>c</span>   <span>Add Bcc</span>   <span>Edit Subject</span>   <span>Attach a file</span>   <span>Insert: </span><span>Invitation</span> yan Taylor wrote:
    <blockquote type="cite">
      
      John,<br>
      <br>
        Thanks, this does not compile though, I get this error:<br>
    </blockquote>
    <br></div>
    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>
    :)<div><br>
    <br>
    <blockquote type="cite"><br>
      cdfg_pass.cpp:511:11: error: ‘class llvm::Function’ has no member
      named ‘getDeclaration’<br>
    </blockquote>
    <br></div>
    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.<div><br>
    <br>
    <blockquote 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></div>
    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.<div><div><br>
    <br>
    <blockquote 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 href="mailto:criswell@illinois.edu" target="_blank">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> 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> <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 href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a>
<a 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>
  </div></div></div>

</blockquote></div></div></div><br>
</blockquote></div><br>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>

<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></div></div></div></blockquote></div><br>
</div></div></div><br>