在LLVM 5.0.1中使用AAResultsWrapperPass时出现分段错误

时间:2018-04-03 07:53:07

标签: llvm

我正在尝试使用AliasAnalysis(LLVM 5.01),我的代码如下:

void getAnalysisUsage(AnalysisUsage &AU) const override {
  AU.addRequired<AAResultsWrapperPass>();
}

我得到AliasAnalysis如下:

AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();

此代码已正确编译。但是当我运行这个时,我会遇到以下错误:

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

有人建议将当前函数作为参数传递给此函数来解决此问题(Segmentation fault while using AAResultsWrapperPass in llvm3.8.1

getAnalysis<AAResultsWrapperPass>().getAAResults() - NOT working
getAnalysis<AAResultsWrapperPass>().getAAResults(F)- working

然而,他的方法对我不起作用。如何处理这个问题?

1 个答案:

答案 0 :(得分:0)

尝试以函数为参数调用.zshrc,即

getAnalysis