aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny.ornl@gmail.com>2024-06-26 14:51:24 -0400
committerGitHub <noreply@github.com>2024-06-26 14:51:24 -0400
commitd29fdfbc4e3b42e9ee0295049493ba7b1471772f (patch)
treed3835593f85b5f70c9081631cce99acf0097fc60 /llvm/lib
parent3f78d89a2e6170d206a6b91a93b3fdf5e46ab6db (diff)
downloadllvm-d29fdfbc4e3b42e9ee0295049493ba7b1471772f.zip
llvm-d29fdfbc4e3b42e9ee0295049493ba7b1471772f.tar.gz
llvm-d29fdfbc4e3b42e9ee0295049493ba7b1471772f.tar.bz2
[LTO] Avoid assert fail on failed pass plugin load (#96691)
Without this patch, passing -load-pass-plugin=nonexistent.so to llvm-lto2 produces a backtrace because LTOBackend.cpp does not handle the error correctly: ``` Failed to load passes from 'nonexistant.so'. Request ignored. Expected<T> must be checked before access or destruction. Unchecked Expected<T> contained error: Could not load library 'nonexistant.so': nonexistant.so: cannot open shared object file: No such file or directoryPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. ``` Any tool using `lto::Config::PassPlugins` should suffer similarly. Based on the message "Request ignored" and the continue statement, the intention was apparently to continue on failure to load a plugin. However, no one appears to rely on that behavior now given that it crashes instead, and terminating is consistent with opt.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 84a69d9..d5d642f 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -191,12 +191,8 @@ static void RegisterPassPlugins(ArrayRef<std::string> PassPlugins,
// Load requested pass plugins and let them register pass builder callbacks
for (auto &PluginFN : PassPlugins) {
auto PassPlugin = PassPlugin::Load(PluginFN);
- if (!PassPlugin) {
- errs() << "Failed to load passes from '" << PluginFN
- << "'. Request ignored.\n";
- continue;
- }
-
+ if (!PassPlugin)
+ report_fatal_error(PassPlugin.takeError(), /*gen_crash_diag=*/false);
PassPlugin->registerPassBuilderCallbacks(PB);
}
}