[llvm] eccb9b6 - [NPM] Complementary fixes for opt option -print-pipeline-passes
Bjorn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 10 00:04:48 PDT 2021
Author: Bjorn Pettersson
Date: 2021-09-10T09:04:24+02:00
New Revision: eccb9b614f1593fa85a515d73d768978a76c40d3
URL: https://github.com/llvm/llvm-project/commit/eccb9b614f1593fa85a515d73d768978a76c40d3
DIFF: https://github.com/llvm/llvm-project/commit/eccb9b614f1593fa85a515d73d768978a76c40d3.diff
LOG: [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
Added:
Modified:
llvm/include/llvm/Analysis/CGSCCPassManager.h
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
llvm/test/Other/new-pm-print-pipeline.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/CGSCCPassManager.h b/llvm/include/llvm/Analysis/CGSCCPassManager.h
index e361cccef960..5603e68f2386 100644
--- a/llvm/include/llvm/Analysis/CGSCCPassManager.h
+++ b/llvm/include/llvm/Analysis/CGSCCPassManager.h
@@ -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 @@ class ModuleToPostOrderCGSCCPassAdaptor
/// 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 @@ class CGSCCToFunctionPassAdaptor
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 @@ class DevirtSCCRepeatedPass : public PassInfoMixin<DevirtSCCRepeatedPass> {
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;
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index 8583cabd4491..f2cbb672f374 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -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;
}
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index 9bebe64d42f8..580b83475bee 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -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.
diff --git a/llvm/test/Other/new-pm-print-pipeline.ll b/llvm/test/Other/new-pm-print-pipeline.ll
index c17ced28b4e4..4a5b545792b6 100644
--- a/llvm/test/Other/new-pm-print-pipeline.ll
+++ b/llvm/test/Other/new-pm-print-pipeline.ll
@@ -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>))
More information about the llvm-commits
mailing list