[llvm] ed4c03a - Revert "Load pass plugins during option processing, so that plugin options are registered and live."
Wael Yehia via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 15 06:03:24 PDT 2022
Author: Wael Yehia
Date: 2022-03-15T13:02:37Z
New Revision: ed4c03afac914ce12757c159bf74f9076a4a6514
URL: https://github.com/llvm/llvm-project/commit/ed4c03afac914ce12757c159bf74f9076a4a6514
DIFF: https://github.com/llvm/llvm-project/commit/ed4c03afac914ce12757c159bf74f9076a4a6514.diff
LOG: Revert "Load pass plugins during option processing, so that plugin options are registered and live."
This reverts commit 5e8700ce8bf58bdf0a59eef99c85185a74177555.
Added:
Modified:
llvm/test/Feature/load_extension.ll
llvm/tools/opt/NewPMDriver.cpp
llvm/tools/opt/NewPMDriver.h
llvm/tools/opt/opt.cpp
Removed:
################################################################################
diff --git a/llvm/test/Feature/load_extension.ll b/llvm/test/Feature/load_extension.ll
index 18f6775fbb4a1..2e1080ceaf97c 100644
--- a/llvm/test/Feature/load_extension.ll
+++ b/llvm/test/Feature/load_extension.ll
@@ -1,7 +1,6 @@
; REQUIRES: x86-registered-target
; RUN: opt %s %loadbye -goodbye -wave-goodbye -disable-output -enable-new-pm=0 2>&1 | FileCheck %s
; RUN: opt %s %loadnewpmbye %loadbye -passes="goodbye" -wave-goodbye -disable-output 2>&1 | FileCheck %s
-; RUN: opt %s %loadnewpmbye -passes="goodbye" -wave-goodbye -disable-output 2>&1 | FileCheck %s
; RUN: opt -module-summary %s -o %t.o
; 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
@@ -18,6 +17,3 @@ define i32* @somefunk() {
ret i32* @junk
}
-; Specifying a new PM pass plugin with the old PM is an error.
-; RUN: ! opt %s %loadnewpmbye -goodbye -wave-goodbye -disable-output -enable-new-pm=0 2>&1 | FileCheck %s --check-prefix=ERROR
-; ERROR: load-pass-plugin specified with legacy PM.
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 8bcd8ff2efd30..d6ddad437983a 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -66,6 +66,10 @@ static cl::opt<DebugLogging> DebugPM(
DebugLogging::Verbose, "verbose",
"Print extra information about adaptors and pass managers")));
+static cl::list<std::string>
+ PassPlugins("load-pass-plugin",
+ cl::desc("Load passes from plugin library"));
+
// This flag specifies a textual description of the alias analysis pipeline to
// use when querying for aliasing information. It only works in concert with
// the "passes" flag above.
@@ -265,7 +269,6 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
ToolOutputFile *ThinLTOLinkOut,
ToolOutputFile *OptRemarkFile,
StringRef PassPipeline, ArrayRef<StringRef> Passes,
- ArrayRef<PassPlugin> PassPlugins,
OutputKind OK, VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
@@ -338,9 +341,17 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
PassBuilder PB(TM, PTO, P, &PIC);
registerEPCallbacks(PB);
- // For any loaded plugins, let them register pass builder callbacks.
- for (auto &PassPlugin : PassPlugins)
- PassPlugin.registerPassBuilderCallbacks(PB);
+ // 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;
+ }
+
+ PassPlugin->registerPassBuilderCallbacks(PB);
+ }
PB.registerPipelineParsingCallback(
[](StringRef Name, ModulePassManager &MPM,
diff --git a/llvm/tools/opt/NewPMDriver.h b/llvm/tools/opt/NewPMDriver.h
index 40f40a0bc8c1f..056f7d6a9b80b 100644
--- a/llvm/tools/opt/NewPMDriver.h
+++ b/llvm/tools/opt/NewPMDriver.h
@@ -26,7 +26,6 @@
namespace llvm {
class StringRef;
class Module;
-class PassPlugin;
class TargetMachine;
class ToolOutputFile;
class TargetLibraryInfoImpl;
@@ -70,8 +69,7 @@ bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
TargetLibraryInfoImpl *TLII, ToolOutputFile *Out,
ToolOutputFile *ThinLinkOut, ToolOutputFile *OptRemarkFile,
StringRef PassPipeline, ArrayRef<StringRef> PassInfos,
- ArrayRef<PassPlugin> PassPlugins, opt_tool::OutputKind OK,
- opt_tool::VerifierKind VK,
+ opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash,
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 347a4b72f2f2e..da5e582e06954 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -39,7 +39,6 @@
#include "llvm/LinkAllPasses.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/MC/TargetRegistry.h"
-#include "llvm/Passes/PassPlugin.h"
#include "llvm/Remarks/HotnessThresholdParser.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileSystem.h"
@@ -301,10 +300,6 @@ static cl::opt<std::string> RemarksFormat(
cl::desc("The format used for serializing remarks (default: YAML)"),
cl::value_desc("format"), cl::init("yaml"));
-static cl::list<std::string>
- PassPlugins("load-pass-plugin",
- cl::desc("Load passes from plugin library"));
-
namespace llvm {
cl::opt<PGOKind>
PGOKindFlag("pgo-kind", cl::init(NoPGO), cl::Hidden,
@@ -586,17 +581,6 @@ int main(int argc, char **argv) {
initializeExampleIRTransforms(Registry);
#endif
- 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;
- }
- PluginList.emplace_back(Plugin.get());
- });
-
cl::ParseCommandLineOptions(argc, argv,
"llvm .bc -> .bc modular optimizer and analysis printer\n");
@@ -607,19 +591,6 @@ int main(int argc, char **argv) {
return 1;
}
- // If `-passes=` is specified, use NPM.
- // If `-enable-new-pm` is specified and there are no codegen passes, use NPM.
- // e.g. `-enable-new-pm -sroa` will use NPM.
- // but `-enable-new-pm -codegenprepare` will still revert to legacy PM.
- const bool UseNPM = (EnableNewPassManager && !shouldForceLegacyPM()) ||
- PassPipeline.getNumOccurrences() > 0;
-
- if (!UseNPM && PluginList.size()) {
- errs() << argv[0] << ": " << PassPlugins.ArgStr
- << " specified with legacy PM.\n";
- return 1;
- }
-
// FIXME: once the legacy PM code is deleted, move runPassPipeline() here and
// construct the PassBuilder before parsing IR so we can reuse the same
// PassBuilder for print passes.
@@ -781,7 +752,12 @@ int main(int argc, char **argv) {
}
}
- if (UseNPM) {
+ // If `-passes=` is specified, use NPM.
+ // If `-enable-new-pm` is specified and there are no codegen passes, use NPM.
+ // e.g. `-enable-new-pm -sroa` will use NPM.
+ // but `-enable-new-pm -codegenprepare` will still revert to legacy PM.
+ if ((EnableNewPassManager && !shouldForceLegacyPM()) ||
+ PassPipeline.getNumOccurrences() > 0) {
if (AnalyzeOnly) {
errs() << "Cannot specify -analyze under new pass manager, either "
"specify '-enable-new-pm=0', or use the corresponding new pass "
@@ -845,7 +821,7 @@ int main(int argc, char **argv) {
// layer.
return runPassPipeline(argv[0], *M, TM.get(), &TLII, Out.get(),
ThinLinkOut.get(), RemarksFile.get(), Pipeline,
- Passes, PluginList, OK, VK, PreserveAssemblyUseListOrder,
+ Passes, OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
EmitModuleHash, EnableDebugify)
? 0
More information about the llvm-commits
mailing list