llvm 4.0.0初始化AliasSetTracker类

时间:2017-05-21 01:49:44

标签: llvm

我尝试使用AliasSetTracker来收集别名集。然而,新版本让我感到困惑。要初始化AliasSetTracker,我需要一个AliasAnalysis实例。但旧的:

AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
AliasSetTracker tr(AA);

没有工作和错误:

In file included from /Users/.../LLVM/llvm/include/llvm/Pass.h:388:
/Users/.../llvm/include/llvm/PassAnalysisSupport.h:223:53: error: no member 
named 'ID' in 'llvm::AAResults'
return getAnalysisID<AnalysisType>(&AnalysisType::ID);

/Users.../program/Analysis.cpp:215:25: note: in 
instantiation of function template specialization 
'llvm::Pass::getAnalysis<llvm::AAResults>' requested here
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();

1 个答案:

答案 0 :(得分:0)

在这个新版本的LLVM中,你必须使用函数getAnalysisUsage并修改你使用函数getAnalysis的方式:
1-在pass结构中添加以下函数:
  virtual void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<AAResultsWrapperPass>(); }
2-修改对getAnalysis函数的调用:
   AliasAnalysis &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();

现在可以使用了:)