[llvm-dev] LoopInfo Analysis Fails on Module Pass

via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 14 18:51:11 PDT 2021


Hi,

I am trying to obtain LoopInfo Analysis from a Module Pass. My code goes 
like:



    void SomePass::someFunction (Module &M) {

    for (auto &F : M) {

           LoopInfo *LI = &getAnalysis<LoopInfoWrapperPass>(F).getLoopInfo(); 
//doing this gives me error shown below

           for (auto &B : F) {

                       //some use of LI
             }
         }

      }


   The runtime error message that I am getting is:

   opt: /usr/lib/llvm-10/include/llvm/PassAnalysisSupport.h:262: AnalysisType& 
llvm::Pass::getAnalysisID(llvm::AnalysisID, llvm::Function&) [with 
AnalysisType = llvm::LoopInfoWrapperPass; llvm::AnalysisID = const void*]: 
Assertion `ResultPass && "Unable to find requested analysis info"' failed.


  I also have defined the analysis usage function as follows:

      /*void getAnalysisUsage(AnalysisUsage &AU) const
     {
             //AU.setPreservesAll(); // I am actually instrumenting the IR, so 
I am not sure this is required. The error occurs regardless.
             AU.addRequired<LoopInfoWrapperPass>();
     }*/


   Is there anything that I am missing here?


   Thanks,
   Bodhi


More information about the llvm-dev mailing list