[LLD][MachO] Enable plugin support for LTO (#115690)
Add new CLI options for feature parity with ELF w.r.t pass plugins.
Most of the changes are ported directly from
0c86198b27.
With this change, it is now possible to load and run external pass
plugins during the LTO phase.
This commit is contained in:
@@ -166,6 +166,7 @@ struct Configuration {
|
||||
llvm::StringRef installName;
|
||||
llvm::StringRef clientName;
|
||||
llvm::StringRef mapFile;
|
||||
llvm::StringRef ltoNewPmPasses;
|
||||
llvm::StringRef ltoObjPath;
|
||||
llvm::StringRef thinLTOJobs;
|
||||
llvm::StringRef umbrella;
|
||||
@@ -239,6 +240,7 @@ struct Configuration {
|
||||
SymtabPresence localSymbolsPresence = SymtabPresence::All;
|
||||
SymbolPatterns localSymbolPatterns;
|
||||
llvm::SmallVector<llvm::StringRef, 0> mllvmOpts;
|
||||
llvm::SmallVector<llvm::StringRef, 0> passPlugins;
|
||||
|
||||
bool zeroModTime = true;
|
||||
bool generateUuid = true;
|
||||
|
||||
@@ -1741,6 +1741,7 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
|
||||
config->umbrella = arg->getValue();
|
||||
}
|
||||
config->ltoObjPath = args.getLastArgValue(OPT_object_path_lto);
|
||||
config->ltoNewPmPasses = args.getLastArgValue(OPT_lto_newpm_passes);
|
||||
config->thinLTOCacheDir = args.getLastArgValue(OPT_cache_path_lto);
|
||||
config->thinLTOCachePolicy = getLTOCachePolicy(args);
|
||||
config->thinLTOEmitImportsFiles = args.hasArg(OPT_thinlto_emit_imports_files);
|
||||
@@ -2110,6 +2111,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
|
||||
config->mllvmOpts.emplace_back(arg->getValue());
|
||||
}
|
||||
|
||||
config->passPlugins = args::getStrings(args, OPT_load_pass_plugins);
|
||||
|
||||
createSyntheticSections();
|
||||
createSyntheticSymbols();
|
||||
addSynthenticMethnames();
|
||||
|
||||
@@ -44,6 +44,9 @@ static lto::Config createConfig() {
|
||||
c.Options.EmitAddrsig = config->icfLevel == ICFLevel::safe;
|
||||
for (StringRef C : config->mllvmOpts)
|
||||
c.MllvmArgs.emplace_back(C.str());
|
||||
for (StringRef pluginFn : config->passPlugins)
|
||||
c.PassPlugins.push_back(std::string(pluginFn));
|
||||
c.OptPipeline = std::string(config->ltoNewPmPasses);
|
||||
c.CodeModel = getCodeModelFromCMModel();
|
||||
c.CPU = getCPUStr();
|
||||
c.MAttrs = getMAttrs();
|
||||
|
||||
@@ -162,6 +162,12 @@ def no_objc_category_merging : Flag<["-"], "no_objc_category_merging">,
|
||||
Group<grp_lld>;
|
||||
def lto_debug_pass_manager: Flag<["--"], "lto-debug-pass-manager">,
|
||||
HelpText<"Debug new pass manager">, Group<grp_lld>;
|
||||
def lto_newpm_passes: Joined<["--"], "lto-newpm-passes=">,
|
||||
HelpText<"Passes to run during LTO">, Group<grp_lld>;
|
||||
def load_pass_plugins : Separate<["--"], "load-pass-plugin">, Group<grp_lld>;
|
||||
def load_pass_plugins_eq : Joined<["--"], "load-pass-plugin=">,
|
||||
Alias<!cast<Separate>(load_pass_plugins)>,
|
||||
HelpText<"Load passes from plugin library">, Group<grp_lld>;
|
||||
def codegen_data_generate_path : Separate<["--"], "codegen-data-generate-path">, Group<grp_lld>;
|
||||
def codegen_data_generate_path_eq : Joined<["--"], "codegen-data-generate-path=">,
|
||||
Alias<!cast<Separate>(codegen_data_generate_path)>, MetaVarName<"<cgdata>">,
|
||||
|
||||
13
lld/test/MachO/ltopasses-extension.ll
Normal file
13
lld/test/MachO/ltopasses-extension.ll
Normal file
@@ -0,0 +1,13 @@
|
||||
; REQUIRES: x86, plugins, examples
|
||||
|
||||
; RUN: opt -module-summary %s -o %t.o
|
||||
; RUN: %lld -dylib -%loadnewpmbye --lto-newpm-passes="goodbye" -mllvm %loadbye -mllvm -wave-goodbye %t.o -o /dev/null 2>&1 | FileCheck %s
|
||||
; CHECK: Bye
|
||||
|
||||
target triple = "x86_64-apple-macosx10.15.0"
|
||||
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
@junk = global i32 0
|
||||
|
||||
define ptr @somefunk() {
|
||||
ret ptr @junk
|
||||
}
|
||||
Reference in New Issue
Block a user