Index: ELF/Config.h =================================================================== --- ELF/Config.h +++ ELF/Config.h @@ -92,6 +92,7 @@ llvm::StringRef Fini; llvm::StringRef Init; llvm::StringRef LTOAAPipeline; + llvm::StringRef LTOCSProfileFile; llvm::StringRef LTONewPmPasses; llvm::StringRef LTOObjPath; llvm::StringRef LTOSampleProfile; @@ -150,6 +151,7 @@ bool HasDynSymTab; bool IgnoreDataAddressEquality; bool IgnoreFunctionAddressEquality; + bool LTOCSPGOGen = false; bool LTODebugPassManager; bool LTONewPassManager; bool MergeArmExidx; Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -798,6 +798,8 @@ Args.hasArg(OPT_ignore_function_address_equality); Config->Init = Args.getLastArgValue(OPT_init, "_init"); Config->LTOAAPipeline = Args.getLastArgValue(OPT_lto_aa_pipeline); + Config->LTOCSProfileFile = Args.getLastArgValue(OPT_lto_cs_profile_file); + Config->LTOCSPGOGen = Args.hasArg(OPT_lto_cs_pgo_gen); Config->LTODebugPassManager = Args.hasArg(OPT_lto_debug_pass_manager); Config->LTONewPassManager = Args.hasArg(OPT_lto_new_pass_manager); Config->LTONewPmPasses = Args.getLastArgValue(OPT_lto_newpm_passes); Index: ELF/LTO.cpp =================================================================== --- ELF/LTO.cpp +++ ELF/LTO.cpp @@ -103,6 +103,9 @@ C.DebugPassManager = Config->LTODebugPassManager; C.DwoDir = Config->DwoDir; + C.CSIRProfile = Config->LTOCSProfileFile; + C.RunCSIRInstr = Config->LTOCSPGOGen; + if (Config->EmitLLVM) { C.PostInternalizeModuleHook = [](size_t Task, const Module &M) { if (std::unique_ptr OS = openFile(Config->OutputFile)) Index: ELF/Options.td =================================================================== --- ELF/Options.td +++ ELF/Options.td @@ -437,6 +437,10 @@ HelpText<"Optimization level for LTO">; def lto_partitions: J<"lto-partitions=">, HelpText<"Number of LTO codegen partitions">; +def lto_cs_pgo_gen: F<"lto-cs-pgo-gen">, + HelpText<"Perform context senstive PGO instrumentation">; +def lto_cs_profile_file: J<"lto-cs-profile-file=">, + HelpText<"Context sensitive profile file path">; def lto_sample_profile: J<"lto-sample-profile=">, HelpText<"Sample profile file path">; def disable_verify: F<"disable-verify">; @@ -465,6 +469,10 @@ def: F<"plugin-opt=new-pass-manager">, Alias, HelpText<"Alias for -lto-new-pass-manager">; def plugin_opt_obj_path_eq: J<"plugin-opt=obj-path=">; +def: F<"plugin-opt=cs-profile-generate">, + Alias, HelpText<"Alias for -lto-cs-pgo-gen">; +def: J<"plugin-opt=cs-profile-path=">, + Alias, HelpText<"Alias for -lto-cs-profile-file">; def: J<"plugin-opt=sample-profile=">, Alias, HelpText<"Alias for -lto-sample-profile">; def: F<"plugin-opt=save-temps">, Alias, HelpText<"Alias for -save-temps">;