86 lines · c
1//===- NewPMDriver.h - Function to drive opt with the new PM ----*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8/// \file9///10/// A single function which is called to drive the opt behavior for the new11/// PassManager.12///13/// This is only in a separate TU with a header to avoid including all of the14/// old pass manager headers and the new pass manager headers into the same15/// file. Eventually all of the routines here will get folded back into16/// opt.cpp.17///18//===----------------------------------------------------------------------===//19 20#ifndef LLVM_TOOLS_OPT_NEWPMDRIVER_H21#define LLVM_TOOLS_OPT_NEWPMDRIVER_H22 23#include "llvm/Support/CommandLine.h"24 25namespace llvm {26class PassBuilder;27class StringRef;28class Module;29class PassPlugin;30class TargetMachine;31class ToolOutputFile;32class TargetLibraryInfoImpl;33 34namespace RTLIB {35struct RuntimeLibcallsInfo;36}37 38extern cl::opt<bool> DebugifyEach;39extern cl::opt<std::string> DebugifyExport;40 41extern cl::opt<bool> VerifyEachDebugInfoPreserve;42extern cl::opt<std::string> VerifyDIPreserveExport;43 44namespace opt_tool {45enum OutputKind {46 OK_NoOutput,47 OK_OutputAssembly,48 OK_OutputBitcode,49 OK_OutputThinLTOBitcode,50};51enum class VerifierKind { None, InputOutput, EachPass };52enum PGOKind {53 NoPGO,54 InstrGen,55 InstrUse,56 SampleUse57};58enum CSPGOKind { NoCSPGO, CSInstrGen, CSInstrUse };59} // namespace opt_tool60 61void printPasses(raw_ostream &OS);62 63/// Driver function to run the new pass manager over a module.64///65/// This function only exists factored away from opt.cpp in order to prevent66/// inclusion of the new pass manager headers and the old headers into the same67/// file. It's interface is consequentially somewhat ad-hoc, but will go away68/// when the transition finishes.69///70/// ThinLTOLinkOut is only used when OK is OK_OutputThinLTOBitcode, and can be71/// nullptr.72bool runPassPipeline(73 StringRef Arg0, Module &M, TargetMachine *TM, TargetLibraryInfoImpl *TLII,74 RTLIB::RuntimeLibcallsInfo &RTLCI, ToolOutputFile *Out,75 ToolOutputFile *ThinLinkOut, ToolOutputFile *OptRemarkFile,76 StringRef PassPipeline, ArrayRef<PassPlugin> PassPlugins,77 ArrayRef<std::function<void(PassBuilder &)>> PassBuilderCallbacks,78 opt_tool::OutputKind OK, opt_tool::VerifierKind VK,79 bool ShouldPreserveAssemblyUseListOrder,80 bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex,81 bool EmitModuleHash, bool EnableDebugify, bool VerifyDIPreserve,82 bool EnableProfcheck, bool UnifiedLTO = false);83} // namespace llvm84 85#endif86