summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/include/polly/LinkAllPasses.h1
-rw-r--r--polly/include/polly/ScopInfo.h55
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp69
-rw-r--r--polly/lib/Support/RegisterPasses.cpp1
-rw-r--r--polly/test/ScopInfo/assume_gep_bounds.ll1
-rw-r--r--polly/test/ScopInfo/constant_factor_in_parameter.ll1
-rw-r--r--polly/test/ScopInfo/invariant_load_loop_ub.ll1
-rw-r--r--polly/test/ScopInfo/loop_affine_bound_0.ll1
-rw-r--r--polly/test/ScopInfo/loop_affine_bound_1.ll1
-rw-r--r--polly/test/ScopInfo/loop_affine_bound_2.ll1
-rw-r--r--polly/test/ScopInfo/multidim_2d-diagonal-matrix.ll1
-rw-r--r--polly/test/ScopInfo/multidim_many_references.ll1
-rw-r--r--polly/test/ScopInfo/multidim_nested_start_integer.ll1
-rw-r--r--polly/test/ScopInfo/multidim_single_and_multidim_array.ll4
-rw-r--r--polly/test/ScopInfo/non_affine_region_3.ll1
-rw-r--r--polly/test/ScopInfo/reduction_two_identical_reads.ll1
-rw-r--r--polly/test/ScopInfo/scalar_to_array.ll1
-rw-r--r--polly/test/ScopInfo/test-wrapping-in-condition.ll1
18 files changed, 143 insertions, 0 deletions
diff --git a/polly/include/polly/LinkAllPasses.h b/polly/include/polly/LinkAllPasses.h
index d9f07a06ef3..48d3d3a324b 100644
--- a/polly/include/polly/LinkAllPasses.h
+++ b/polly/include/polly/LinkAllPasses.h
@@ -38,6 +38,7 @@ llvm::Pass *createJSONImporterPass();
llvm::Pass *createPollyCanonicalizePass();
llvm::Pass *createScopDetectionPass();
llvm::Pass *createScopInfoRegionPassPass();
+llvm::Pass *createScopInfoWrapperPassPass();
llvm::Pass *createIslAstInfoPass();
llvm::Pass *createCodeGenerationPass();
llvm::Pass *createIslScheduleOptimizerPass();
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 40f5f0f5db1..024ed22d411 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -2518,11 +2518,66 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const override;
};
+//===----------------------------------------------------------------------===//
+/// @brief The legacy pass manager's analysis pass to compute scop information
+/// for the whole function.
+///
+/// This pass will maintain a map of the maximal region within a scop to its
+/// scop object for all the feasible scops present in a function.
+/// This pass is an alternative to the ScopInfoRegionPass in order to avoid a
+/// region pass manager.
+class ScopInfoWrapperPass : public FunctionPass {
+
+public:
+ using RegionToScopMapTy = DenseMap<Region *, std::unique_ptr<Scop>>;
+ using iterator = RegionToScopMapTy::iterator;
+ using const_iterator = RegionToScopMapTy::const_iterator;
+
+private:
+ /// @brief A map of Region to its Scop object containing
+ /// Polly IR of static control part
+ RegionToScopMapTy RegionToScopMap;
+
+public:
+ static char ID; // Pass identification, replacement for typeid
+
+ ScopInfoWrapperPass() : FunctionPass(ID) {}
+ ~ScopInfoWrapperPass() {}
+
+ /// @brief Get the Scop object for the given Region
+ ///
+ /// @return If the given region is the maximal region within a scop, return
+ /// the scop object. If the given region is a subregion, return a
+ /// nullptr. Top level region containing the entry block of a function
+ /// is not considered in the scop creation.
+ Scop *getScop(Region *R) const {
+ auto MapIt = RegionToScopMap.find(R);
+ if (MapIt != RegionToScopMap.end())
+ return MapIt->second.get();
+ return nullptr;
+ }
+
+ iterator begin() { return RegionToScopMap.begin(); }
+ iterator end() { return RegionToScopMap.end(); }
+ const_iterator begin() const { return RegionToScopMap.begin(); }
+ const_iterator end() const { return RegionToScopMap.end(); }
+
+ /// @brief Calculate all the polyhedral scops for a given function.
+ bool runOnFunction(Function &F) override;
+
+ void releaseMemory() override { RegionToScopMap.clear(); }
+
+ void print(raw_ostream &O, const Module *M = nullptr) const override;
+
+ void getAnalysisUsage(AnalysisUsage &AU) const override;
+};
+
} // end namespace polly
namespace llvm {
class PassRegistry;
void initializeScopInfoRegionPassPass(llvm::PassRegistry &);
+void initializeScopInfoWrapperPassPass(llvm::PassRegistry &);
} // namespace llvm
#endif
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index c64f025b5ff..f8e2e3abef2 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -4936,3 +4936,72 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass);
INITIALIZE_PASS_END(ScopInfoRegionPass, "polly-scops",
"Polly - Create polyhedral description of Scops", false,
false)
+
+//===----------------------------------------------------------------------===//
+void ScopInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.addRequired<LoopInfoWrapperPass>();
+ AU.addRequired<RegionInfoPass>();
+ AU.addRequired<DominatorTreeWrapperPass>();
+ AU.addRequiredTransitive<ScalarEvolutionWrapperPass>();
+ AU.addRequiredTransitive<ScopDetection>();
+ AU.addRequired<AAResultsWrapperPass>();
+ AU.addRequired<AssumptionCacheTracker>();
+ AU.setPreservesAll();
+}
+
+bool ScopInfoWrapperPass::runOnFunction(Function &F) {
+ auto &SD = getAnalysis<ScopDetection>();
+
+ auto &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
+ auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
+ auto &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
+ auto const &DL = F.getParent()->getDataLayout();
+ auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
+
+ /// Create polyhedral descripton of scops for all the valid regions of a
+ /// function.
+ for (auto &It : SD) {
+ Region *R = const_cast<Region *>(It);
+ if (!SD.isMaxRegionInScop(*R))
+ continue;
+
+ ScopBuilder SB(R, AC, AA, DL, DT, LI, SD, SE);
+ bool Inserted =
+ RegionToScopMap.insert(std::make_pair(R, SB.getScop())).second;
+ assert(Inserted && "Building Scop for the same region twice!");
+ (void)Inserted;
+ }
+ return false;
+}
+
+void ScopInfoWrapperPass::print(raw_ostream &OS, const Module *) const {
+ for (auto &It : RegionToScopMap) {
+ if (It.second)
+ It.second->print(OS);
+ else
+ OS << "Invalid Scop!\n";
+ }
+}
+
+char ScopInfoWrapperPass::ID = 0;
+
+Pass *polly::createScopInfoWrapperPassPass() {
+ return new ScopInfoWrapperPass();
+}
+
+INITIALIZE_PASS_BEGIN(
+ ScopInfoWrapperPass, "polly-function-scops",
+ "Polly - Create polyhedral description of all Scops of a function", false,
+ false);
+INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass);
+INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker);
+INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
+INITIALIZE_PASS_DEPENDENCY(RegionInfoPass);
+INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass);
+INITIALIZE_PASS_DEPENDENCY(ScopDetection);
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass);
+INITIALIZE_PASS_END(
+ ScopInfoWrapperPass, "polly-function-scops",
+ "Polly - Create polyhedral description of all Scops of a function", false,
+ false)
diff --git a/polly/lib/Support/RegisterPasses.cpp b/polly/lib/Support/RegisterPasses.cpp
index b7ec5353558..9baf8de56fe 100644
--- a/polly/lib/Support/RegisterPasses.cpp
+++ b/polly/lib/Support/RegisterPasses.cpp
@@ -155,6 +155,7 @@ void initializePollyPasses(PassRegistry &Registry) {
initializePollyCanonicalizePass(Registry);
initializeScopDetectionPass(Registry);
initializeScopInfoRegionPassPass(Registry);
+ initializeScopInfoWrapperPassPass(Registry);
initializeCodegenCleanupPass(Registry);
}
diff --git a/polly/test/ScopInfo/assume_gep_bounds.ll b/polly/test/ScopInfo/assume_gep_bounds.ll
index 747898edff3..f1bad856c06 100644
--- a/polly/test/ScopInfo/assume_gep_bounds.ll
+++ b/polly/test/ScopInfo/assume_gep_bounds.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
; void foo(float A[][20][30], long n, long m, long p) {
; for (long i = 0; i < n; i++)
diff --git a/polly/test/ScopInfo/constant_factor_in_parameter.ll b/polly/test/ScopInfo/constant_factor_in_parameter.ll
index f4129d89cec..381ef36754b 100644
--- a/polly/test/ScopInfo/constant_factor_in_parameter.ll
+++ b/polly/test/ScopInfo/constant_factor_in_parameter.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -analyze -polly-scops < %s | FileCheck %s
+; RUN: opt %loadPolly -analyze -polly-function-scops < %s | FileCheck %s
;
; Check that the constant part of the N * M * 4 expression is not part of the
; parameter but explicit in the access function. This can avoid existentially
diff --git a/polly/test/ScopInfo/invariant_load_loop_ub.ll b/polly/test/ScopInfo/invariant_load_loop_ub.ll
index 4ea1f8c832f..1c063dc0268 100644
--- a/polly/test/ScopInfo/invariant_load_loop_ub.ll
+++ b/polly/test/ScopInfo/invariant_load_loop_ub.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -polly-process-unprofitable -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -polly-process-unprofitable -analyze < %s | FileCheck %s
;
; CHECK: Invariant Accesses:
; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
diff --git a/polly/test/ScopInfo/loop_affine_bound_0.ll b/polly/test/ScopInfo/loop_affine_bound_0.ll
index a613e7b41fd..28017636c16 100644
--- a/polly/test/ScopInfo/loop_affine_bound_0.ll
+++ b/polly/test/ScopInfo/loop_affine_bound_0.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
; void f(long a[][128], long N, long M) {
; long i, j;
diff --git a/polly/test/ScopInfo/loop_affine_bound_1.ll b/polly/test/ScopInfo/loop_affine_bound_1.ll
index 151d22e31a3..9237b8a84db 100644
--- a/polly/test/ScopInfo/loop_affine_bound_1.ll
+++ b/polly/test/ScopInfo/loop_affine_bound_1.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
;void f(long a[][128], long N, long M) {
; long i, j;
diff --git a/polly/test/ScopInfo/loop_affine_bound_2.ll b/polly/test/ScopInfo/loop_affine_bound_2.ll
index e01f091ca6c..4ebaf715159 100644
--- a/polly/test/ScopInfo/loop_affine_bound_2.ll
+++ b/polly/test/ScopInfo/loop_affine_bound_2.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
; void f(long a[][128], long N, long M) {
; long i, j;
diff --git a/polly/test/ScopInfo/multidim_2d-diagonal-matrix.ll b/polly/test/ScopInfo/multidim_2d-diagonal-matrix.ll
index 6a5534d9bd6..6a60abd2569 100644
--- a/polly/test/ScopInfo/multidim_2d-diagonal-matrix.ll
+++ b/polly/test/ScopInfo/multidim_2d-diagonal-matrix.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
; Derived from the following code:
diff --git a/polly/test/ScopInfo/multidim_many_references.ll b/polly/test/ScopInfo/multidim_many_references.ll
index dd1da0cfc0e..1cf7dd44416 100644
--- a/polly/test/ScopInfo/multidim_many_references.ll
+++ b/polly/test/ScopInfo/multidim_many_references.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze -polly-ignore-aliasing < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze -polly-ignore-aliasing < %s | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
diff --git a/polly/test/ScopInfo/multidim_nested_start_integer.ll b/polly/test/ScopInfo/multidim_nested_start_integer.ll
index bc945cd7ff6..a2cebd651e5 100644
--- a/polly/test/ScopInfo/multidim_nested_start_integer.ll
+++ b/polly/test/ScopInfo/multidim_nested_start_integer.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
; void foo(long n, long m, long o, double A[n][m][o]) {
diff --git a/polly/test/ScopInfo/multidim_single_and_multidim_array.ll b/polly/test/ScopInfo/multidim_single_and_multidim_array.ll
index 182725d7fe3..dc0536e9ea9 100644
--- a/polly/test/ScopInfo/multidim_single_and_multidim_array.ll
+++ b/polly/test/ScopInfo/multidim_single_and_multidim_array.ll
@@ -2,6 +2,10 @@
; RUN: opt %loadPolly -polly-scops -polly-delinearize=false -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s --check-prefix=DELIN
; RUN: opt %loadPolly -polly-scops -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=DELIN
+; RUN: opt %loadPolly -polly-function-scops -polly-delinearize=false -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -polly-delinearize=false -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s --check-prefix=DELIN
+; RUN: opt %loadPolly -polly-function-scops -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=DELIN
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
diff --git a/polly/test/ScopInfo/non_affine_region_3.ll b/polly/test/ScopInfo/non_affine_region_3.ll
index 3b43c6360c9..e284c121166 100644
--- a/polly/test/ScopInfo/non_affine_region_3.ll
+++ b/polly/test/ScopInfo/non_affine_region_3.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
;
; Verify the scalar x defined in a non-affine subregion is written as it
; escapes the region. In this test the two conditionals inside the region
diff --git a/polly/test/ScopInfo/reduction_two_identical_reads.ll b/polly/test/ScopInfo/reduction_two_identical_reads.ll
index 1d334aa2a49..1937e731c9a 100644
--- a/polly/test/ScopInfo/reduction_two_identical_reads.ll
+++ b/polly/test/ScopInfo/reduction_two_identical_reads.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
;
; CHECK: Reduction Type: NONE
;
diff --git a/polly/test/ScopInfo/scalar_to_array.ll b/polly/test/ScopInfo/scalar_to_array.ll
index 6e2305d4ffe..c959c2b0e17 100644
--- a/polly/test/ScopInfo/scalar_to_array.ll
+++ b/polly/test/ScopInfo/scalar_to_array.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -basicaa -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -basicaa -polly-function-scops -analyze < %s | FileCheck %s
; ModuleID = 'scalar_to_array.ll'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
diff --git a/polly/test/ScopInfo/test-wrapping-in-condition.ll b/polly/test/ScopInfo/test-wrapping-in-condition.ll
index 9c5c8a1b323..0087a408323 100644
--- a/polly/test/ScopInfo/test-wrapping-in-condition.ll
+++ b/polly/test/ScopInfo/test-wrapping-in-condition.ll
@@ -1,4 +1,5 @@
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
;
; CHECK: Invalid Context:
; CHECK: [N] -> { : N >= 129 }
OpenPOWER on IntegriCloud