runtime assert failure when trying to obtain analysis pass info within a transformation pass

I am having problems passing analysis results to transformation passes, so I reduced my testcase into the following bare bone:

Pass1: simple FunctionPass, counting functions
Pass2: transformation pass, for now, just trying to obtain a reference of Pass1 using AU.getAnalysis<Pass1>() inside its runOnFunction().

When I run it, I get the following runtime error:

opt -load Release/lib/ -pass2 < ../test/test.bc > /dev/null
opt: /autofs/steffan/a/a0/czhao/ResearchTools/LLVM/2.7/llvm-2.7//include/llvm/PassAnalysisSupport.h:53: llvm::AnalysisUsage& llvm::AnalysisUsage::addRequiredID(const llvm::PassInfo*): Assertion `ID && "Pass class not registered!"' failed.
0 opt 0x084d2928
Stack dump:
0. Program arguments: opt -load Release/lib/ -pass2
/bin/sh: line 1: 6436 Aborted opt -load Release/lib/ -pass2 <../test/test.bc >/dev/null
make: *** [run_pass2] Error 134

Any hints?

Thank you


Pass2.cpp (1.87 KB)

Pass1.cpp (1.12 KB)

Pass1.h (1.71 KB)

Makefile (672 Bytes)