从FunctionPass获取RegionPass分析信息

时间:2018-05-01 11:39:46

标签: c++ llvm

我有一个RegionPass,其分析结果我想在FunctionPass中使用。

class RPass : public RegionPass{
    bool runOnRegion(...) { ... };
}

class FPass : public FunctionPass {
    bool runOnFunction(Function &F){
        // Get a list of regions in the function
        auto RI = &getAnalysis<RegionInfoPass>().getRegionInfo();
        std::deque<Region *> RQ = getRegionList(RI->getTopLevelRegion());

        for(Region *R : RQ){
            /* In this step, I want to get the analysis results 
             * for the Region from the RPass */
            RPass *RPI = &getAnalysis<RPass>(R);
            ...
        }
    }
    void getAnalysisUsage(AnalysisUsage &AU){
        AU.addRequired<RPass>();
        ...
        AU.setPreservesAll();
    }
}

不幸的是,唯一可用的功能是 getAnalysis() getAnalysis(功能&amp; F)

* RPass RPI =&amp; getAnalysis(); 导致运行时错误:

Assertion 'ResultPass && "getAnalysis*() called on an analysis that wa not " "'required' by pass!"' failed

和* RPass RPI =&amp; getAnalysis(R); 导致编译错误:

error: no matching function for call to 'FPass::getAnalysis(llvm::Region*&)

有关如何获取所需信息的任何想法?关于编写LLVM通行证的文档导致死路一条。

0 个答案:

没有答案