Index: lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -454,6 +454,14 @@ CmdArgs.push_back( Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + FName)); } + + // Need this flag to turn on new pass manager via Gold plugin. + if (Args.hasFlag(options::OPT_fexperimental_new_pass_manager, + options::OPT_fno_experimental_new_pass_manager, + /* Default */ false)) { + CmdArgs.push_back("-plugin-opt=new-pass-manager"); + } + } void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args, Index: tools/gold/gold-plugin.cpp =================================================================== --- tools/gold/gold-plugin.cpp +++ tools/gold/gold-plugin.cpp @@ -183,6 +183,8 @@ static std::vector extra; // Sample profile file path static std::string sample_profile; + // New pass manager + static bool new_pass_manager = false; static void process_plugin_option(const char *opt_) { @@ -242,6 +244,8 @@ DisableVerify = true; } else if (opt.startswith("sample-profile=")) { sample_profile= opt.substr(strlen("sample-profile=")); + } else if (opt == "new-pass-manager") { + new_pass_manager = true; } else { // Save this option to pass to the code generator. // ParseCommandLineOptions() expects argv[0] to be program name. Lazily @@ -810,6 +814,9 @@ if (!options::sample_profile.empty()) Conf.SampleProfile = options::sample_profile; + // Use new pass manager if set in driver + Conf.UseNewPM = options::new_pass_manager; + return llvm::make_unique(std::move(Conf), Backend, options::ParallelCodeGenParallelismLevel); }