diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h --- a/lld/COFF/Config.h +++ b/lld/COFF/Config.h @@ -289,6 +289,9 @@ bool autoImport = false; bool pseudoRelocs = false; bool stdcallFixup = false; + + llvm::StringRef ltoNewPmPasses; + llvm::SmallVector passPlugins; }; extern std::unique_ptr config; diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -1919,6 +1919,9 @@ args.hasFlag(OPT_stdcall_fixup, OPT_stdcall_fixup_no, config->mingw); config->warnStdcallFixup = !args.hasArg(OPT_stdcall_fixup); + config->ltoNewPmPasses = args.getLastArgValue(OPT_lto_newpm_passes); + config->passPlugins = args::getStrings(args, OPT_load_pass_plugins); + // Don't warn about long section names, such as .debug_info, for mingw or // when -debug:dwarf is requested. if (config->mingw || config->debugDwarf) diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp --- a/lld/COFF/LTO.cpp +++ b/lld/COFF/LTO.cpp @@ -93,6 +93,10 @@ c.CSIRProfile = std::string(config->ltoCSProfileFile); c.RunCSIRInstr = config->ltoCSProfileGenerate; c.PGOWarnMismatch = config->ltoPGOWarnMismatch; + c.OptPipeline = std::string(config->ltoNewPmPasses); + + for (StringRef pluginFn : config->passPlugins) + c.PassPlugins.push_back(std::string(pluginFn)); if (config->saveTemps) checkError(c.addSaveTemps(std::string(config->outputFile) + ".", diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td --- a/lld/COFF/Options.td +++ b/lld/COFF/Options.td @@ -282,6 +282,9 @@ def vfsoverlay : P<"vfsoverlay", "Path to a vfsoverlay yaml file to optionally look for /defaultlib's in">; +def lto_newpm_passes: P<"lto-newpm-passes", "Passes to run during LTO">; +def load_pass_plugins: P<"load-pass-plugin", "Load passes from plugin library">; + // Flags for debugging def lldmap : F<"lldmap">; def lldmap_file : P_priv<"lldmap">;