Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 02f6406

Browse files
YangKeaoMeinersbur
authored andcommittedJun 1, 2022
[Polly] Migrate -polly-mse to the new pass manager.
This patch implements the `MaximalStaticExpansion` and its printer in NPM. Reviewed By: Meinersbur Differential Revision: https://reviews.llvm.org/D125870
1 parent a4425cc commit 02f6406

16 files changed

+454
-325
lines changed
 

‎polly/include/polly/LinkAllPasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void initializeManagedMemoryRewritePassPass(llvm::PassRegistry &);
162162
#endif
163163
void initializeIslScheduleOptimizerWrapperPassPass(llvm::PassRegistry &);
164164
void initializeIslScheduleOptimizerPrinterLegacyPassPass(llvm::PassRegistry &);
165-
void initializeMaximalStaticExpanderPass(llvm::PassRegistry &);
165+
void initializeMaximalStaticExpanderWrapperPassPass(llvm::PassRegistry &);
166166
void initializePollyCanonicalizePass(llvm::PassRegistry &);
167167
void initializeFlattenSchedulePass(llvm::PassRegistry &);
168168
void initializeFlattenSchedulePrinterLegacyPassPass(llvm::PassRegistry &);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===- polly/MaximalStaticExpansion.h - expand memory access -*- C++ -*-======//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This pass fully expand the memory accesses of a Scop to get rid of
10+
// dependencies.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef POLLY_MAXIMALSTATICEXPANSION_H
15+
#define POLLY_MAXIMALSTATICEXPANSION_H
16+
17+
#include "polly/ScopPass.h"
18+
#include "llvm/IR/PassManager.h"
19+
20+
namespace polly {
21+
22+
class MaximalStaticExpansionPass
23+
: public llvm::PassInfoMixin<MaximalStaticExpansionPass> {
24+
public:
25+
llvm::PreservedAnalyses run(Scop &, ScopAnalysisManager &,
26+
ScopStandardAnalysisResults &, SPMUpdater &);
27+
};
28+
29+
struct MaximalStaticExpansionPrinterPass
30+
: llvm::PassInfoMixin<MaximalStaticExpansionPrinterPass> {
31+
MaximalStaticExpansionPrinterPass(raw_ostream &OS) : OS(OS) {}
32+
33+
PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
34+
ScopStandardAnalysisResults &SAR, SPMUpdater &);
35+
36+
private:
37+
llvm::raw_ostream &OS;
38+
};
39+
40+
} // namespace polly
41+
42+
#endif /* POLLY_MAXIMALSTATICEXPANSION_H */

‎polly/lib/Support/PollyPasses.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ SCOP_PASS("polly-prune-unprofitable", PruneUnprofitablePass())
4343
SCOP_PASS("polly-opt-isl", IslScheduleOptimizerPass())
4444
SCOP_PASS("print<polly-opt-isl>", IslScheduleOptimizerPrinterPass(llvm::outs()))
4545
SCOP_PASS("polly-dce", DeadCodeElimPass())
46+
SCOP_PASS("polly-mse", MaximalStaticExpansionPass())
47+
SCOP_PASS("print<polly-mse>", MaximalStaticExpansionPrinterPass(llvm::outs()))
4648
#undef SCOP_PASS

‎polly/lib/Support/RegisterPasses.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "polly/ForwardOpTree.h"
3131
#include "polly/JSONExporter.h"
3232
#include "polly/LinkAllPasses.h"
33+
#include "polly/MaximalStaticExpansion.h"
3334
#include "polly/PolyhedralInfo.h"
3435
#include "polly/PruneUnprofitable.h"
3536
#include "polly/ScheduleOptimizer.h"
@@ -263,7 +264,7 @@ void initializePollyPasses(llvm::PassRegistry &Registry) {
263264
initializeJSONExporterPass(Registry);
264265
initializeJSONImporterPass(Registry);
265266
initializeJSONImporterPrinterLegacyPassPass(Registry);
266-
initializeMaximalStaticExpanderPass(Registry);
267+
initializeMaximalStaticExpanderWrapperPassPass(Registry);
267268
initializeIslAstInfoWrapperPassPass(Registry);
268269
initializeIslAstInfoPrinterLegacyPassPass(Registry);
269270
initializeIslScheduleOptimizerWrapperPassPass(Registry);

‎polly/lib/Transform/MaximalStaticExpansion.cpp

Lines changed: 390 additions & 323 deletions
Large diffs are not rendered by default.

‎polly/test/MaximalStaticExpansion/load_after_store_same_statement.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-mse -polly-print-scops -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1| FileCheck %s --check-prefix=MSE
4+
; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
35
;
46
; Verify that the expansion of an array with load after store in a same statement is not done.
57
;

‎polly/test/MaximalStaticExpansion/read_from_original.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
; RUN: opt %loadPolly -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
; RUN: opt %loadPolly -polly-mse -polly-print-scops -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1| FileCheck %s --check-prefix=MSE
4+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
35
;
46
; Verify that Polly detects problems and does not expand the array
57
;

‎polly/test/MaximalStaticExpansion/too_many_writes.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
; RUN: opt %loadPolly -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
; RUN: opt %loadPolly -polly-mse -polly-print-scops -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
4+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
35
;
46
; Verify that Polly detects problems and does not expand the array
57
;

‎polly/test/MaximalStaticExpansion/working_deps_between_inners.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt %loadPolly -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
;
34
; Verify that the accesses are correctly expanded for MemoryKind::Array
45
;

‎polly/test/MaximalStaticExpansion/working_deps_between_inners_phi.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
; RUN: opt %loadPolly -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
; RUN: opt %loadPolly -polly-mse -polly-print-scops -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
4+
; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
35
;
46
; Verify that the accesses are correctly expanded for MemoryKind::Array and MemoryKind::PHI.
57
; tmp_06_phi is not expanded because it need copy in.

‎polly/test/MaximalStaticExpansion/working_expansion.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt %loadPolly -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
;
34
; Verify that the accesses are correctly expanded for MemoryKind::Array
45
;

‎polly/test/MaximalStaticExpansion/working_expansion_multiple_dependences_per_statement.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
;
34
; Verify that the accesses are correctly expanded
45
;

‎polly/test/MaximalStaticExpansion/working_expansion_multiple_instruction_per_statement.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
;
34
; Verify that the accesses are correctly expanded
45
;

‎polly/test/MaximalStaticExpansion/working_phi_expansion.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
; RUN: opt %loadPolly -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
; RUN: opt %loadPolly -polly-mse -polly-print-scops -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
4+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
35
;
46
; Verify that the accesses are correctly expanded for MemoryKind::PHI
57
; tmp_04 is not expanded because it need copy-in.

‎polly/test/MaximalStaticExpansion/working_phi_two_scalars.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-mse -polly-print-scops -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
4+
; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
35
;
46
; Verify that the accesses are correctly expanded for MemoryKind::PHI
57
; tmp_05 and tmp2_06 are not expanded because they need copy-in.

‎polly/test/MaximalStaticExpansion/working_value_expansion.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt %loadPolly -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2+
; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
23
;
34
; Verify that the accesses are correctly expanded for MemoryKind::Value
45
;

0 commit comments

Comments
 (0)
Please sign in to comment.