Fault while using AAResultsWrapperPass in LLVM 5.0.1

I am trying to use AliasAnalysis. The code for pass dependence is as following:

class Timer : public ModulePass{
AliasAnalysis *AA;
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired();
}

}

bool Timer::runOnFunction(Function &F)
{
LLVMContext &C = F.getContext();
AA = &getAnalysis(F).getAAResults();

}

When the Timer pass is registered by the following code:
char CPI::ID = 0;
static RegisterPass X(“cpi”, “code pointer integrity Pass”);
The test code can be compiled successfully by the following command:
comp_1:
clang -O0 -emit-llvm test.c -c -o test_clang.bc
clang -O0 -emit-llvm fun_lib.c -c -o fun_lib.bc
opt -load ${LLVM_LIB}/LLVMTimer.so -Timer < test_clang.bc > test_clang1.bc
opt -load ${LLVM_LIB}/LLVMTimer.so -Timer < fun_lib.bc > test_clang1.bc
llc test_clang.bc -o test_clang.s
llc fun_lib.bc -o fun_lib.s
gcc test_clang.s fun_lib.s -o test.native

When the Pass is registered by the following code:
static void registerCPI(const PassManagerBuilder &, legacy::PassManagerBase &PM){
PM.add(new CPI());
}

static RegisterStandardPasses
RegisterMyPass(PassManagerBuilder::EP_ModuleOptimizerEarly, registerCPI);

static RegisterStandardPasses
RegisterMyPass0(PassManagerBuilder::EP_EnabledOnOptLevel0, registerCPI);
And compiled with the following command:
comp_3:
clang -Xclang -load -Xclang ${LLVM_LIB}/LLVMCPI.so -O0 -c test.c
clang -Xclang -load -Xclang ${LLVM_LIB}/LLVMCPI.so -O0 -c fun_lib.c
cc *.o ${CPI_LIB}
I get the following errors:

clang -Xclang -load -Xclang /home/zhangjun/tools/llvm/llvm-build/lib/LLVMCPI.so -O0 -c test.c
Pass ‘Unnamed pass: implement Pass::getPassName()’ is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
clang-5.0: /home/zhangjun/tools/llvm/llvm/lib/IR/LegacyPassManager.cpp:653: void llvm::PMTopLevelManager::schedulePass(llvm::Pass*): Assertion `PI && “Expected required passes to be initialized”’ failed.
#0 0x0000000002dae43f llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/zhangjun/tools/llvm/llvm/lib/Support/Unix/Signals.inc:398:0
#1 0x0000000002dae4d0 PrintStackTraceSignalHandler(void*) /home/zhangjun/tools/llvm/llvm/lib/Support/Unix/Signals.inc:462:0
#2 0x0000000002dac916 llvm::sys::RunSignalHandlers() /home/zhangjun/tools/llvm/llvm/lib/Support/Signals.cpp:49:0
#3 0x0000000002daddd7 SignalHandler(int) /home/zhangjun/tools/llvm/llvm/lib/Support/Unix/Signals.inc:252:0

How to fix this problem?

Regards,
Jun