对于我自己的 LLVM 传递,我需要
llvm::DependenceAnalysis()
传递的结果。 IE。我想要某些模块/功能的 DependenceInfo
对象。
我尝试了多种方法来获取通行证来运行通行证,但到目前为止都没有奏效。
欢迎任何有关如何使用
DependenceAnalysis
的提示!
第一种方法:
我尝试直接在我自己的 pass 的
DependenceAnalysis().run()
函数中调用 run()
函数。
// MAM is the ModuleAnalysisManager that is an argument to the run() function of my pass
FunctionAnalysisManager &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
DependenceAnalysis depAnalysis;
llvm::DependenceInfo depInfo = depAnalysis.run(F, FAM);
当我运行我的通行证时,我收到来自
opt
的错误:
opt: CommandLine Error: Option 'enable-fs-discriminator' registered more than once!
我无法找到此错误消息的来源。
第二种方法: 我将
DependenceAnalysis()
通行证直接添加到 ModulePassManager
,我还添加了我自己的通行证。
MPM.addPass(createModuleToFunctionPassAdaptor((DependenceAnalysis())))
这会导致编译错误,因为
DependenceAnalysis.run()
不返回 PreservedAnalysis
对象,而是返回 DependenceInfo
对象。
我发现问题不仅在于我如何使用
DependenceAnalysis
,还在于我链接LLVM时出现了一些问题。
获取
DependenceAnalysis
的结果是通过以下方式完成的:
FunctionAnalysisManager &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
DependencyInfo depInfo = FAM.getResult<DependenceAnalysis>(F);
感谢@arnt指出链接问题。结果我在
CMake
中链接了两次 LLVM。