#include "NewPMDriver.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IRPrinter/IRPrintingPasses.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Utils/Debugify.h"
usingnamespacellvm;
usingnamespaceopt_tool;
namespace llvm {
cl::opt<bool> DebugifyEach(
"debugify-each",
cl::desc("Start each pass with debugify and end it with check-debugify"));
cl::opt<std::string>
DebugifyExport("debugify-export",
cl::desc("Export per-pass debugify statistics to this file"),
cl::value_desc("filename"));
cl::opt<bool> VerifyEachDebugInfoPreserve(
"verify-each-debuginfo-preserve",
cl::desc("Start each pass with collecting and end it with checking of "
"debug info preservation."));
cl::opt<std::string>
VerifyDIPreserveExport("verify-di-preserve-export",
cl::desc("Export debug info preservation failures into "
"specified (JSON) file (should be abs path as we use"
" append mode to insert new JSON objects)"),
cl::value_desc("filename"), cl::init(""));
}
enum class DebugLogging { … };
static cl::opt<DebugLogging> DebugPM(
"debug-pass-manager", cl::Hidden, cl::ValueOptional,
cl::desc("Print pass management debugging information"),
cl::init(DebugLogging::None),
cl::values(
clEnumValN(DebugLogging::Normal, "", ""),
clEnumValN(DebugLogging::Quiet, "quiet",
"Skip printing info about analyses"),
clEnumValN(
DebugLogging::Verbose, "verbose",
"Print extra information about adaptors and pass managers")));
static cl::opt<std::string>
AAPipeline("aa-pipeline",
cl::desc("A textual description of the alias analysis "
"pipeline for handling managed aliasing queries"),
cl::Hidden, cl::init("default"));
static cl::opt<std::string> PeepholeEPPipeline(
"passes-ep-peephole",
cl::desc("A textual description of the function pass pipeline inserted at "
"the Peephole extension points into default pipelines"),
cl::Hidden);
static cl::opt<std::string> LateLoopOptimizationsEPPipeline(
"passes-ep-late-loop-optimizations",
cl::desc(
"A textual description of the loop pass pipeline inserted at "
"the LateLoopOptimizations extension point into default pipelines"),
cl::Hidden);
static cl::opt<std::string> LoopOptimizerEndEPPipeline(
"passes-ep-loop-optimizer-end",
cl::desc("A textual description of the loop pass pipeline inserted at "
"the LoopOptimizerEnd extension point into default pipelines"),
cl::Hidden);
static cl::opt<std::string> ScalarOptimizerLateEPPipeline(
"passes-ep-scalar-optimizer-late",
cl::desc("A textual description of the function pass pipeline inserted at "
"the ScalarOptimizerLate extension point into default pipelines"),
cl::Hidden);
static cl::opt<std::string> CGSCCOptimizerLateEPPipeline(
"passes-ep-cgscc-optimizer-late",
cl::desc("A textual description of the cgscc pass pipeline inserted at "
"the CGSCCOptimizerLate extension point into default pipelines"),
cl::Hidden);
static cl::opt<std::string> VectorizerStartEPPipeline(
"passes-ep-vectorizer-start",
cl::desc("A textual description of the function pass pipeline inserted at "
"the VectorizerStart extension point into default pipelines"),
cl::Hidden);
static cl::opt<std::string> PipelineStartEPPipeline(
"passes-ep-pipeline-start",
cl::desc("A textual description of the module pass pipeline inserted at "
"the PipelineStart extension point into default pipelines"),
cl::Hidden);
static cl::opt<std::string> PipelineEarlySimplificationEPPipeline(
"passes-ep-pipeline-early-simplification",
cl::desc("A textual description of the module pass pipeline inserted at "
"the EarlySimplification extension point into default pipelines"),
cl::Hidden);
static cl::opt<std::string> OptimizerEarlyEPPipeline(
"passes-ep-optimizer-early",
cl::desc("A textual description of the module pass pipeline inserted at "
"the OptimizerEarly extension point into default pipelines"),
cl::Hidden);
static cl::opt<std::string> OptimizerLastEPPipeline(
"passes-ep-optimizer-last",
cl::desc("A textual description of the module pass pipeline inserted at "
"the OptimizerLast extension point into default pipelines"),
cl::Hidden);
static cl::opt<std::string> FullLinkTimeOptimizationEarlyEPPipeline(
"passes-ep-full-link-time-optimization-early",
cl::desc("A textual description of the module pass pipeline inserted at "
"the FullLinkTimeOptimizationEarly extension point into default "
"pipelines"),
cl::Hidden);
static cl::opt<std::string> FullLinkTimeOptimizationLastEPPipeline(
"passes-ep-full-link-time-optimization-last",
cl::desc("A textual description of the module pass pipeline inserted at "
"the FullLinkTimeOptimizationLast extension point into default "
"pipelines"),
cl::Hidden);
static cl::opt<bool> DisablePipelineVerification(
"disable-pipeline-verification",
cl::desc("Only has an effect when specified with -print-pipeline-passes. "
"Disables verifying that the textual pipeline generated by "
"-print-pipeline-passes can be used to create a pipeline."),
cl::Hidden);
static cl::opt<PGOKind>
PGOKindFlag("pgo-kind", cl::init(NoPGO), cl::Hidden,
cl::desc("The kind of profile guided optimization"),
cl::values(clEnumValN(NoPGO, "nopgo", "Do not use PGO."),
clEnumValN(InstrGen, "pgo-instr-gen-pipeline",
"Instrument the IR to generate profile."),
clEnumValN(InstrUse, "pgo-instr-use-pipeline",
"Use instrumented profile to guide PGO."),
clEnumValN(SampleUse, "pgo-sample-use-pipeline",
"Use sampled profile to guide PGO.")));
static cl::opt<std::string> ProfileFile("profile-file",
cl::desc("Path to the profile."), cl::Hidden);
static cl::opt<std::string>
MemoryProfileFile("memory-profile-file",
cl::desc("Path to the memory profile."), cl::Hidden);
static cl::opt<CSPGOKind> CSPGOKindFlag(
"cspgo-kind", cl::init(NoCSPGO), cl::Hidden,
cl::desc("The kind of context sensitive profile guided optimization"),
cl::values(
clEnumValN(NoCSPGO, "nocspgo", "Do not use CSPGO."),
clEnumValN(
CSInstrGen, "cspgo-instr-gen-pipeline",
"Instrument (context sensitive) the IR to generate profile."),
clEnumValN(
CSInstrUse, "cspgo-instr-use-pipeline",
"Use instrumented (context sensitive) profile to guide PGO.")));
static cl::opt<std::string> CSProfileGenFile(
"cs-profilegen-file",
cl::desc("Path to the instrumented context sensitive profile."),
cl::Hidden);
static cl::opt<std::string>
ProfileRemappingFile("profile-remapping-file",
cl::desc("Path to the profile remapping file."),
cl::Hidden);
static cl::opt<PGOOptions::ColdFuncOpt> PGOColdFuncAttr(
"pgo-cold-func-opt", cl::init(PGOOptions::ColdFuncOpt::Default), cl::Hidden,
cl::desc(
"Function attribute to apply to cold functions as determined by PGO"),
cl::values(clEnumValN(PGOOptions::ColdFuncOpt::Default, "default",
"Default (no attribute)"),
clEnumValN(PGOOptions::ColdFuncOpt::OptSize, "optsize",
"Mark cold functions with optsize."),
clEnumValN(PGOOptions::ColdFuncOpt::MinSize, "minsize",
"Mark cold functions with minsize."),
clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
"Mark cold functions with optnone.")));
static cl::opt<bool> DebugInfoForProfiling(
"debug-info-for-profiling", cl::init(false), cl::Hidden,
cl::desc("Emit special debug info to enable PGO profile generation."));
static cl::opt<bool> PseudoProbeForProfiling(
"pseudo-probe-for-profiling", cl::init(false), cl::Hidden,
cl::desc("Emit pseudo probes to enable PGO profile generation."));
static cl::opt<bool> DisableLoopUnrolling(
"disable-loop-unrolling",
cl::desc("Disable loop unrolling in all relevant passes"), cl::init(false));
template <typename PassManagerT>
bool tryParsePipelineText(PassBuilder &PB,
const cl::opt<std::string> &PipelineOpt) { … }
static void registerEPCallbacks(PassBuilder &PB) { … }
#define HANDLE_EXTENSION …
#include "llvm/Support/Extension.def"
bool llvm::runPassPipeline(
StringRef Arg0, Module &M, TargetMachine *TM, TargetLibraryInfoImpl *TLII,
ToolOutputFile *Out, ToolOutputFile *ThinLTOLinkOut,
ToolOutputFile *OptRemarkFile, StringRef PassPipeline,
ArrayRef<PassPlugin> PassPlugins,
ArrayRef<std::function<void(llvm::PassBuilder &)>> PassBuilderCallbacks,
OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,
bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,
bool UnifiedLTO) { … }
void llvm::printPasses(raw_ostream &OS) { … }