Hi,
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 {
AU.addRequired();
AU.setPreservesAll();
}
Then, I assumes the UnreachableBlockElim (inherited from FunctionPass) requires myPass, by revising the related function as follows:
UnreachableBlockElim::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addPreserved();
AU.addPreserved();
AU.addRequired();
}
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?