Skip to content

Commit a22d1c2

Browse files
Revert "[Polly] Introduce PhaseManager and remove LPM support (#125442)"
This reverts commit e987ab1. This broke premerge: 1. https://lab.llvm.org/staging/#/builders/192/builds/9521 2. https://github.com/llvm/llvm-project/actions/runs/19054182009 Notably this did not break inside the PR. Not exactly sure why. I realize that there is a lot of test churn here, but they're largely in polly where commit frequency is much lower, so a reapply of the patch should be clean.
1 parent 02d93f7 commit a22d1c2

File tree

1,143 files changed

+4460
-2700
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,143 files changed

+4460
-2700
lines changed

polly/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,3 @@ In Polly |version| the following important changes have been incorporated.
1313

1414
* ScopInliner has been updated for the New Pass Manager.
1515

16-
* Polly now is a monolithic pass split into phases.
17-
18-
* Polly's support for the legacy pass manager has been removed.
19-

polly/include/polly/Canonicalization.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
#include "llvm/Passes/PassBuilder.h"
1313

14+
namespace llvm {
15+
namespace legacy {
16+
class PassManagerBase;
17+
}
18+
} // namespace llvm
19+
1420
namespace polly {
1521

1622
/// Schedule a set of canonicalization passes to prepare for Polly.
@@ -20,6 +26,8 @@ namespace polly {
2026
/// into a canonical form that simplifies the analysis and optimization passes
2127
/// of Polly. The set of optimization passes scheduled here is probably not yet
2228
/// optimal. TODO: Optimize the set of canonicalization passes.
29+
void registerCanonicalicationPasses(llvm::legacy::PassManagerBase &PM);
30+
2331
llvm::FunctionPassManager
2432
buildCanonicalicationPassesForNPM(llvm::ModulePassManager &MPM,
2533
llvm::OptimizationLevel Level);

polly/include/polly/CodeGen/CodeGeneration.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "llvm/IR/PassManager.h"
1515

1616
namespace polly {
17-
class IslAstInfo;
1817

1918
enum VectorizerChoice {
2019
VECTORIZER_NONE,
@@ -34,8 +33,6 @@ struct CodeGenerationPass final : PassInfoMixin<CodeGenerationPass> {
3433
};
3534

3635
extern bool PerfMonitoring;
37-
38-
bool runCodeGeneration(Scop &S, llvm::RegionInfo &RI, IslAstInfo &AI);
3936
} // namespace polly
4037

4138
#endif // POLLY_CODEGENERATION_H

polly/include/polly/CodeGen/IslAst.h

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#ifndef POLLY_ISLAST_H
2222
#define POLLY_ISLAST_H
2323

24-
#include "polly/DependenceInfo.h"
2524
#include "polly/ScopPass.h"
2625
#include "llvm/ADT/SmallPtrSet.h"
2726
#include "llvm/IR/PassManager.h"
@@ -173,6 +172,33 @@ struct IslAstAnalysis : AnalysisInfoMixin<IslAstAnalysis> {
173172
ScopStandardAnalysisResults &SAR);
174173
};
175174

175+
class IslAstInfoWrapperPass final : public ScopPass {
176+
std::unique_ptr<IslAstInfo> Ast;
177+
178+
public:
179+
static char ID;
180+
181+
IslAstInfoWrapperPass() : ScopPass(ID) {}
182+
183+
IslAstInfo &getAI() { return *Ast; }
184+
const IslAstInfo &getAI() const { return *Ast; }
185+
186+
/// Build the AST for the given SCoP @p S.
187+
bool runOnScop(Scop &S) override;
188+
189+
/// Register all analyses and transformation required.
190+
void getAnalysisUsage(AnalysisUsage &AU) const override;
191+
192+
/// Release the internal memory.
193+
void releaseMemory() override;
194+
195+
/// Print a source code representation of the program.
196+
void printScop(raw_ostream &OS, Scop &S) const override;
197+
};
198+
199+
llvm::Pass *createIslAstInfoWrapperPassPass();
200+
llvm::Pass *createIslAstInfoPrinterLegacyPass(llvm::raw_ostream &OS);
201+
176202
struct IslAstPrinterPass final : PassInfoMixin<IslAstPrinterPass> {
177203
IslAstPrinterPass(raw_ostream &OS) : OS(OS) {}
178204

@@ -181,9 +207,11 @@ struct IslAstPrinterPass final : PassInfoMixin<IslAstPrinterPass> {
181207

182208
raw_ostream &OS;
183209
};
184-
185-
std::unique_ptr<IslAstInfo> runIslAstGen(Scop &S,
186-
DependenceAnalysis::Result &DA);
187210
} // namespace polly
188211

212+
namespace llvm {
213+
void initializeIslAstInfoWrapperPassPass(llvm::PassRegistry &);
214+
void initializeIslAstInfoPrinterLegacyPassPass(llvm::PassRegistry &);
215+
} // namespace llvm
216+
189217
#endif // POLLY_ISLAST_H

polly/include/polly/CodePreparation.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515

1616
#include "llvm/IR/PassManager.h"
1717

18-
namespace llvm {
19-
class DominatorTree;
20-
class LoopInfo;
21-
class RegionInfo;
22-
} // namespace llvm
23-
2418
namespace polly {
2519
struct CodePreparationPass final : llvm::PassInfoMixin<CodePreparationPass> {
2620
llvm::PreservedAnalyses run(llvm::Function &F,

polly/include/polly/DeLICM.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@
2121
#include "isl/isl-noexceptions.h"
2222

2323
namespace llvm {
24+
class PassRegistry;
25+
class Pass;
2426
class raw_ostream;
2527
} // namespace llvm
2628

2729
namespace polly {
30+
/// Create a new DeLICM pass instance.
31+
llvm::Pass *createDeLICMWrapperPass();
32+
llvm::Pass *createDeLICMPrinterLegacyPass(llvm::raw_ostream &OS);
2833

2934
struct DeLICMPass final : llvm::PassInfoMixin<DeLICMPass> {
3035
DeLICMPass() {}
@@ -54,7 +59,11 @@ bool isConflicting(isl::union_set ExistingOccupied,
5459
isl::union_map ProposedWrites,
5560
llvm::raw_ostream *OS = nullptr, unsigned Indent = 0);
5661

57-
bool runDeLICM(Scop &S);
5862
} // namespace polly
5963

64+
namespace llvm {
65+
void initializeDeLICMWrapperPassPass(llvm::PassRegistry &);
66+
void initializeDeLICMPrinterLegacyPassPass(llvm::PassRegistry &);
67+
} // namespace llvm
68+
6069
#endif /* POLLY_DELICM_H */

polly/include/polly/DeadCodeElimination.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@
1313
#ifndef POLLY_DEADCODEELIMINATION_H
1414
#define POLLY_DEADCODEELIMINATION_H
1515

16-
#include "polly/DependenceInfo.h"
1716
#include "polly/ScopPass.h"
1817

18+
namespace llvm {
19+
class PassRegistry;
20+
class Pass;
21+
class raw_ostream;
22+
} // namespace llvm
23+
1924
namespace polly {
25+
llvm::Pass *createDeadCodeElimWrapperPass();
2026

2127
struct DeadCodeElimPass final : llvm::PassInfoMixin<DeadCodeElimPass> {
2228
DeadCodeElimPass() {}
@@ -25,7 +31,10 @@ struct DeadCodeElimPass final : llvm::PassInfoMixin<DeadCodeElimPass> {
2531
ScopStandardAnalysisResults &SAR, SPMUpdater &U);
2632
};
2733

28-
bool runDeadCodeElim(Scop &S, DependenceAnalysis::Result &DA);
2934
} // namespace polly
3035

36+
namespace llvm {
37+
void initializeDeadCodeElimWrapperPassPass(llvm::PassRegistry &);
38+
} // namespace llvm
39+
3140
#endif /* POLLY_DEADCODEELIMINATION_H */

polly/include/polly/DependenceInfo.h

Lines changed: 103 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class Dependences final {
145145
friend struct DependenceAnalysis;
146146
friend struct DependenceInfoPrinterPass;
147147
friend class DependenceInfo;
148+
friend class DependenceInfoWrapperPass;
148149

149150
/// Destructor that will free internal objects.
150151
~Dependences() { releaseMemory(); }
@@ -191,8 +192,6 @@ class Dependences final {
191192
const AnalysisLevel Level;
192193
};
193194

194-
extern Dependences::AnalysisLevel OptAnalysisLevel;
195-
196195
struct DependenceAnalysis final : public AnalysisInfoMixin<DependenceAnalysis> {
197196
static AnalysisKey Key;
198197
struct Result {
@@ -233,7 +232,108 @@ struct DependenceInfoPrinterPass final
233232
raw_ostream &OS;
234233
};
235234

236-
DependenceAnalysis::Result runDependenceAnalysis(Scop &S);
235+
class DependenceInfo final : public ScopPass {
236+
public:
237+
static char ID;
238+
239+
/// Construct a new DependenceInfo pass.
240+
DependenceInfo() : ScopPass(ID) {}
241+
242+
/// Return the dependence information for the current SCoP.
243+
///
244+
/// @param Level The granularity of dependence analysis result.
245+
///
246+
/// @return The dependence analysis result
247+
///
248+
const Dependences &getDependences(Dependences::AnalysisLevel Level);
249+
250+
/// Recompute dependences from schedule and memory accesses.
251+
const Dependences &recomputeDependences(Dependences::AnalysisLevel Level);
252+
253+
/// Invalidate the dependence information and recompute it when needed again.
254+
/// May be required when the underlying Scop was changed in a way that would
255+
/// add new dependencies (e.g. between new statement instances insierted into
256+
/// the SCoP) or intentionally breaks existing ones. It is not required when
257+
/// updating the schedule that conforms the existing dependencies.
258+
void abandonDependences();
259+
260+
/// Compute the dependence information for the SCoP @p S.
261+
bool runOnScop(Scop &S) override;
262+
263+
/// Print the dependences for the given SCoP to @p OS.
264+
void printScop(raw_ostream &OS, Scop &) const override;
265+
266+
/// Release the internal memory.
267+
void releaseMemory() override {
268+
for (auto &d : D)
269+
d.reset();
270+
}
271+
272+
/// Register all analyses and transformation required.
273+
void getAnalysisUsage(AnalysisUsage &AU) const override;
274+
275+
private:
276+
Scop *S;
277+
278+
/// Dependences struct for the current SCoP.
279+
std::unique_ptr<Dependences> D[Dependences::NumAnalysisLevels];
280+
};
281+
282+
llvm::Pass *createDependenceInfoPass();
283+
llvm::Pass *createDependenceInfoPrinterLegacyPass(llvm::raw_ostream &OS);
284+
285+
/// Construct a new DependenceInfoWrapper pass.
286+
class DependenceInfoWrapperPass final : public FunctionPass {
287+
public:
288+
static char ID;
289+
290+
/// Construct a new DependenceInfoWrapper pass.
291+
DependenceInfoWrapperPass() : FunctionPass(ID) {}
292+
293+
/// Return the dependence information for the given SCoP.
294+
///
295+
/// @param S SCoP object.
296+
/// @param Level The granularity of dependence analysis result.
297+
///
298+
/// @return The dependence analysis result
299+
///
300+
const Dependences &getDependences(Scop *S, Dependences::AnalysisLevel Level);
301+
302+
/// Recompute dependences from schedule and memory accesses.
303+
const Dependences &recomputeDependences(Scop *S,
304+
Dependences::AnalysisLevel Level);
305+
306+
/// Compute the dependence information on-the-fly for the function.
307+
bool runOnFunction(Function &F) override;
308+
309+
/// Print the dependences for the current function to @p OS.
310+
void print(raw_ostream &OS, const Module *M = nullptr) const override;
311+
312+
/// Release the internal memory.
313+
void releaseMemory() override { ScopToDepsMap.clear(); }
314+
315+
/// Register all analyses and transformation required.
316+
void getAnalysisUsage(AnalysisUsage &AU) const override;
317+
318+
private:
319+
using ScopToDepsMapTy = DenseMap<Scop *, std::unique_ptr<Dependences>>;
320+
321+
/// Scop to Dependence map for the current function.
322+
ScopToDepsMapTy ScopToDepsMap;
323+
};
324+
325+
llvm::Pass *createDependenceInfoWrapperPassPass();
326+
llvm::Pass *
327+
createDependenceInfoPrinterLegacyFunctionPass(llvm::raw_ostream &OS);
328+
237329
} // namespace polly
238330

331+
namespace llvm {
332+
void initializeDependenceInfoPass(llvm::PassRegistry &);
333+
void initializeDependenceInfoPrinterLegacyPassPass(llvm::PassRegistry &);
334+
void initializeDependenceInfoWrapperPassPass(llvm::PassRegistry &);
335+
void initializeDependenceInfoPrinterLegacyFunctionPassPass(
336+
llvm::PassRegistry &);
337+
} // namespace llvm
338+
239339
#endif

polly/include/polly/FlattenSchedule.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@
1515
#ifndef POLLY_FLATTENSCHEDULE_H
1616
#define POLLY_FLATTENSCHEDULE_H
1717

18-
namespace polly {
19-
class Scop;
18+
namespace llvm {
19+
class PassRegistry;
20+
class Pass;
21+
class raw_ostream;
22+
} // namespace llvm
2023

21-
void runFlattenSchedulePass(Scop &S);
24+
namespace polly {
25+
llvm::Pass *createFlattenSchedulePass();
26+
llvm::Pass *createFlattenSchedulePrinterLegacyPass(llvm::raw_ostream &OS);
2227
} // namespace polly
2328

29+
namespace llvm {
30+
void initializeFlattenSchedulePass(llvm::PassRegistry &);
31+
void initializeFlattenSchedulePrinterLegacyPassPass(llvm::PassRegistry &);
32+
} // namespace llvm
33+
2434
#endif /* POLLY_FLATTENSCHEDULE_H */

polly/include/polly/ForwardOpTree.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515

1616
#include "polly/ScopPass.h"
1717

18+
namespace llvm {
19+
class PassRegistry;
20+
} // namespace llvm
21+
1822
namespace polly {
23+
llvm::Pass *createForwardOpTreeWrapperPass();
24+
llvm::Pass *createForwardOpTreePrinterLegacyPass(llvm::raw_ostream &OS);
1925

2026
struct ForwardOpTreePass final : llvm::PassInfoMixin<ForwardOpTreePass> {
2127
ForwardOpTreePass() {}
@@ -35,15 +41,11 @@ struct ForwardOpTreePrinterPass final
3541
llvm::raw_ostream &OS;
3642
};
3743

38-
/// Pass that redirects scalar reads to array elements that are known to contain
39-
/// the same value.
40-
///
41-
/// This reduces the number of scalar accesses and therefore potentially
42-
/// increases the freedom of the scheduler. In the ideal case, all reads of a
43-
/// scalar definition are redirected (We currently do not care about removing
44-
/// the write in this case). This is also useful for the main DeLICM pass as
45-
/// there are less scalars to be mapped.
46-
bool runForwardOpTree(Scop &S);
4744
} // namespace polly
4845

46+
namespace llvm {
47+
void initializeForwardOpTreeWrapperPassPass(PassRegistry &);
48+
void initializeForwardOpTreePrinterLegacyPassPass(PassRegistry &);
49+
} // namespace llvm
50+
4951
#endif // POLLY_FORWARDOPTREE_H

0 commit comments

Comments
 (0)