//===- Parsing, selection, and construction of pass pipelines --*- C++ -*--===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// \file /// /// Interfaces for registering analysis passes, producing common pass manager /// configurations, and parsing of pass pipelines. /// //===----------------------------------------------------------------------===// #ifndef LLVM_PASSES_PASSBUILDER_H #define LLVM_PASSES_PASSBUILDER_H #include "llvm/Analysis/CGSCCPassManager.h" #include "llvm/CodeGen/MachinePassManager.h" #include "llvm/CodeGen/RegAllocCommon.h" #include "llvm/IR/PassManager.h" #include "llvm/Passes/OptimizationLevel.h" #include "llvm/Support/Error.h" #include "llvm/Support/PGOOptions.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/IPO/Inliner.h" #include "llvm/Transforms/IPO/ModuleInliner.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" #include <optional> #include <vector> namespace llvm { class StringRef; class AAManager; class TargetMachine; class ModuleSummaryIndex; template <typename T> class IntrusiveRefCntPtr; namespace vfs { class FileSystem; } // namespace vfs /// Tunable parameters for passes in the default pipelines. class PipelineTuningOptions { … }; /// This class provides access to building LLVM's passes. /// /// Its members provide the baseline state available to passes during their /// construction. The \c PassRegistry.def file specifies how to construct all /// of the built-in passes, and those may reference these members during /// construction. class PassBuilder { … }; /// This utility template takes care of adding require<> and invalidate<> /// passes for an analysis to a given \c PassManager. It is intended to be used /// during parsing of a pass pipeline when parsing a single PipelineName. /// When registering a new function analysis FancyAnalysis with the pass /// pipeline name "fancy-analysis", a matching ParsePipelineCallback could look /// like this: /// /// static bool parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM, /// ArrayRef<PipelineElement> P) { /// if (parseAnalysisUtilityPasses<FancyAnalysis>("fancy-analysis", Name, /// FPM)) /// return true; /// return false; /// } template <typename AnalysisT, typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs> bool parseAnalysisUtilityPasses( StringRef AnalysisName, StringRef PipelineName, PassManager<IRUnitT, AnalysisManagerT, ExtraArgTs...> &PM) { … } // These are special since they are only for testing purposes. /// No-op module pass which does nothing. struct NoOpModulePass : PassInfoMixin<NoOpModulePass> { … }; /// No-op module analysis. class NoOpModuleAnalysis : public AnalysisInfoMixin<NoOpModuleAnalysis> { … }; /// No-op CGSCC pass which does nothing. struct NoOpCGSCCPass : PassInfoMixin<NoOpCGSCCPass> { … }; /// No-op CGSCC analysis. class NoOpCGSCCAnalysis : public AnalysisInfoMixin<NoOpCGSCCAnalysis> { … }; /// No-op function pass which does nothing. struct NoOpFunctionPass : PassInfoMixin<NoOpFunctionPass> { … }; /// No-op function analysis. class NoOpFunctionAnalysis : public AnalysisInfoMixin<NoOpFunctionAnalysis> { … }; /// No-op loop nest pass which does nothing. struct NoOpLoopNestPass : PassInfoMixin<NoOpLoopNestPass> { … }; /// No-op loop pass which does nothing. struct NoOpLoopPass : PassInfoMixin<NoOpLoopPass> { … }; /// No-op machine function pass which does nothing. struct NoOpMachineFunctionPass : public PassInfoMixin<NoOpMachineFunctionPass> { … }; /// No-op loop analysis. class NoOpLoopAnalysis : public AnalysisInfoMixin<NoOpLoopAnalysis> { … }; /// Common option used by multiple tools to print pipeline passes extern cl::opt<bool> PrintPipelinePasses; } #endif