<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"><style>body { line-height: 1.5; }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span><br></div>
<div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">I am trying to use AliasAnalysis. The code for pass dependence is as following:<br><br>class Timer : public ModulePass{<br> AliasAnalysis *AA;<br> void getAnalysisUsage(AnalysisUsage &AU) const override {<br> AU.addRequired<AAResultsWrapperPass>();<br> }<br>.........<br>}<br><br>bool Timer::runOnFunction(Function &F) <br>{<br> LLVMContext &C = F.getContext();<br> AA = &getAnalysis<AAResultsWrapperPass>(F).getAAResults();<br>.....<br>}<br><br>When the Timer pass is registered by the following code:<br>char CPI::ID = 0;<br>static RegisterPass<CPI> X("cpi", "code pointer integrity Pass");<br>The test code can be compiled successfully by the following command:<br>comp_1:<br><span style="white-space: pre;"> </span>clang -O0 -emit-llvm test.c -c -o test_clang.bc<br><span style="white-space: pre;"> </span>clang -O0 -emit-llvm fun_lib.c -c -o fun_lib.bc<br><span style="white-space: pre;"> </span>opt -load ${LLVM_LIB}/LLVMTimer.so -Timer < test_clang.bc > test_clang1.bc<br><span style="white-space: pre;"> </span>opt -load ${LLVM_LIB}/LLVMTimer.so -Timer < fun_lib.bc > test_clang1.bc<br><span style="white-space: pre;"> </span>llc test_clang.bc -o test_clang.s<br><span style="white-space: pre;"> </span>llc fun_lib.bc -o fun_lib.s<br><span style="white-space: pre;"> </span>gcc test_clang.s fun_lib.s -o test.native<br><br>When the Pass is registered by the following code:<br>static void registerCPI(const PassManagerBuilder &, legacy::PassManagerBase &PM){<br> PM.add(new CPI()); <br>}<br><br>static RegisterStandardPasses <br> RegisterMyPass(PassManagerBuilder::EP_ModuleOptimizerEarly, registerCPI);<br><br>static RegisterStandardPasses<br><span style="white-space: pre;"> </span>RegisterMyPass0(PassManagerBuilder::EP_EnabledOnOptLevel0, registerCPI);<br>And compiled with the following command:<br>comp_3:<br><span style="white-space: pre;"> </span>clang -Xclang -load -Xclang ${LLVM_LIB}/LLVMCPI.so -O0 -c test.c <br><span style="white-space: pre;"> </span>clang -Xclang -load -Xclang ${LLVM_LIB}/LLVMCPI.so -O0 -c fun_lib.c <br><span style="white-space: pre;"> </span>cc *.o ${CPI_LIB}<br>I get the following errors:<br><br>clang -Xclang -load -Xclang /home/zhangjun/tools/llvm/llvm-build/lib/LLVMCPI.so -O0 -c test.c <br>Pass 'Unnamed pass: implement Pass::getPassName()' is not initialized.<br>Verify if there is a pass dependency cycle.<br>Required Passes:<br>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.<br>#0 0x0000000002dae43f llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/zhangjun/tools/llvm/llvm/lib/Support/Unix/Signals.inc:398:0<br>#1 0x0000000002dae4d0 PrintStackTraceSignalHandler(void*) /home/zhangjun/tools/llvm/llvm/lib/Support/Unix/Signals.inc:462:0<br>#2 0x0000000002dac916 llvm::sys::RunSignalHandlers() /home/zhangjun/tools/llvm/llvm/lib/Support/Signals.cpp:49:0<br>#3 0x0000000002daddd7 SignalHandler(int) /home/zhangjun/tools/llvm/llvm/lib/Support/Unix/Signals.inc:252:0<br><br></span></div><div>How to fix this problem?</div><div><br></div><div>Regards,</div><div>Jun</div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>zhangjun02@ict.ac.cn</div></div></span></div>
</body></html>