Index: lld/ELF/Config.h =================================================================== --- lld/ELF/Config.h +++ lld/ELF/Config.h @@ -85,6 +85,7 @@ llvm::StringRef Init; llvm::StringRef LTOAAPipeline; llvm::StringRef LTONewPmPasses; + llvm::StringRef LTOSampleProfile; llvm::StringRef MapFile; llvm::StringRef OutputFile; llvm::StringRef OptRemarksFilename; @@ -131,6 +132,7 @@ bool ICF; bool IgnoreDataAddressEquality; bool IgnoreFunctionAddressEquality; + bool LTONewPassManager = false; bool MergeArmExidx; bool MipsN32Abi = false; bool NoinhibitExec; Index: lld/ELF/Driver.cpp =================================================================== --- lld/ELF/Driver.cpp +++ lld/ELF/Driver.cpp @@ -657,6 +657,9 @@ Args.hasArg(OPT_ignore_function_address_equality); Config->Init = Args.getLastArgValue(OPT_init, "_init"); Config->LTOAAPipeline = Args.getLastArgValue(OPT_lto_aa_pipeline); + Config->LTOSampleProfile = Args.getLastArgValue(OPT_lto_sample_profile); + Config->LTONewPassManager = + Args.hasFlag(OPT_lto_new_pass_manager, OPT_lto_new_pass_manager, false); Config->LTONewPmPasses = Args.getLastArgValue(OPT_lto_newpm_passes); Config->LTOO = args::getInteger(Args, OPT_lto_O, 2); Config->LTOPartitions = args::getInteger(Args, OPT_lto_partitions, 1); @@ -734,6 +737,10 @@ Config->ThinLTOJobs = parseInt(S.substr(5), Arg); else if (S.startswith("mcpu=")) parseClangOption(Saver.save("-" + S), Arg->getSpelling()); + else if (S.startswith("sample-profile=")) + Config->LTOSampleProfile = S.substr(strlen("sample-profile=")); + else if (S == "new-pass-manager") + Config->LTONewPassManager = true; else if (!S.startswith("/") && !S.startswith("-fresolution=") && !S.startswith("-pass-through=") && !S.startswith("thinlto")) parseClangOption(S, Arg->getSpelling()); Index: lld/ELF/LTO.cpp =================================================================== --- lld/ELF/LTO.cpp +++ lld/ELF/LTO.cpp @@ -104,6 +104,13 @@ lto::ThinBackend Backend; if (Config->ThinLTOJobs != -1u) Backend = lto::createInProcessThinBackend(Config->ThinLTOJobs); + + if (!Config->LTOSampleProfile.empty()) + Conf.SampleProfile = Config->LTOSampleProfile; + + // Use new pass manager if set in driver + Conf.UseNewPM = Config->LTONewPassManager; + return llvm::make_unique(std::move(Conf), Backend, Config->LTOPartitions); } Index: lld/ELF/Options.td =================================================================== --- lld/ELF/Options.td +++ lld/ELF/Options.td @@ -394,10 +394,14 @@ // LTO-related options. def lto_aa_pipeline: J<"lto-aa-pipeline=">, HelpText<"AA pipeline to run during LTO. Used in conjunction with -lto-newpm-passes">; +def lto_new_pass_manager: F<"lto-new-pass-manager">, + HelpText<"New pass manager">; def lto_newpm_passes: J<"lto-newpm-passes=">, HelpText<"Passes to run during LTO">; def lto_partitions: J<"lto-partitions=">, HelpText<"Number of LTO codegen partitions">; +def lto_sample_profile: J<"lto-sample-profile=">, + HelpText<"Sample profile file path">; def disable_verify: F<"disable-verify">; defm mllvm: Eq<"mllvm">; def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,