[LLVMdev] how can I have LoopInfo in a module pass?

Wenbin Zhang zhangwen at cse.ohio-state.edu
Thu Mar 3 14:26:20 PST 2011


I think this assertion failure may be caused by the getAnalysisUsage(). Mine is like the following:

class myclass : public ModulePass{
    ...
    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
        AU.addRequired<LoopInfo>();
    }
    ...
}

Is it enough? Thanks!

Best,
--Wenbin

  ----- Original Message ----- 
  From: Wenbin Zhang 
  To: John Criswell 
  Cc: llvmdev at cs.uiuc.edu 
  Sent: Thursday, March 03, 2011 5:04 PM
  Subject: Re: [LLVMdev] how can I have LoopInfo in a module pass?


  Thanks John, I modify my code to like this:

  bool XXX::ModulePass(Module &M){
      ....
      LoopInfo &li = getAnalysis<LoopInfo>(fi);
      ....
  }

  Here fi is a Function* pointing to main().

  Now when I run the pass, another error shows up:

  AnalysisType& llvm::Pass::getAnalysisID(const llvm::PassInfo*, llvm::Function&) [with AnalysisType = llvm::LoopInfo]: Assertion `ResultPass && "Unable to find requested analysis info"' failed.

  Did I miss something? Thanks!

  Best,
  --Wenbin
    ----- Original Message ----- 
    From: John Criswell 
    To: Wenbin Zhang 
    Cc: llvmdev at cs.uiuc.edu 
    Sent: Thursday, March 03, 2011 4:26 PM
    Subject: Re: [LLVMdev] how can I have LoopInfo in a module pass?


    On 3/3/11 3:09 PM, Wenbin Zhang wrote: 
      Hi all,
      I tried to have a LoopInfo object in a function pass, add addRequired<LoopInfo> in getAnalysisUsage, and then use getAnalysis<LoopInfo> in runOnFunction(). It worked OK.
      Now I want to have a module pass to traverse the functions, and similarly I want to have to loop information of the functions. When I did the above in runOnModule, and run the pass, the following error popped out:

      AnalysisType& llvm::Pass::getAnalysis() const [with AnalysisType = llvm::DominatorTree]: Assertion `Resolver && "Pass has not been inserted into a PassManager object!"' failed.

      Can anyone tell me the correct way to handle this in a module pass? Thanks a lot!

    LoopInfo is a FunctionPass, so you have to use getAnalysis<LoopInfo>(F) where F is a pointer to the function that you want analyzed.

    Note that LoopInfo, in this instance, will be re-run every time you call getAnalysis on it (this is a result of using a FunctionPass within a ModulePass).  Be sure to structure you code to only call getAnalysis<LoopInfo>(F) on each function just once, if possible.

    Also be sure that F is not a function declaration (i.e., a function with no body).

    -- John T.



      Best,
      --Wenbin




------------------------------------------------------------------------------


  _______________________________________________
  LLVM Developers mailing list
  LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
  http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110303/0ada6bfa/attachment.html>


More information about the llvm-dev mailing list