Skip to content

Commit 8fe7e88

Browse files
authored
[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.
1 parent 6bff2d5 commit 8fe7e88

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
; REQUIRES: plugins, examples
2+
; UNSUPPORTED: target={{.*windows.*}}
3+
4+
; RUN: not opt < %s -load-pass-plugin=%t/nonexistant.so -disable-output 2>&1 | FileCheck %s
5+
; CHECK: Could not load library {{.*}}nonexistant.so

llvm/tools/opt/opt.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "llvm/Passes/PassPlugin.h"
4040
#include "llvm/Remarks/HotnessThresholdParser.h"
4141
#include "llvm/Support/Debug.h"
42+
#include "llvm/Support/ErrorHandling.h"
4243
#include "llvm/Support/FileSystem.h"
4344
#include "llvm/Support/InitLLVM.h"
4445
#include "llvm/Support/PluginLoader.h"
@@ -440,11 +441,8 @@ int main(int argc, char **argv) {
440441
SmallVector<PassPlugin, 1> PluginList;
441442
PassPlugins.setCallback([&](const std::string &PluginPath) {
442443
auto Plugin = PassPlugin::Load(PluginPath);
443-
if (!Plugin) {
444-
errs() << "Failed to load passes from '" << PluginPath
445-
<< "'. Request ignored.\n";
446-
return;
447-
}
444+
if (!Plugin)
445+
report_fatal_error(Plugin.takeError(), /*gen_crash_diag=*/false);
448446
PluginList.emplace_back(Plugin.get());
449447
});
450448

0 commit comments

Comments
 (0)