Skip to content

Commit 3135e1d

Browse files
committed
[MachO] Enable new passmanager plugin support for LTO
1 parent 6aa845f commit 3135e1d

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

lld/MachO/Config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ struct Configuration {
214214
bool pgoWarnMismatch;
215215
bool warnThinArchiveMissingMembers;
216216

217+
llvm::SmallVector<llvm::StringRef, 0> passPlugins;
218+
llvm::StringRef ltoNewPmPasses;
219+
217220
bool callGraphProfileSort = false;
218221
llvm::StringRef printSymbolOrder;
219222

lld/MachO/Driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,9 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
17501750
OPT_no_warn_thin_archive_missing_members, true);
17511751
config->generateUuid = !args.hasArg(OPT_no_uuid);
17521752

1753+
config->passPlugins = args::getStrings(args, OPT_load_pass_plugins);
1754+
config->ltoNewPmPasses = args.getLastArgValue(OPT_lto_newpm_passes);
1755+
17531756
for (const Arg *arg : args.filtered(OPT_alias)) {
17541757
config->aliasedSymbols.push_back(
17551758
std::make_pair(arg->getValue(0), arg->getValue(1)));

lld/MachO/LTO.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ static lto::Config createConfig() {
6262
c.PGOWarnMismatch = config->pgoWarnMismatch;
6363
c.OptLevel = config->ltoo;
6464
c.CGOptLevel = config->ltoCgo;
65+
66+
for (StringRef pluginFn : config->passPlugins)
67+
c.PassPlugins.push_back(std::string(pluginFn));
68+
69+
// Set up a custom pipeline if we've been asked to.
70+
c.OptPipeline = std::string(config->ltoNewPmPasses);
71+
6572
if (config->saveTemps)
6673
checkError(c.addSaveTemps(config->outputFile.str() + ".",
6774
/*UseInputModulePath=*/true));

lld/MachO/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ defm pgo_warn_mismatch: BB<"pgo-warn-mismatch",
156156
defm warn_thin_archive_missing_members : BB<"warn-thin-archive-missing-members",
157157
"Warn on missing object files referenced by thin archives (default)",
158158
"Do not warn on missing object files referenced by thin archives">, Group<grp_lld>;
159+
def load_pass_plugins: Flag<["--"], "load-pass-plugin=">,
160+
HelpText<"Load passes from plugin library">,
161+
Group<grp_lld>;
162+
def lto_newpm_passes: Flag<["--"], "lto-newpm-passes=">,
163+
HelpText<"Passes to run during LTO">,
164+
Group<grp_lld>;
159165

160166
// This is a complete Options.td compiled from Apple's ld(1) manpage
161167
// dated 2018-03-07 and cross checked with ld64 source code in repo

0 commit comments

Comments
 (0)