[LLVMdev] Error when using getAnalysis

Bill Wendling isanbard at gmail.com
Sat Nov 29 21:06:20 PST 2008


On Nov 29, 2008, at 8:53 PM, nitisha warkari wrote:

> Hi,
>
> I'm trying to use the function getAnalysis. This is the code I'm  
> using :
>
>  void getAnalysisUsage(AnalysisUsage &AU) const {
>       AU.addRequired<LoopInfo>();
>       AU.setPreservesAll();
>     }
>
>  virtual bool runOnModule(Module &M) {
>      LoopInfo &LI = getAnalysis<LoopInfo>();
>
>
>    }
>
>
>
> I get following error when I try to run my pass :
>
> opt: /net/hc295/nwarkari/llvm/llvm-2.3/include/llvm/ 
> PassAnalysisSupport.h:193: 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.
> opt[0x83cfa9d]
> /lib/tls/libc.so.6(abort+0xe9)[0x15d289]
> /lib/tls/libc.so.6(__assert_fail+0x101)[0x154da1]
> opt(_ZNK4llvm4Pass13getAnalysisIDINS_8LoopInfoEEERT_PKNS_8PassInfoE 
> +0x54)[0x81294a0]
>
> Could someone please help me out with this?
>
You might need to have your pass inherit from the LoopPass instead of  
ModulePass. See some examples in lib/Transforms/Scalar.

-bw




More information about the llvm-dev mailing list