[polly] 13f758a - [Polly] Improve Simplify pass PM integration.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 9 21:59:06 PST 2021
Author: Michael Kruse
Date: 2021-02-09T23:56:21-06:00
New Revision: 13f758a805e043a1a83d36804f88b0ca49944fc3
URL: https://github.com/llvm/llvm-project/commit/13f758a805e043a1a83d36804f88b0ca49944fc3
DIFF: https://github.com/llvm/llvm-project/commit/13f758a805e043a1a83d36804f88b0ca49944fc3.diff
LOG: [Polly] Improve Simplify pass PM integration.
1. LegacyPM: Rename SimplifyLegacyPass to SimplifyWrapperPass.
2. LegacyPM: Complete create/init functions in LinkAllPasses.h
3. NewPM: Only invalidate non-Scop passes if changed.
4. NewPM: Add to default pass pipeline.
5. NewPM: Print -analyze header for each print<polly-simplify>
Added:
Modified:
polly/include/polly/LinkAllPasses.h
polly/include/polly/Simplify.h
polly/lib/Support/RegisterPasses.cpp
polly/lib/Transform/Simplify.cpp
Removed:
################################################################################
diff --git a/polly/include/polly/LinkAllPasses.h b/polly/include/polly/LinkAllPasses.h
index 2c01933fb53a..f59db175a8a5 100644
--- a/polly/include/polly/LinkAllPasses.h
+++ b/polly/include/polly/LinkAllPasses.h
@@ -16,7 +16,6 @@
#include "polly/CodeGen/PPCGCodeGeneration.h"
#include "polly/Config/config.h"
-#include "polly/Simplify.h"
#include "polly/Support/DumpModulePass.h"
#include "llvm/ADT/StringRef.h"
#include <cstdlib>
@@ -59,6 +58,7 @@ llvm::Pass *createFlattenSchedulePass();
llvm::Pass *createForwardOpTreeWrapperPass();
llvm::Pass *createDeLICMWrapperPass();
llvm::Pass *createMaximalStaticExpansionPass();
+llvm::Pass *createSimplifyWrapperPass(int);
llvm::Pass *createPruneUnprofitableWrapperPass();
extern char &CodePreparationID;
@@ -99,7 +99,7 @@ struct PollyForcePassLinking {
polly::createForwardOpTreeWrapperPass();
polly::createDeLICMWrapperPass();
polly::createDumpModulePass("", true);
- polly::createSimplifyPass();
+ polly::createSimplifyWrapperPass(0);
polly::createPruneUnprofitableWrapperPass();
}
} PollyForcePassLinking; // Force link by creating a global definition.
@@ -125,6 +125,7 @@ void initializePollyCanonicalizePass(llvm::PassRegistry &);
void initializeFlattenSchedulePass(llvm::PassRegistry &);
void initializeForwardOpTreeWrapperPassPass(llvm::PassRegistry &);
void initializeDeLICMWrapperPassPass(llvm::PassRegistry &);
+void initializeSimplifyWrapperPassPass(llvm::PassRegistry &);
void initializePruneUnprofitableWrapperPassPass(llvm::PassRegistry &);
} // namespace llvm
diff --git a/polly/include/polly/Simplify.h b/polly/include/polly/Simplify.h
index 952f937a91c4..35948726c65a 100644
--- a/polly/include/polly/Simplify.h
+++ b/polly/include/polly/Simplify.h
@@ -145,7 +145,7 @@ llvm::SmallVector<MemoryAccess *, 32> getAccessesInOrder(ScopStmt &Stmt);
/// simplification itself.
///
/// @return The Simplify pass.
-llvm::Pass *createSimplifyPass(int CallNo = 0);
+llvm::Pass *createSimplifyWrapperPass(int CallNo = 0);
struct SimplifyPass : public PassInfoMixin<SimplifyPass> {
SimplifyPass(int CallNo = 0) : Imp(CallNo) {}
@@ -168,7 +168,7 @@ struct SimplifyPrinterPass : public PassInfoMixin<SimplifyPrinterPass> {
} // namespace polly
namespace llvm {
-void initializeSimplifyLegacyPassPass(llvm::PassRegistry &);
+void initializeSimplifyWrapperPassPass(llvm::PassRegistry &);
} // namespace llvm
#endif /* POLLY_TRANSFORM_SIMPLIFY_H */
diff --git a/polly/lib/Support/RegisterPasses.cpp b/polly/lib/Support/RegisterPasses.cpp
index b68d65c0a7fd..a16bab806dcf 100644
--- a/polly/lib/Support/RegisterPasses.cpp
+++ b/polly/lib/Support/RegisterPasses.cpp
@@ -266,7 +266,7 @@ void initializePollyPasses(PassRegistry &Registry) {
initializeFlattenSchedulePass(Registry);
initializeForwardOpTreeWrapperPassPass(Registry);
initializeDeLICMWrapperPassPass(Registry);
- initializeSimplifyLegacyPassPass(Registry);
+ initializeSimplifyWrapperPassPass(Registry);
initializeDumpModulePass(Registry);
initializePruneUnprofitableWrapperPassPass(Registry);
}
@@ -322,13 +322,13 @@ void registerPollyPasses(llvm::legacy::PassManagerBase &PM) {
PM.add(polly::createPolyhedralInfoPass());
if (EnableSimplify)
- PM.add(polly::createSimplifyPass(0));
+ PM.add(polly::createSimplifyWrapperPass(0));
if (EnableForwardOpTree)
PM.add(polly::createForwardOpTreeWrapperPass());
if (EnableDeLICM)
PM.add(polly::createDeLICMWrapperPass());
if (EnableSimplify)
- PM.add(polly::createSimplifyPass(1));
+ PM.add(polly::createSimplifyWrapperPass(1));
if (ImportJScop)
PM.add(polly::createJSONImporterPass());
@@ -471,11 +471,14 @@ static void buildDefaultPollyPipeline(FunctionPassManager &PM,
assert(!PollyPrinter && "This option is not implemented");
assert(!PollyOnlyPrinter && "This option is not implemented");
assert(!EnablePolyhedralInfo && "This option is not implemented");
+ if (EnableSimplify)
+ SPM.addPass(SimplifyPass(0));
if (EnableForwardOpTree)
SPM.addPass(ForwardOpTreePass());
if (EnableDeLICM)
SPM.addPass(DeLICMPass());
- assert(!EnableSimplify && "This option is not implemented");
+ if (EnableSimplify)
+ SPM.addPass(SimplifyPass(1));
if (ImportJScop)
SPM.addPass(JSONImportPass());
assert(!DeadCodeElim && "This option is not implemented");
diff --git a/polly/lib/Transform/Simplify.cpp b/polly/lib/Transform/Simplify.cpp
index c25a2eff72df..e064df2f9cdf 100644
--- a/polly/lib/Transform/Simplify.cpp
+++ b/polly/lib/Transform/Simplify.cpp
@@ -680,12 +680,12 @@ void SimplifyVisitor::releaseMemory() {
}
namespace {
-class SimplifyLegacyPass : public ScopPass {
+class SimplifyWrapperPass : public ScopPass {
public:
static char ID;
SimplifyVisitor Imp;
- explicit SimplifyLegacyPass(int CallNo = 0) : ScopPass(ID), Imp(CallNo) {}
+ explicit SimplifyWrapperPass(int CallNo = 0) : ScopPass(ID), Imp(CallNo) {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequiredTransitive<ScopInfoRegionPass>();
@@ -704,7 +704,7 @@ class SimplifyLegacyPass : public ScopPass {
virtual void releaseMemory() override { Imp.releaseMemory(); }
};
-char SimplifyLegacyPass::ID;
+char SimplifyWrapperPass::ID;
} // anonymous namespace
namespace polly {
@@ -714,19 +714,30 @@ llvm::PreservedAnalyses SimplifyPass::run(Scop &S, ScopAnalysisManager &SAM,
if (!Imp.visit(S, &SAR.LI))
return llvm::PreservedAnalyses::all();
- return llvm::PreservedAnalyses::none();
+ PreservedAnalyses PA;
+ PA.preserveSet<AllAnalysesOn<Module>>();
+ PA.preserveSet<AllAnalysesOn<Function>>();
+ PA.preserveSet<AllAnalysesOn<Loop>>();
+ return PA;
}
llvm::PreservedAnalyses
SimplifyPrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
ScopStandardAnalysisResults &SAR, SPMUpdater &U) {
bool Changed = Imp.visit(S, &SAR.LI);
+
+ OS << "Printing analysis 'Polly - Simplify' for region: '" << S.getName()
+ << "' in function '" << S.getFunction().getName() << "':\n";
Imp.printScop(OS, S);
if (!Changed)
return llvm::PreservedAnalyses::all();
- return llvm::PreservedAnalyses::none();
+ PreservedAnalyses PA;
+ PA.preserveSet<AllAnalysesOn<Module>>();
+ PA.preserveSet<AllAnalysesOn<Function>>();
+ PA.preserveSet<AllAnalysesOn<Loop>>();
+ return PA;
}
SmallVector<MemoryAccess *, 32> getAccessesInOrder(ScopStmt &Stmt) {
@@ -749,12 +760,12 @@ SmallVector<MemoryAccess *, 32> getAccessesInOrder(ScopStmt &Stmt) {
}
} // namespace polly
-Pass *polly::createSimplifyPass(int CallNo) {
- return new SimplifyLegacyPass(CallNo);
+Pass *polly::createSimplifyWrapperPass(int CallNo) {
+ return new SimplifyWrapperPass(CallNo);
}
-INITIALIZE_PASS_BEGIN(SimplifyLegacyPass, "polly-simplify", "Polly - Simplify",
+INITIALIZE_PASS_BEGIN(SimplifyWrapperPass, "polly-simplify", "Polly - Simplify",
false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
-INITIALIZE_PASS_END(SimplifyLegacyPass, "polly-simplify", "Polly - Simplify",
+INITIALIZE_PASS_END(SimplifyWrapperPass, "polly-simplify", "Polly - Simplify",
false, false)
More information about the llvm-commits
mailing list