PassManager与LegacyPassManager

PassManager与LegacyPassManager

本文介绍了LLVM(3.5+)PassManager与LegacyPassManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用LLVM C ++ API开发新的语言,并希望利用优化过程。 ( 注意: ,我目前使用的是源LLVM的最新版本,我认为该版本等于3.8)

I'm working on a new language using the LLVM C++ API and would like to take advantage of optimization passes. (Note: I'm currently using the latest from source LLVM which I believe equates to 3.8)

I尚未找到使用新的甚至是仍在使用。

I have yet to find any examples that use the new PassManager and even Clang is still utilizing the LegacyPassManager.

我遇到过诸如提到了新的,但他们仍然仍然使用旧版系统。

I have come across posts such as this that are several years old now that mention the new PassManager, but they all still use the legacy system.

是否有任何示例/教程来使用这种新的(ish)?新的LLVM项目是否应该首选而不是? 是否计划进行迁移,或者这就是Legacy系统始终存在的原因?

Is there any examples/tutorials on how to use this new(ish) PassManager? Should new LLVM projects prefer PassManager to LegacyPassManager? Does Clang plan on migrating or is this why the Legacy system has stuck around?

推荐答案

扩展Lukes答案,使用 PassBuilder ,您可以构建预定义的开箱即用简化管道,并进行不同的优化级别:

Extending Lukes answer, with PassBuilder you can build predefined "out of box" simplification pipelines with different optimization levels:

llvm::FunctionAnalysisManager FAManager;
llvm::PassBuilder passBuilder;

passBuilder.registerFunctionAnalyses(FAManager);

passBuilder.buildFunctionSimplificationPipeline(
        llvm::PassBuilder::OptimizationLevel::O2,
        llvm::PassBuilder::ThinLTOPhase::None);

这会向 FunctionAnalysisManager 。这样可以简化您的生活。看到为每个 OptimizationLevel 添加的完整通行证的最佳位置是。

which will add a bunch of passes to FunctionAnalysisManager. This may simplify your life. The best place to see the full set of passes added for each OptimizationLevel is the original sources.

这篇关于LLVM(3.5+)PassManager与LegacyPassManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 23:42