Hello, I was trying to get the loop info in a module pass to be able to iterate over the loops int the module itself. Since my pass requires to make module level changes including adding new types to module hence a looppass cannot be used here. I am getting the following error on running opt. opt: /root/llvm-2.4/include/llvm/PassAnalysisSupport.h:199: AnalysisType& llvm::Pass::getAnalysisID(const llvm::PassInfo*) const [with AnalysisType = llvm::LoopInfo]: Assertion `ResultPass && "getAnalysis*() called on an analysis that was not " "'required' by pass!"' failed. <snip_gdb_trace> #4 0x083006f2 in llvm::Pass::getAnalysisID<llvm::LoopInfo> (this=0x86cfc48, PI=0x86cbfe0) at /root/llvm-2.4/include/llvm/PassAnalysisSupport.h:197 #5 0x083007aa in llvm::Pass::getAnalysis<llvm::LoopInfo> (this=0x86cfc48) at /root/llvm-2.4/include/llvm/PassAnalysisSupport.h:186 #6 0x0056e1c0 in runOnModule (this=0x86cfc48, M=@0x86cfeb8) at timing.cpp:167 </snip_gdb_trace> gdb backtrace points to the following statement in the runOnModule method; Loopinfo * LI = &getAnalysis<LoopInfo>(); following is the content of the getAnalysis Usage method. void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<LoopInfo> (); AU.addPreserved<LoopInfo> (); } I picked this from the LPPassManager class which has a similar structure and its runOnFunction iterates over loop list from LoopInfo. I think I am missing some line to add. Can someone please point out the cause of the error?? Thanks regards, Kshitiz -- Kshitiz Garg Graduate Student Department of Computer Science & Engineering IIT Kanpur http://home.iitk.ac.in/~kshitizg
Kshitiz Garg wrote:> Hello, > I was trying to get the loop info in a module pass to be able to > iterate over the loops int the module itself. Since my pass requires > to make module level changes including adding new types to module > hence a looppass cannot be used here. > I am getting the following error on running opt. > > opt: /root/llvm-2.4/include/llvm/PassAnalysisSupport.h:199: > AnalysisType& llvm::Pass::getAnalysisID(const llvm::PassInfo*) const > [with AnalysisType = llvm::LoopInfo]: Assertion `ResultPass && > "getAnalysis*() called on an analysis that was not " "'required' by > pass!"' failed. > > <snip_gdb_trace> > #4 0x083006f2 in llvm::Pass::getAnalysisID<llvm::LoopInfo> (this=0x86cfc48, > PI=0x86cbfe0) at /root/llvm-2.4/include/llvm/PassAnalysisSupport.h:197 > #5 0x083007aa in llvm::Pass::getAnalysis<llvm::LoopInfo> (this=0x86cfc48) > at /root/llvm-2.4/include/llvm/PassAnalysisSupport.h:186 > #6 0x0056e1c0 in runOnModule (this=0x86cfc48, M=@0x86cfeb8) at timing.cpp:167 > </snip_gdb_trace> > gdb backtrace points to the following statement in the runOnModule method; > Loopinfo * LI = &getAnalysis<LoopInfo>(); >I believe the problem here is that you need to specify the function for which you want loop information in the above call, i.e.: Loopinfo * LI = &getAnalysis<LoopInfo>(F) ... where F is either a pointer to the Function or is a reference to the Function (I don't recall the details off-hand; see http://llvm.org/docs/WritingAnLLVMPass.html#getAnalysis for more information. You said that your pass needs to make some global modification to the Module. In some cases, you can still write your pass as a FunctionPass; simply put the code that changes global Module information into the doInitialization() or doFinalization() methods. -- John T.> following is the content of the getAnalysis Usage method. > > void getAnalysisUsage(AnalysisUsage &AU) const { > AU.addRequired<LoopInfo> (); > AU.addPreserved<LoopInfo> (); > } > > I picked this from the LPPassManager class which has a similar > structure and its runOnFunction iterates over loop list from LoopInfo. > > I think I am missing some line to add. Can someone please point out > the cause of the error?? > > Thanks > regards, > Kshitiz > -- > Kshitiz Garg > Graduate Student > Department of Computer Science & Engineering > IIT Kanpur > http://home.iitk.ac.in/~kshitizg > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Hi, Kshitiz Garg wrote:> Hello, > I was trying to get the loop info in a module pass to be able to > iterate over the loops int the module itself. Since my pass requires > to make module level changes including adding new types to module > hence a looppass cannot be used here. > I am getting the following error on running opt. > > opt: /root/llvm-2.4/include/llvm/PassAnalysisSupport.h:199: > AnalysisType& llvm::Pass::getAnalysisID(const llvm::PassInfo*) const > [with AnalysisType = llvm::LoopInfo]: Assertion `ResultPass && > "getAnalysis*() called on an analysis that was not " "'required' by > pass!"' failed. > > <snip_gdb_trace> > #4 0x083006f2 in llvm::Pass::getAnalysisID<llvm::LoopInfo> (this=0x86cfc48, > PI=0x86cbfe0) at /root/llvm-2.4/include/llvm/PassAnalysisSupport.h:197 > #5 0x083007aa in llvm::Pass::getAnalysis<llvm::LoopInfo> (this=0x86cfc48) > at /root/llvm-2.4/include/llvm/PassAnalysisSupport.h:186 > #6 0x0056e1c0 in runOnModule (this=0x86cfc48, M=@0x86cfeb8) at timing.cpp:167 > </snip_gdb_trace> > gdb backtrace points to the following statement in the runOnModule method; > Loopinfo * LI = &getAnalysis<LoopInfo>(); > > following is the content of the getAnalysis Usage method. > > void getAnalysisUsage(AnalysisUsage &AU) const { > AU.addRequired<LoopInfo> (); > AU.addPreserved<LoopInfo> (); > } > > I picked this from the LPPassManager class which has a similar > structure and its runOnFunction iterates over loop list from LoopInfo. > > I think I am missing some line to add. Can someone please point out > the cause of the error??Funny enough I stumbled over the same problem right now. I have no solution either but I will post a follow-up if I find something out. Andi
>> > I believe the problem here is that you need to specify the function for > which you want loop information in the above call, i.e.: > > Loopinfo * LI = &getAnalysis<LoopInfo>(F) >Thanks John . Your solution worked. We need to pass the function as a reference. However only the do initialization can do some module level stuff but it will not serve my purpose as one is not allowed to maintain states across 2 invocations of a function pass. kshitiz