about writing a functionpass requiring a modulepass


I wrote an analysis pass, myPass, inherited from both ModulePass and ProfileInfo, and this pass requires the CallGraph, i.e.,

class myPass : public ModulePass, public ProfileInfo { …};

void myPass::getAnalysisUsage(AnalysisUsage &AU) const {


Then, I assumes the UnreachableBlockElim (inherited from FunctionPass) requires myPass, by revising the related function as follows:

UnreachableBlockElim::getAnalysisUsage(AnalysisUsage &AU) const {


Then, i built it, it is OK. I went on to run it. It failed with a segment error.
By debugging, it is found that in the following code from PMTopLevelManager::schedulePass(Pass *P),

const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(*I);
AnalysisPass = PI->createPass();

When this manager search for the CallGraph reqiured by myPass ( in the failing trace , Pass *P is myPass), the return value of PassRegistry::getPassInfo(const void *TI) is NULL, thus the following dereference of PI is invalid.
I am using llvm 2.9, which is download from http://llvm.org/releases/.

Could anybody help me?

This may be a limitation of pass manager. Please file a bug report with a reproducible test case. Thanks!