我想在从CallGraphSCC-Pass派生的传递的LoopInfoPass
方法中使用runOnSCC()
。更具体地说,我想在runOnSCC()
方法中判断基本块是否在循环中。
所以,代码应该是:
LoopInfo &lf = getAnalysis<LoopInfo>(F);
Loop *bbLoop = lf.getLoopFor(BB);
和getAnalysisUsage:
void AnalyzerPass::getAnalysisUsage(AnalysisUsage &Info) const {
Info.addRequired<CallGraphWrapperPass>();
Info.addRequired<LoopInfo>();
Info.addRequired<ScalarEvolution>();
Info.addPreserved<CallGraphWrapperPass>();
Info.setPreservesCFG();
}
和初始化:
INITIALIZE_PASS_BEGIN(AnalyzerPass, "analyzer",
"analysis", false, false)
INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LoopInfo)
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
INITIALIZE_PASS_END(AnalyzerPass, "analyzer",
"analysis", false, false)
最后,我使用PassManager:
PassManager pm;
pm.add(LoopInfo);
pm.add(ScalarEvolution);
pm.add(AnalyzerPass);
pm.run(&module);
执行pm.run(&module)
时,出现错误:
Unable to schedule 'Natural Loop Info' for 'analysis'.
Unable to schedule pass.
我想问我哪里错了?关于如何使用CallGraphSCC-Pass的信息太少。任何帮助将不胜感激!