diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h --- a/lld/COFF/Config.h +++ b/lld/COFF/Config.h @@ -215,6 +215,12 @@ // Used for /lto-obj-path: llvm::StringRef ltoObjPath; + // Used for /lto-cs-profile-generate: + bool ltoCSProfileGenerate = false; + + // Used for /lto-cs-profile-path + llvm::StringRef ltoCSProfileFile; + // Used for /call-graph-ordering-file: llvm::MapVector, uint64_t> diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -1712,6 +1712,8 @@ config->thinLTOObjectSuffixReplace = getOldNewOptions(args, OPT_thinlto_object_suffix_replace); config->ltoObjPath = args.getLastArgValue(OPT_lto_obj_path); + config->ltoCSProfileGenerate = args.hasArg(OPT_lto_cs_profile_generate); + config->ltoCSProfileFile = args.getLastArgValue(OPT_lto_cs_profile_file); // Handle miscellaneous boolean flags. config->allowBind = args.hasFlag(OPT_allowbind, OPT_allowbind_no, true); config->allowIsolation = diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp --- a/lld/COFF/LTO.cpp +++ b/lld/COFF/LTO.cpp @@ -84,6 +84,8 @@ c.AlwaysEmitRegularLTOObj = !config->ltoObjPath.empty(); c.UseNewPM = config->ltoNewPassManager; c.DebugPassManager = config->ltoDebugPassManager; + c.CSIRProfile = std::string(config->ltoCSProfileFile); + c.RunCSIRInstr = config->ltoCSProfileGenerate; 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 @@ -239,6 +239,10 @@ def lto_obj_path : P< "lto-obj-path", "output native object for merged LTO unit to this path">; +def lto_cs_profile_generate: F<"lto-cs-profile-generate">, + HelpText<"Perform context sensitive PGO instrumentation">; +def lto_cs_profile_file : P<"lto-cs-profile-file", + "Context sensitive profile file path">; def dash_dash_version : Flag<["--"], "version">, HelpText<"Display the version number and exit">; def threads