[NPM] Complementary fixes for opt option -print-pipeline-passes

Make sure we handle some more adaptors etc (such as cgscc and devirt).

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D109542
This commit is contained in:
Bjorn Pettersson 2021-09-09 22:19:29 +02:00
parent 704a395693
commit eccb9b614f
4 changed files with 38 additions and 3 deletions

View File

@ -161,6 +161,12 @@ struct RequireAnalysisPass<AnalysisT, LazyCallGraph::SCC, CGSCCAnalysisManager,
(void)AM.template getResult<AnalysisT>(C, CG);
return PreservedAnalyses::all();
}
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName) {
auto ClassName = AnalysisT::name();
auto PassName = MapClassName2PassName(ClassName);
OS << "require<" << PassName << ">";
}
};
/// A proxy from a \c CGSCCAnalysisManager to a \c Module.
@ -363,6 +369,13 @@ public:
/// Runs the CGSCC pass across every SCC in the module.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName) {
OS << "cgscc(";
Pass->printPipeline(OS, MapClassName2PassName);
OS << ")";
}
static bool isRequired() { return true; }
private:
@ -481,6 +494,13 @@ public:
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
LazyCallGraph &CG, CGSCCUpdateResult &UR);
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName) {
OS << "function(";
Pass->printPipeline(OS, MapClassName2PassName);
OS << ")";
}
static bool isRequired() { return true; }
private:
@ -528,6 +548,13 @@ public:
PreservedAnalyses run(LazyCallGraph::SCC &InitialC, CGSCCAnalysisManager &AM,
LazyCallGraph &CG, CGSCCUpdateResult &UR);
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName) {
OS << "devirt<" << MaxIterations << ">(";
Pass->printPipeline(OS, MapClassName2PassName);
OS << ")";
}
private:
std::unique_ptr<PassConceptT> Pass;
int MaxIterations;

View File

@ -377,14 +377,13 @@ template <typename DerivedT> struct PassInfoMixin {
static_assert(std::is_base_of<PassInfoMixin, DerivedT>::value,
"Must pass the derived type as the template argument!");
StringRef Name = getTypeName<DerivedT>();
if (Name.startswith("llvm::"))
Name = Name.drop_front(strlen("llvm::"));
Name.consume_front("llvm::");
return Name;
}
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName) {
auto ClassName = name();
StringRef ClassName = DerivedT::name();
auto PassName = MapClassName2PassName(ClassName);
OS << PassName;
}

View File

@ -217,6 +217,12 @@ struct RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
(void)AM.template getResult<AnalysisT>(L, AR);
return PreservedAnalyses::all();
}
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName) {
auto ClassName = AnalysisT::name();
auto PassName = MapClassName2PassName(ClassName);
OS << "require<" << PassName << ">";
}
};
/// An alias template to easily name a require analysis loop pass.

View File

@ -15,3 +15,6 @@
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(loop-mssa(indvars))' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-4
; CHECK-4: function(loop-mssa(indvars))
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='cgscc(argpromotion,require<no-op-cgscc>,no-op-cgscc,devirt<7>(inline,no-op-cgscc)),function(loop(require<no-op-loop>))' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-5
; CHECK-5: cgscc(argpromotion,require<no-op-cgscc>,no-op-cgscc,devirt<7>(inline,no-op-cgscc)),function(loop(require<no-op-loop>))