[polly] r303621 - [Polly][NewPM] Port DependenceInfo to the new ScopPassManager.
Philip Pfaffe via llvm-commits
llvm-commits at lists.llvm.org
Tue May 23 03:09:06 PDT 2017
Author: pfaffe
Date: Tue May 23 05:09:06 2017
New Revision: 303621
URL: http://llvm.org/viewvc/llvm-project?rev=303621&view=rev
Log:
[Polly][NewPM] Port DependenceInfo to the new ScopPassManager.
Summary: This patch ports DependenceInfo to the new ScopPassManager. Printing is implemented as a seperate printer pass.
Reviewers: grosser, Meinersbur
Reviewed By: grosser
Subscribers: llvm-commits, pollydev
Tags: #polly
Differential Revision: https://reviews.llvm.org/D33421
Modified:
polly/trunk/include/polly/DependenceInfo.h
polly/trunk/lib/Analysis/DependenceInfo.cpp
Modified: polly/trunk/include/polly/DependenceInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/DependenceInfo.h?rev=303621&r1=303620&r2=303621&view=diff
==============================================================================
--- polly/trunk/include/polly/DependenceInfo.h (original)
+++ polly/trunk/include/polly/DependenceInfo.h Tue May 23 05:09:06 2017
@@ -148,6 +148,8 @@ struct Dependences {
///
/// To restrict access to the internal state, only the DependenceInfo class
/// is able to call or modify a Dependences struct.
+ friend struct DependenceAnalysis;
+ friend struct DependenceInfoPrinterPass;
friend class DependenceInfo;
friend class DependenceInfoWrapperPass;
@@ -196,6 +198,37 @@ private:
const AnalysisLevel Level;
};
+struct DependenceAnalysis : public AnalysisInfoMixin<DependenceAnalysis> {
+ static AnalysisKey Key;
+ struct Result {
+ Scop &S;
+ std::unique_ptr<Dependences> D[Dependences::NumAnalysisLevels];
+
+ /// Return the dependence information for the current SCoP.
+ ///
+ /// @param Level The granularity of dependence analysis result.
+ ///
+ /// @return The dependence analysis result
+ ///
+ const Dependences &getDependences(Dependences::AnalysisLevel Level);
+
+ /// Recompute dependences from schedule and memory accesses.
+ const Dependences &recomputeDependences(Dependences::AnalysisLevel Level);
+ };
+ Result run(Scop &S, ScopAnalysisManager &SAM,
+ ScopStandardAnalysisResults &SAR);
+};
+
+struct DependenceInfoPrinterPass
+ : public PassInfoMixin<DependenceInfoPrinterPass> {
+ DependenceInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
+
+ PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
+ ScopStandardAnalysisResults &, SPMUpdater &);
+
+ raw_ostream &OS;
+};
+
class DependenceInfo : public ScopPass {
public:
static char ID;
Modified: polly/trunk/lib/Analysis/DependenceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/DependenceInfo.cpp?rev=303621&r1=303620&r2=303621&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/DependenceInfo.cpp (original)
+++ polly/trunk/lib/Analysis/DependenceInfo.cpp Tue May 23 05:09:06 2017
@@ -912,6 +912,48 @@ void Dependences::setReductionDependence
}
const Dependences &
+DependenceAnalysis::Result::getDependences(Dependences::AnalysisLevel Level) {
+ if (Dependences *d = D[Level].get())
+ return *d;
+
+ return recomputeDependences(Level);
+}
+
+const Dependences &DependenceAnalysis::Result::recomputeDependences(
+ Dependences::AnalysisLevel Level) {
+ D[Level].reset(new Dependences(S.getSharedIslCtx(), Level));
+ D[Level]->calculateDependences(S);
+ return *D[Level];
+}
+
+DependenceAnalysis::Result
+DependenceAnalysis::run(Scop &S, ScopAnalysisManager &SAM,
+ ScopStandardAnalysisResults &SAR) {
+ return {S, {}};
+}
+
+AnalysisKey DependenceAnalysis::Key;
+
+PreservedAnalyses
+DependenceInfoPrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
+ ScopStandardAnalysisResults &SAR,
+ SPMUpdater &U) {
+ auto &DI = SAM.getResult<DependenceAnalysis>(S, SAR);
+
+ if (auto d = DI.D[OptAnalysisLevel].get()) {
+ d->print(OS);
+ return PreservedAnalyses::all();
+ }
+
+ // Otherwise create the dependences on-the-fly and print it
+ Dependences D(S.getSharedIslCtx(), OptAnalysisLevel);
+ D.calculateDependences(S);
+ D.print(OS);
+
+ return PreservedAnalyses::all();
+}
+
+const Dependences &
DependenceInfo::getDependences(Dependences::AnalysisLevel Level) {
if (Dependences *d = D[Level].get())
return *d;
More information about the llvm-commits
mailing list