[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>
This commit is contained in:
Michael Kruse 2021-02-09 22:58:54 -06:00
parent e200df952b
commit 13f758a805
4 changed files with 32 additions and 17 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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");

View File

@ -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 @@ public:
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)