[polly] r273856 - [GSoC 2016]New function pass ScopInfoWrapperPass
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 27 02:32:31 PDT 2016
Author: jdoerfert
Date: Mon Jun 27 04:32:30 2016
New Revision: 273856
URL: http://llvm.org/viewvc/llvm-project?rev=273856&view=rev
Log:
[GSoC 2016]New function pass ScopInfoWrapperPass
This patch adds a new function pass ScopInfoWrapperPass so that the
polyhedral description of a region, the SCoP, can be constructed and
used in a function pass.
Patch by Utpal Bora <cs14mtech11017 at iith.ac.in>
Differential Revision: http://reviews.llvm.org/D20962
Modified:
polly/trunk/include/polly/LinkAllPasses.h
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/lib/Support/RegisterPasses.cpp
polly/trunk/test/ScopInfo/assume_gep_bounds.ll
polly/trunk/test/ScopInfo/constant_factor_in_parameter.ll
polly/trunk/test/ScopInfo/invariant_load_loop_ub.ll
polly/trunk/test/ScopInfo/loop_affine_bound_0.ll
polly/trunk/test/ScopInfo/loop_affine_bound_1.ll
polly/trunk/test/ScopInfo/loop_affine_bound_2.ll
polly/trunk/test/ScopInfo/multidim_2d-diagonal-matrix.ll
polly/trunk/test/ScopInfo/multidim_many_references.ll
polly/trunk/test/ScopInfo/multidim_nested_start_integer.ll
polly/trunk/test/ScopInfo/multidim_single_and_multidim_array.ll
polly/trunk/test/ScopInfo/non_affine_region_3.ll
polly/trunk/test/ScopInfo/reduction_two_identical_reads.ll
polly/trunk/test/ScopInfo/scalar_to_array.ll
polly/trunk/test/ScopInfo/test-wrapping-in-condition.ll
Modified: polly/trunk/include/polly/LinkAllPasses.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/LinkAllPasses.h?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/include/polly/LinkAllPasses.h (original)
+++ polly/trunk/include/polly/LinkAllPasses.h Mon Jun 27 04:32:30 2016
@@ -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();
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Mon Jun 27 04:32:30 2016
@@ -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
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Mon Jun 27 04:32:30 2016
@@ -4936,3 +4936,72 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTree
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)
Modified: polly/trunk/lib/Support/RegisterPasses.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/RegisterPasses.cpp?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/lib/Support/RegisterPasses.cpp (original)
+++ polly/trunk/lib/Support/RegisterPasses.cpp Mon Jun 27 04:32:30 2016
@@ -155,6 +155,7 @@ void initializePollyPasses(PassRegistry
initializePollyCanonicalizePass(Registry);
initializeScopDetectionPass(Registry);
initializeScopInfoRegionPassPass(Registry);
+ initializeScopInfoWrapperPassPass(Registry);
initializeCodegenCleanupPass(Registry);
}
Modified: polly/trunk/test/ScopInfo/assume_gep_bounds.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/assume_gep_bounds.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/assume_gep_bounds.ll (original)
+++ polly/trunk/test/ScopInfo/assume_gep_bounds.ll Mon Jun 27 04:32:30 2016
@@ -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++)
Modified: polly/trunk/test/ScopInfo/constant_factor_in_parameter.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/constant_factor_in_parameter.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/constant_factor_in_parameter.ll (original)
+++ polly/trunk/test/ScopInfo/constant_factor_in_parameter.ll Mon Jun 27 04:32:30 2016
@@ -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
Modified: polly/trunk/test/ScopInfo/invariant_load_loop_ub.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/invariant_load_loop_ub.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/invariant_load_loop_ub.ll (original)
+++ polly/trunk/test/ScopInfo/invariant_load_loop_ub.ll Mon Jun 27 04:32:30 2016
@@ -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]
Modified: polly/trunk/test/ScopInfo/loop_affine_bound_0.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/loop_affine_bound_0.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/loop_affine_bound_0.ll (original)
+++ polly/trunk/test/ScopInfo/loop_affine_bound_0.ll Mon Jun 27 04:32:30 2016
@@ -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;
Modified: polly/trunk/test/ScopInfo/loop_affine_bound_1.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/loop_affine_bound_1.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/loop_affine_bound_1.ll (original)
+++ polly/trunk/test/ScopInfo/loop_affine_bound_1.ll Mon Jun 27 04:32:30 2016
@@ -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;
Modified: polly/trunk/test/ScopInfo/loop_affine_bound_2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/loop_affine_bound_2.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/loop_affine_bound_2.ll (original)
+++ polly/trunk/test/ScopInfo/loop_affine_bound_2.ll Mon Jun 27 04:32:30 2016
@@ -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;
Modified: polly/trunk/test/ScopInfo/multidim_2d-diagonal-matrix.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_2d-diagonal-matrix.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_2d-diagonal-matrix.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_2d-diagonal-matrix.ll Mon Jun 27 04:32:30 2016
@@ -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:
Modified: polly/trunk/test/ScopInfo/multidim_many_references.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_many_references.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_many_references.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_many_references.ll Mon Jun 27 04:32:30 2016
@@ -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"
Modified: polly/trunk/test/ScopInfo/multidim_nested_start_integer.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_nested_start_integer.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_nested_start_integer.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_nested_start_integer.ll Mon Jun 27 04:32:30 2016
@@ -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]) {
Modified: polly/trunk/test/ScopInfo/multidim_single_and_multidim_array.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_single_and_multidim_array.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_single_and_multidim_array.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_single_and_multidim_array.ll Mon Jun 27 04:32:30 2016
@@ -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"
Modified: polly/trunk/test/ScopInfo/non_affine_region_3.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/non_affine_region_3.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/non_affine_region_3.ll (original)
+++ polly/trunk/test/ScopInfo/non_affine_region_3.ll Mon Jun 27 04:32:30 2016
@@ -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
Modified: polly/trunk/test/ScopInfo/reduction_two_identical_reads.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/reduction_two_identical_reads.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/reduction_two_identical_reads.ll (original)
+++ polly/trunk/test/ScopInfo/reduction_two_identical_reads.ll Mon Jun 27 04:32:30 2016
@@ -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
;
Modified: polly/trunk/test/ScopInfo/scalar_to_array.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/scalar_to_array.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/scalar_to_array.ll (original)
+++ polly/trunk/test/ScopInfo/scalar_to_array.ll Mon Jun 27 04:32:30 2016
@@ -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"
Modified: polly/trunk/test/ScopInfo/test-wrapping-in-condition.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/test-wrapping-in-condition.ll?rev=273856&r1=273855&r2=273856&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/test-wrapping-in-condition.ll (original)
+++ polly/trunk/test/ScopInfo/test-wrapping-in-condition.ll Mon Jun 27 04:32:30 2016
@@ -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 }
More information about the llvm-commits
mailing list