Skip to content

Commit 4f9c61e

Browse files
yolanda15phoebewang
authored andcommitted
[lld] add context-sensitive PGO options for COFF.
Add lld CSPGO (Contex-Sensitive PGO) options for COFF target. Reference the ELF options from https://reviews.llvm.org/D56675 Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D98763
1 parent 3f143a1 commit 4f9c61e

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

lld/COFF/Config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ struct Configuration {
215215
// Used for /lto-obj-path:
216216
llvm::StringRef ltoObjPath;
217217

218+
// Used for /lto-cs-profile-generate:
219+
bool ltoCSProfileGenerate = false;
220+
221+
// Used for /lto-cs-profile-path
222+
llvm::StringRef ltoCSProfileFile;
223+
218224
// Used for /call-graph-ordering-file:
219225
llvm::MapVector<std::pair<const SectionChunk *, const SectionChunk *>,
220226
uint64_t>

lld/COFF/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
17121712
config->thinLTOObjectSuffixReplace =
17131713
getOldNewOptions(args, OPT_thinlto_object_suffix_replace);
17141714
config->ltoObjPath = args.getLastArgValue(OPT_lto_obj_path);
1715+
config->ltoCSProfileGenerate = args.hasArg(OPT_lto_cs_profile_generate);
1716+
config->ltoCSProfileFile = args.getLastArgValue(OPT_lto_cs_profile_file);
17151717
// Handle miscellaneous boolean flags.
17161718
config->allowBind = args.hasFlag(OPT_allowbind, OPT_allowbind_no, true);
17171719
config->allowIsolation =

lld/COFF/LTO.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ static lto::Config createConfig() {
8484
c.AlwaysEmitRegularLTOObj = !config->ltoObjPath.empty();
8585
c.UseNewPM = config->ltoNewPassManager;
8686
c.DebugPassManager = config->ltoDebugPassManager;
87+
c.CSIRProfile = std::string(config->ltoCSProfileFile);
88+
c.RunCSIRInstr = config->ltoCSProfileGenerate;
8789

8890
if (config->saveTemps)
8991
checkError(c.addSaveTemps(std::string(config->outputFile) + ".",

lld/COFF/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ def thinlto_prefix_replace: P<
239239
def lto_obj_path : P<
240240
"lto-obj-path",
241241
"output native object for merged LTO unit to this path">;
242+
def lto_cs_profile_generate: F<"lto-cs-profile-generate">,
243+
HelpText<"Perform context sensitive PGO instrumentation">;
244+
def lto_cs_profile_file : P<"lto-cs-profile-file",
245+
"Context sensitive profile file path">;
242246
def dash_dash_version : Flag<["--"], "version">,
243247
HelpText<"Display the version number and exit">;
244248
def threads

0 commit comments

Comments
 (0)