[PATCH] D77704: [LTO][gold] Add support for loading pass plugins
Dominic Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 22:50:09 PDT 2020
ddcc updated this revision to Diff 257598.
ddcc added a comment.
Herald added a subscriber: mgorny.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77704/new/
https://reviews.llvm.org/D77704
Files:
llvm/tools/gold/CMakeLists.txt
llvm/tools/gold/gold-plugin.cpp
Index: llvm/tools/gold/gold-plugin.cpp
===================================================================
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -23,6 +23,7 @@
#include "llvm/Object/Error.h"
#include "llvm/Support/CachePruning.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -207,6 +208,8 @@
static std::string stats_file;
// Asserts that LTO link has whole program visibility
static bool whole_program_visibility = false;
+ // List of new PM pass plugins
+ static std::vector<std::string> pass_plugins;
// Optimization remarks filename, accepted passes and hotness options
static std::string RemarksFilename;
@@ -306,6 +309,14 @@
RemarksFormat = std::string(opt.substr(strlen("opt-remarks-format=")));
} else if (opt.startswith("stats-file=")) {
stats_file = std::string(opt.substr(strlen("stats-file=")));
+ } else if (opt.startswith("load=")) {
+ std::string Error, Path(opt.substr(strlen("load=")));
+
+ if (sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
+ message(LDPL_ERROR, "Unable to load plugin: %s", Error.c_str());
+ } else if (opt.startswith("load-pass-plugin=")) {
+ pass_plugins.push_back(
+ std::string(opt.substr(strlen("load-pass-plugin="))));
} else {
// Save this option to pass to the code generator.
// ParseCommandLineOptions() expects argv[0] to be program name. Lazily
@@ -941,6 +952,8 @@
Conf.UseNewPM = options::new_pass_manager;
// Debug new pass manager if requested
Conf.DebugPassManager = options::debug_pass_manager;
+ // Pass plugins to load
+ Conf.PassPlugins = std::move(options::pass_plugins);
Conf.HasWholeProgramVisibility = options::whole_program_visibility;
Index: llvm/tools/gold/CMakeLists.txt
===================================================================
--- llvm/tools/gold/CMakeLists.txt
+++ llvm/tools/gold/CMakeLists.txt
@@ -13,6 +13,9 @@
add_llvm_library(LLVMgold MODULE
gold-plugin.cpp
+
+ ENABLE_PLUGINS
)
+ export_executable_symbols_for_plugins(LLVMgold)
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77704.257598.patch
Type: text/x-patch
Size: 2270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200415/62a90d75/attachment-0001.bin>
More information about the llvm-commits
mailing list