123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- #pragma once
- #ifdef __GNUC__
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wunused-parameter"
- #endif
- #ifndef LLVM_LTO_CONFIG_H
- #define LLVM_LTO_CONFIG_H
- #include "llvm/ADT/DenseSet.h"
- #include "llvm/Config/llvm-config.h"
- #include "llvm/IR/DiagnosticInfo.h"
- #include "llvm/IR/GlobalValue.h"
- #include "llvm/IR/LLVMContext.h"
- #include "llvm/IR/LegacyPassManager.h"
- #include "llvm/Passes/PassBuilder.h"
- #include "llvm/Support/CodeGen.h"
- #include "llvm/Target/TargetOptions.h"
- #include <functional>
- #include <optional>
- namespace llvm {
- class Error;
- class Module;
- class ModuleSummaryIndex;
- class raw_pwrite_stream;
- namespace lto {
- struct Config {
- enum VisScheme {
- FromPrevailing,
- ELF,
- };
-
-
- std::string CPU;
- TargetOptions Options;
- std::vector<std::string> MAttrs;
- std::vector<std::string> MllvmArgs;
- std::vector<std::string> PassPlugins;
-
- std::function<void(legacy::PassManager &)> PreCodeGenPassesHook;
- std::optional<Reloc::Model> RelocModel = Reloc::PIC_;
- std::optional<CodeModel::Model> CodeModel;
- CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default;
- CodeGenFileType CGFileType = CGFT_ObjectFile;
- unsigned OptLevel = 2;
- bool DisableVerify = false;
-
- bool UseDefaultPipeline = false;
-
-
- bool Freestanding = false;
-
- bool CodeGenOnly = false;
-
- bool RunCSIRInstr = false;
-
- bool PGOWarnMismatch = true;
-
-
- bool HasWholeProgramVisibility = false;
-
-
-
- bool AlwaysEmitRegularLTOObj = false;
-
-
-
-
- VisScheme VisibilityScheme = FromPrevailing;
-
-
-
- std::string OptPipeline;
-
-
-
- std::string AAPipeline;
-
-
- std::string OverrideTriple;
-
-
- std::string DefaultTriple;
-
- std::string CSIRProfile;
-
- std::string SampleProfile;
-
- std::string ProfileRemapping;
-
- std::string DwoDir;
-
-
-
-
- std::string SplitDwarfFile;
-
-
-
- std::string SplitDwarfOutput;
-
- std::string RemarksFilename;
-
- std::string RemarksPasses;
-
- bool RemarksWithHotness = false;
-
-
-
-
-
-
-
-
-
-
-
-
-
- std::optional<uint64_t> RemarksHotnessThreshold = 0;
-
- std::string RemarksFormat;
-
- bool DebugPassManager = false;
-
- std::string StatsFile;
-
- std::vector<std::string> ThinLTOModulesToCompile;
-
- bool TimeTraceEnabled = false;
-
- unsigned TimeTraceGranularity = 500;
- bool ShouldDiscardValueNames = true;
- DiagnosticHandlerFunction DiagHandler;
-
- bool AddFSDiscriminator = false;
-
-
- bool OpaquePointers = true;
-
-
-
-
- std::unique_ptr<raw_ostream> ResolutionFile;
-
- PipelineTuningOptions PTO;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- using ModuleHookFn = std::function<bool(unsigned Task, const Module &)>;
-
-
- ModuleHookFn PreOptModuleHook;
-
-
- ModuleHookFn PostPromoteModuleHook;
-
- ModuleHookFn PostInternalizeModuleHook;
-
- ModuleHookFn PostImportModuleHook;
-
- ModuleHookFn PostOptModuleHook;
-
-
-
- ModuleHookFn PreCodeGenModuleHook;
-
-
-
-
-
-
-
-
-
- using CombinedIndexHookFn = std::function<bool(
- const ModuleSummaryIndex &Index,
- const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols)>;
- CombinedIndexHookFn CombinedIndexHook;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Error addSaveTemps(std::string OutputFileName,
- bool UseInputModulePath = false,
- const DenseSet<StringRef> &SaveTempsArgs = {});
- };
- struct LTOLLVMDiagnosticHandler : public DiagnosticHandler {
- DiagnosticHandlerFunction *Fn;
- LTOLLVMDiagnosticHandler(DiagnosticHandlerFunction *DiagHandlerFn)
- : Fn(DiagHandlerFn) {}
- bool handleDiagnostics(const DiagnosticInfo &DI) override {
- (*Fn)(DI);
- return true;
- }
- };
- struct LTOLLVMContext : LLVMContext {
- LTOLLVMContext(const Config &C) : DiagHandler(C.DiagHandler) {
- setDiscardValueNames(C.ShouldDiscardValueNames);
- enableDebugTypeODRUniquing();
- setDiagnosticHandler(
- std::make_unique<LTOLLVMDiagnosticHandler>(&DiagHandler), true);
- setOpaquePointers(C.OpaquePointers);
- }
- DiagnosticHandlerFunction DiagHandler;
- };
- }
- }
- #endif
- #ifdef __GNUC__
- #pragma GCC diagnostic pop
- #endif
|