forked from OSchip/llvm-project
[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:
parent
e200df952b
commit
13f758a805
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#include "polly/CodeGen/PPCGCodeGeneration.h"
|
#include "polly/CodeGen/PPCGCodeGeneration.h"
|
||||||
#include "polly/Config/config.h"
|
#include "polly/Config/config.h"
|
||||||
#include "polly/Simplify.h"
|
|
||||||
#include "polly/Support/DumpModulePass.h"
|
#include "polly/Support/DumpModulePass.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -59,6 +58,7 @@ llvm::Pass *createFlattenSchedulePass();
|
||||||
llvm::Pass *createForwardOpTreeWrapperPass();
|
llvm::Pass *createForwardOpTreeWrapperPass();
|
||||||
llvm::Pass *createDeLICMWrapperPass();
|
llvm::Pass *createDeLICMWrapperPass();
|
||||||
llvm::Pass *createMaximalStaticExpansionPass();
|
llvm::Pass *createMaximalStaticExpansionPass();
|
||||||
|
llvm::Pass *createSimplifyWrapperPass(int);
|
||||||
llvm::Pass *createPruneUnprofitableWrapperPass();
|
llvm::Pass *createPruneUnprofitableWrapperPass();
|
||||||
|
|
||||||
extern char &CodePreparationID;
|
extern char &CodePreparationID;
|
||||||
|
@ -99,7 +99,7 @@ struct PollyForcePassLinking {
|
||||||
polly::createForwardOpTreeWrapperPass();
|
polly::createForwardOpTreeWrapperPass();
|
||||||
polly::createDeLICMWrapperPass();
|
polly::createDeLICMWrapperPass();
|
||||||
polly::createDumpModulePass("", true);
|
polly::createDumpModulePass("", true);
|
||||||
polly::createSimplifyPass();
|
polly::createSimplifyWrapperPass(0);
|
||||||
polly::createPruneUnprofitableWrapperPass();
|
polly::createPruneUnprofitableWrapperPass();
|
||||||
}
|
}
|
||||||
} PollyForcePassLinking; // Force link by creating a global definition.
|
} PollyForcePassLinking; // Force link by creating a global definition.
|
||||||
|
@ -125,6 +125,7 @@ void initializePollyCanonicalizePass(llvm::PassRegistry &);
|
||||||
void initializeFlattenSchedulePass(llvm::PassRegistry &);
|
void initializeFlattenSchedulePass(llvm::PassRegistry &);
|
||||||
void initializeForwardOpTreeWrapperPassPass(llvm::PassRegistry &);
|
void initializeForwardOpTreeWrapperPassPass(llvm::PassRegistry &);
|
||||||
void initializeDeLICMWrapperPassPass(llvm::PassRegistry &);
|
void initializeDeLICMWrapperPassPass(llvm::PassRegistry &);
|
||||||
|
void initializeSimplifyWrapperPassPass(llvm::PassRegistry &);
|
||||||
void initializePruneUnprofitableWrapperPassPass(llvm::PassRegistry &);
|
void initializePruneUnprofitableWrapperPassPass(llvm::PassRegistry &);
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ llvm::SmallVector<MemoryAccess *, 32> getAccessesInOrder(ScopStmt &Stmt);
|
||||||
/// simplification itself.
|
/// simplification itself.
|
||||||
///
|
///
|
||||||
/// @return The Simplify pass.
|
/// @return The Simplify pass.
|
||||||
llvm::Pass *createSimplifyPass(int CallNo = 0);
|
llvm::Pass *createSimplifyWrapperPass(int CallNo = 0);
|
||||||
|
|
||||||
struct SimplifyPass : public PassInfoMixin<SimplifyPass> {
|
struct SimplifyPass : public PassInfoMixin<SimplifyPass> {
|
||||||
SimplifyPass(int CallNo = 0) : Imp(CallNo) {}
|
SimplifyPass(int CallNo = 0) : Imp(CallNo) {}
|
||||||
|
@ -168,7 +168,7 @@ struct SimplifyPrinterPass : public PassInfoMixin<SimplifyPrinterPass> {
|
||||||
} // namespace polly
|
} // namespace polly
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
void initializeSimplifyLegacyPassPass(llvm::PassRegistry &);
|
void initializeSimplifyWrapperPassPass(llvm::PassRegistry &);
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
#endif /* POLLY_TRANSFORM_SIMPLIFY_H */
|
#endif /* POLLY_TRANSFORM_SIMPLIFY_H */
|
||||||
|
|
|
@ -266,7 +266,7 @@ void initializePollyPasses(PassRegistry &Registry) {
|
||||||
initializeFlattenSchedulePass(Registry);
|
initializeFlattenSchedulePass(Registry);
|
||||||
initializeForwardOpTreeWrapperPassPass(Registry);
|
initializeForwardOpTreeWrapperPassPass(Registry);
|
||||||
initializeDeLICMWrapperPassPass(Registry);
|
initializeDeLICMWrapperPassPass(Registry);
|
||||||
initializeSimplifyLegacyPassPass(Registry);
|
initializeSimplifyWrapperPassPass(Registry);
|
||||||
initializeDumpModulePass(Registry);
|
initializeDumpModulePass(Registry);
|
||||||
initializePruneUnprofitableWrapperPassPass(Registry);
|
initializePruneUnprofitableWrapperPassPass(Registry);
|
||||||
}
|
}
|
||||||
|
@ -322,13 +322,13 @@ void registerPollyPasses(llvm::legacy::PassManagerBase &PM) {
|
||||||
PM.add(polly::createPolyhedralInfoPass());
|
PM.add(polly::createPolyhedralInfoPass());
|
||||||
|
|
||||||
if (EnableSimplify)
|
if (EnableSimplify)
|
||||||
PM.add(polly::createSimplifyPass(0));
|
PM.add(polly::createSimplifyWrapperPass(0));
|
||||||
if (EnableForwardOpTree)
|
if (EnableForwardOpTree)
|
||||||
PM.add(polly::createForwardOpTreeWrapperPass());
|
PM.add(polly::createForwardOpTreeWrapperPass());
|
||||||
if (EnableDeLICM)
|
if (EnableDeLICM)
|
||||||
PM.add(polly::createDeLICMWrapperPass());
|
PM.add(polly::createDeLICMWrapperPass());
|
||||||
if (EnableSimplify)
|
if (EnableSimplify)
|
||||||
PM.add(polly::createSimplifyPass(1));
|
PM.add(polly::createSimplifyWrapperPass(1));
|
||||||
|
|
||||||
if (ImportJScop)
|
if (ImportJScop)
|
||||||
PM.add(polly::createJSONImporterPass());
|
PM.add(polly::createJSONImporterPass());
|
||||||
|
@ -471,11 +471,14 @@ static void buildDefaultPollyPipeline(FunctionPassManager &PM,
|
||||||
assert(!PollyPrinter && "This option is not implemented");
|
assert(!PollyPrinter && "This option is not implemented");
|
||||||
assert(!PollyOnlyPrinter && "This option is not implemented");
|
assert(!PollyOnlyPrinter && "This option is not implemented");
|
||||||
assert(!EnablePolyhedralInfo && "This option is not implemented");
|
assert(!EnablePolyhedralInfo && "This option is not implemented");
|
||||||
|
if (EnableSimplify)
|
||||||
|
SPM.addPass(SimplifyPass(0));
|
||||||
if (EnableForwardOpTree)
|
if (EnableForwardOpTree)
|
||||||
SPM.addPass(ForwardOpTreePass());
|
SPM.addPass(ForwardOpTreePass());
|
||||||
if (EnableDeLICM)
|
if (EnableDeLICM)
|
||||||
SPM.addPass(DeLICMPass());
|
SPM.addPass(DeLICMPass());
|
||||||
assert(!EnableSimplify && "This option is not implemented");
|
if (EnableSimplify)
|
||||||
|
SPM.addPass(SimplifyPass(1));
|
||||||
if (ImportJScop)
|
if (ImportJScop)
|
||||||
SPM.addPass(JSONImportPass());
|
SPM.addPass(JSONImportPass());
|
||||||
assert(!DeadCodeElim && "This option is not implemented");
|
assert(!DeadCodeElim && "This option is not implemented");
|
||||||
|
|
|
@ -680,12 +680,12 @@ void SimplifyVisitor::releaseMemory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class SimplifyLegacyPass : public ScopPass {
|
class SimplifyWrapperPass : public ScopPass {
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
SimplifyVisitor Imp;
|
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 {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
AU.addRequiredTransitive<ScopInfoRegionPass>();
|
AU.addRequiredTransitive<ScopInfoRegionPass>();
|
||||||
|
@ -704,7 +704,7 @@ public:
|
||||||
virtual void releaseMemory() override { Imp.releaseMemory(); }
|
virtual void releaseMemory() override { Imp.releaseMemory(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
char SimplifyLegacyPass::ID;
|
char SimplifyWrapperPass::ID;
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
namespace polly {
|
namespace polly {
|
||||||
|
@ -714,19 +714,30 @@ llvm::PreservedAnalyses SimplifyPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||||
if (!Imp.visit(S, &SAR.LI))
|
if (!Imp.visit(S, &SAR.LI))
|
||||||
return llvm::PreservedAnalyses::all();
|
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
|
llvm::PreservedAnalyses
|
||||||
SimplifyPrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
|
SimplifyPrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U) {
|
ScopStandardAnalysisResults &SAR, SPMUpdater &U) {
|
||||||
bool Changed = Imp.visit(S, &SAR.LI);
|
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);
|
Imp.printScop(OS, S);
|
||||||
|
|
||||||
if (!Changed)
|
if (!Changed)
|
||||||
return llvm::PreservedAnalyses::all();
|
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) {
|
SmallVector<MemoryAccess *, 32> getAccessesInOrder(ScopStmt &Stmt) {
|
||||||
|
@ -749,12 +760,12 @@ SmallVector<MemoryAccess *, 32> getAccessesInOrder(ScopStmt &Stmt) {
|
||||||
}
|
}
|
||||||
} // namespace polly
|
} // namespace polly
|
||||||
|
|
||||||
Pass *polly::createSimplifyPass(int CallNo) {
|
Pass *polly::createSimplifyWrapperPass(int CallNo) {
|
||||||
return new SimplifyLegacyPass(CallNo);
|
return new SimplifyWrapperPass(CallNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
INITIALIZE_PASS_BEGIN(SimplifyLegacyPass, "polly-simplify", "Polly - Simplify",
|
INITIALIZE_PASS_BEGIN(SimplifyWrapperPass, "polly-simplify", "Polly - Simplify",
|
||||||
false, false)
|
false, false)
|
||||||
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
|
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
|
||||||
INITIALIZE_PASS_END(SimplifyLegacyPass, "polly-simplify", "Polly - Simplify",
|
INITIALIZE_PASS_END(SimplifyWrapperPass, "polly-simplify", "Polly - Simplify",
|
||||||
false, false)
|
false, false)
|
||||||
|
|
Loading…
Reference in New Issue