[PATCH] D120490: lld: Enable new passmanager plugin support for LTO
Jakob via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 8 09:53:03 PST 2022
jkl updated this revision to Diff 413854.
jkl added a comment.
I fixed the styling changes suggested.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120490/new/
https://reviews.llvm.org/D120490
Files:
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/LTO.cpp
lld/ELF/Options.td
llvm/examples/Bye/Bye.cpp
llvm/test/Feature/load_extension.ll
Index: llvm/test/Feature/load_extension.ll
===================================================================
--- llvm/test/Feature/load_extension.ll
+++ llvm/test/Feature/load_extension.ll
@@ -5,6 +5,8 @@
; RUN: llvm-lto2 run %t.o %loadbye -wave-goodbye -use-new-pm=0 -o %t -r %t.o,somefunk,plx -r %t.o,junk,plx 2>&1 | FileCheck %s
; RUN: llvm-lto2 run %t.o %loadbye %loadnewpmbye -wave-goodbye -use-new-pm -o %t -r %t.o,somefunk,plx -r %t.o,junk,plx 2>&1 | FileCheck %s
; RUN: llvm-lto2 run %t.o %loadbye %loadnewpmbye -opt-pipeline="goodbye" -wave-goodbye -use-new-pm -o %t -r %t.o,somefunk,plx -r %t.o,junk,plx 2>&1 | FileCheck %s
+; RUN: ld.lld -%loadnewpmbye --lto-newpm-passes="goodbye" -mllvm=%loadbye -mllvm=-wave-goodbye %t.o 2>&1 | FileCheck %s
+; RUN: ld.lld -mllvm=%loadbye -mllvm=-wave-goodbye -plugin-opt=legacy-pass-manager %t.o 2>&1 | FileCheck %s
; REQUIRES: plugins, examples
; UNSUPPORTED: windows
; CHECK: Bye
Index: llvm/examples/Bye/Bye.cpp
===================================================================
--- llvm/examples/Bye/Bye.cpp
+++ llvm/examples/Bye/Bye.cpp
@@ -50,6 +50,11 @@
[](const llvm::PassManagerBuilder &Builder,
llvm::legacy::PassManagerBase &PM) { PM.add(new LegacyBye()); });
+static llvm::RegisterStandardPasses RegisterByeLTO(
+ llvm::PassManagerBuilder::EP_ModuleOptimizerEarly,
+ [](const llvm::PassManagerBuilder &Builder,
+ llvm::legacy::PassManagerBase &PM) { PM.add(new LegacyBye()); });
+
/* New PM Registration */
llvm::PassPluginLibraryInfo getByePluginInfo() {
return {LLVM_PLUGIN_API_VERSION, "Bye", LLVM_VERSION_STRING,
Index: lld/ELF/Options.td
===================================================================
--- lld/ELF/Options.td
+++ lld/ELF/Options.td
@@ -714,3 +714,5 @@
"Perform additional validation of the written dynamic relocations",
"Do not perform additional validation of the written dynamic relocations">,
Flags<[HelpHidden]>;
+
+defm load_pass_plugins: Eq<"load-pass-plugin", "Load passes from plugin library">;
Index: lld/ELF/LTO.cpp
===================================================================
--- lld/ELF/LTO.cpp
+++ lld/ELF/LTO.cpp
@@ -144,6 +144,8 @@
c.SampleProfile = std::string(config->ltoSampleProfile);
c.UseNewPM = config->ltoNewPassManager;
+ for (llvm::StringRef &PluginFN : config->PassPlugins)
+ c.PassPlugins.push_back(std::string(PluginFN));
c.DebugPassManager = config->ltoDebugPassManager;
c.DwoDir = std::string(config->dwoDir);
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1252,6 +1252,8 @@
error(arg->getSpelling() + ": unknown plugin option '" + arg->getValue() +
"'");
+ config->PassPlugins = args::getStrings(args, OPT_load_pass_plugins);
+
// Parse -mllvm options.
for (auto *arg : args.filtered(OPT_mllvm))
parseClangOption(arg->getValue(), arg->getSpelling());
Index: lld/ELF/Config.h
===================================================================
--- lld/ELF/Config.h
+++ lld/ELF/Config.h
@@ -144,6 +144,7 @@
std::vector<llvm::StringRef> undefined;
std::vector<SymbolVersion> dynamicList;
std::vector<uint8_t> buildIdVector;
+ std::vector<llvm::StringRef> PassPlugins;
llvm::MapVector<std::pair<const InputSectionBase *, const InputSectionBase *>,
uint64_t>
callGraphProfile;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120490.413854.patch
Type: text/x-patch
Size: 3439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220308/0f76166c/attachment.bin>
More information about the llvm-commits
mailing list