1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[NewPM] Attempt to run opt passes specified via -foo-pass under NPM

Summary:
In order to enable mass testing of opt under NPM, specifically passes
specified via -foo-pass.

This is gated under a new opt flag -enable-new-pm.  Currently
the pass flag parser looks for legacy PM passes with the name "foo" (for
opt arg "-foo") and creates a PassInfo for each one. Here we take the
(legacy PM) pass name and try to match it with one defined in (NPM)
PassRegistry.def.  Ultimately if we want all tests to pass like this,
we'll need to port all passes to NPM and register them in
PassRegistry.def under the same name as they were reigstered in the
legacy PM.

Maybe at some point we'll migrate all -foo to --passes=foo, but that
would be after the NPM switch.

Flipping on the flag causes 2XXX failures under check-llvm. By far most
of them are passes either not ported to NPM or don't have the same name
in PassRegistry.def as their old name.

Reviewers: hans, echristo, asbirlea, leonardchan

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D82320
This commit is contained in:
Arthur Eubanks 2020-06-19 16:22:00 -07:00
parent 12aae3e8af
commit 39765fa3ed
4 changed files with 36 additions and 10 deletions

6
test/Other/opt-npm.ll Normal file
View File

@ -0,0 +1,6 @@
; RUN: opt -dce -enable-new-pm -disable-output -debug-pass-manager %s 2>&1 | FileCheck %s
; CHECK: DCEPass
define void @foo() {
ret void
}

View File

@ -214,8 +214,8 @@ static void registerEPCallbacks(PassBuilder &PB, bool VerifyEachPass,
bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
ToolOutputFile *Out, ToolOutputFile *ThinLTOLinkOut,
ToolOutputFile *OptRemarkFile,
StringRef PassPipeline, OutputKind OK,
VerifierKind VK,
StringRef PassPipeline, ArrayRef<StringRef> Passes,
OutputKind OK, VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash,
@ -332,11 +332,20 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
if (EnableDebugify)
MPM.addPass(NewPMDebugifyPass());
if (!PassPipeline.empty()) {
if (auto Err =
PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) {
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
return false;
}
}
for (auto PassName : Passes) {
if (auto Err =
PB.parsePassPipeline(MPM, PassName, VerifyEachPass, DebugPM)) {
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
return false;
}
}
if (VK > VK_NoVerifier)
MPM.addPass(VerifierPass());

View File

@ -20,6 +20,8 @@
#ifndef LLVM_TOOLS_OPT_NEWPMDRIVER_H
#define LLVM_TOOLS_OPT_NEWPMDRIVER_H
#include "llvm/ADT/ArrayRef.h"
namespace llvm {
class StringRef;
class Module;
@ -59,7 +61,8 @@ enum CSPGOKind { NoCSPGO, CSInstrGen, CSInstrUse };
bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
ToolOutputFile *Out, ToolOutputFile *ThinLinkOut,
ToolOutputFile *OptRemarkFile, StringRef PassPipeline,
opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
ArrayRef<StringRef> PassInfos, opt_tool::OutputKind OK,
opt_tool::VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash,

View File

@ -71,6 +71,10 @@ static codegen::RegisterCodeGenFlags CFG;
static cl::list<const PassInfo*, bool, PassNameParser>
PassList(cl::desc("Optimizations available:"));
static cl::opt<bool>
EnableNewPassManager("enable-new-pm",
cl::desc("Enable the new pass manager"));
// This flag specifies a textual description of the optimization pass pipeline
// to run over the module. This flag switches opt to use the new pass manager
// infrastructure, completely disabling all of the flags specific to the old
@ -734,12 +738,16 @@ int main(int argc, char **argv) {
if (OutputThinLTOBC)
M->addModuleFlag(Module::Error, "EnableSplitLTOUnit", SplitLTOUnit);
if (PassPipeline.getNumOccurrences() > 0) {
if (PassList.size()) {
if (EnableNewPassManager || PassPipeline.getNumOccurrences() > 0) {
if (PassPipeline.getNumOccurrences() > 0 && PassList.size() > 0) {
errs()
<< "Cannot specify passes via both -foo-pass and --passes=foo-pass";
return 1;
}
SmallVector<StringRef, 4> Passes;
for (const auto &P : PassList) {
Passes.push_back(P->getPassArgument());
}
OutputKind OK = OK_NoOutput;
if (!NoOutput)
OK = OutputAssembly
@ -756,7 +764,7 @@ int main(int argc, char **argv) {
// string. Hand off the rest of the functionality to the new code for that
// layer.
return runPassPipeline(argv[0], *M, TM.get(), Out.get(), ThinLinkOut.get(),
RemarksFile.get(), PassPipeline, OK, VK,
RemarksFile.get(), PassPipeline, Passes, OK, VK,
PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
EmitModuleHash, EnableDebugify, Coroutines)