Can a Function Pass require a Module Pass?

Dear LLVMers,

I am implementing a Function Pass and I would like to use analysis obtained from a Module Pass. Some extracts of my code look like that:

struct MyPass : public FunctionPass {
static char ID;
MyPass() : FunctionPass(ID) {
PADriver &PD = getAnalysis();


virtual void getAnalysisUsage(AnalysisUsage &AU) const{
AU.setPreservesAll();
AU.addRequired();
}

But when I try to run my pass, I get the following error at the point os getAnalysis:

Assertion `Resolver && “Pass has not been inserted into a PassManager object!”’ failed.

Did I do anything I should not or did I miss something?

Regards,

Problem solved. The problem is that I cannot call getAnalysis inside the pass constructor.