LLVM: How to use LoopInfoPass and ScalarEvolutionPass in CallGraphSCC-Pass?

472 views Asked by At

I want to use LoopInfoPass in the runOnSCC() method of a pass derived from CallGraphSCC-Pass. More specifically, I want to judge whether a basicblock is in a loop or not in the runOnSCC() method. So, the code should be like:

LoopInfo &lf = getAnalysis<LoopInfo>(F);
Loop *bbLoop = lf.getLoopFor(BB);

and the getAnalysisUsage:

void AnalyzerPass::getAnalysisUsage(AnalysisUsage &Info) const {
    Info.addRequired<CallGraphWrapperPass>();
    Info.addRequired<LoopInfo>();
    Info.addRequired<ScalarEvolution>();
    Info.addPreserved<CallGraphWrapperPass>();
    Info.setPreservesCFG();
}

and the Initialization:

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)

Finally, I use a PassManager:

PassManager pm;
pm.add(LoopInfo);
pm.add(ScalarEvolution);
pm.add(AnalyzerPass);
pm.run(&module);

When executing the pm.run(&module), I get the error:

Unable to schedule 'Natural Loop Info' for 'analysis'.
Unable to schedule pass.

I want to ask where am I wrong? There are too little information about how to use CallGraphSCC-Pass. Any help would be much appreciated!

0

There are 0 answers