LLVM New Pass Manager-如何传递额外的参数?

时间:2019-02-28 22:47:03

标签: llvm llvm-ir llvm-c++-api

我有一个由两个文件组成的自定义LLVM AnalysisInfo Pass。我试图找出如何将额外的要素,例如 bool 传递给 AnalysisPass.h 中的 run()? / p>

目前,我正在这样调用通行证:

AnalysisInfo &FA = FAM.getResult<FunctionInfoPass>(*f);

我希望能够通过这种方式拨打通行证:

AnalysisInfo &FA = FAM.getResult<FunctionInfoPass>(*f, true);


我该怎么做?


AnalysisPass.h

#include "AnalysisInfo.h"

class AnalysisPass : public llvm::AnalysisInfoMixin<AnalysisPass>
{
   friend llvm::AnalysisInfoMixin<AnalysisPass>;
   static llvm::AnalysisKey Key;

public:
using Result = AnalysisInfo;`//object to collect analysis data

AnalysisInfo run(llvm::Function &function, llvm::FunctionAnalysisManager &FAM)
{
    AnalysisInfo analysis(&function);
    gatherAnalysis(function, analysis, FAM);
    return analysis;
}

void gatherAnalysis(llvm::Function &function, AnalysisInfo &analysis,
                  llvm::FunctionAnalysisManager &FAM);
};

AnalysisPass.cpp

#include "AnalysisPass.h"

llvm::AnalysisKey AnalysisPass::Key;

void AnalysisPass::gatherAnalysis(llvm::Function &function, AnalysisInfo &analysis, llvm::FunctionAnalysisManager &FAM)
{
  //do stuff
}

0 个答案:

没有答案