[llvm] 8fe7e88 - [opt] Properly report errors when loading pass plugins (#69745)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 23 09:55:33 PDT 2023
Author: Arthur Eubanks
Date: 2023-10-23T09:55:29-07:00
New Revision: 8fe7e8838649fb285c2313f66d0d52909536e338
URL: https://github.com/llvm/llvm-project/commit/8fe7e8838649fb285c2313f66d0d52909536e338
DIFF: https://github.com/llvm/llvm-project/commit/8fe7e8838649fb285c2313f66d0d52909536e338.diff
LOG: [opt] Properly report errors when loading pass plugins (#69745)
All error messages here already contain the path to the plugin, so no
need to repeat it in opt.cpp.
Added:
llvm/test/Feature/load_plugin_error.ll
Modified:
llvm/tools/opt/opt.cpp
Removed:
################################################################################
diff --git a/llvm/test/Feature/load_plugin_error.ll b/llvm/test/Feature/load_plugin_error.ll
new file mode 100644
index 000000000000000..24a7cce5d8d397e
--- /dev/null
+++ b/llvm/test/Feature/load_plugin_error.ll
@@ -0,0 +1,5 @@
+; REQUIRES: plugins, examples
+; UNSUPPORTED: target={{.*windows.*}}
+
+; RUN: not opt < %s -load-pass-plugin=%t/nonexistant.so -disable-output 2>&1 | FileCheck %s
+; CHECK: Could not load library {{.*}}nonexistant.so
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 52c8c17ea4b46de..5f415e50d20f2c7 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -39,6 +39,7 @@
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Remarks/HotnessThresholdParser.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/PluginLoader.h"
@@ -440,11 +441,8 @@ int main(int argc, char **argv) {
SmallVector<PassPlugin, 1> PluginList;
PassPlugins.setCallback([&](const std::string &PluginPath) {
auto Plugin = PassPlugin::Load(PluginPath);
- if (!Plugin) {
- errs() << "Failed to load passes from '" << PluginPath
- << "'. Request ignored.\n";
- return;
- }
+ if (!Plugin)
+ report_fatal_error(Plugin.takeError(), /*gen_crash_diag=*/false);
PluginList.emplace_back(Plugin.get());
});
More information about the llvm-commits
mailing list