[LLVMdev] getAnalysis*() called on an analysis that was not " "'required' by pass!

Wojciech Matyjewicz wmatyjewicz at fastmail.fm
Tue Mar 4 23:34:21 PST 2008


Hi,

> bool MyModulePass::runOnModule(Module &m) {
>         for (Module::const_iterator f = m.begin(); f != m.end(); ++f)
>                 DominatorTree &dt = getAnalysis<DominatorTree>();
> 
>         return false;
> }

DominatorTree is a function-level analysis, while your pass is a
module-level one. It means you have to point the function you want the
analysis result for. Try using:

  getAnalysis<DominatorTree>(*f);

(It would probably require changing const_iterator to iterator)

Getting analysis result is valid only for function definitions, not
declarations. Hence, it is necessary to check f->isDeclaration() before
calling getAnalysis().

Wojtek



More information about the llvm-dev mailing list