[Polly] Remove ScopPass infrastructure (#125783)
PR #125442 replaces the pass-based Polly architecture with a monolithic pass consisting of phases. Reasons listed in https://github.com/llvm/llvm-project/pull/125442. With this change, the SCoP-passes became redundant problematic versions of the same functionality and are removed.
This commit is contained in:
parent
c61a4406db
commit
f12ad95991
@ -17,3 +17,5 @@ In Polly |version| the following important changes have been incorporated.
|
||||
|
||||
* Polly's support for the legacy pass manager has been removed.
|
||||
|
||||
* The infrastructure around ScopPasses has been removed.
|
||||
|
||||
|
||||
@ -10,12 +10,16 @@
|
||||
#define POLLY_CODEGENERATION_H
|
||||
|
||||
#include "polly/CodeGen/IRBuilder.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
class RegionInfo;
|
||||
}
|
||||
|
||||
namespace polly {
|
||||
class IslAstInfo;
|
||||
|
||||
using llvm::BasicBlock;
|
||||
|
||||
enum VectorizerChoice {
|
||||
VECTORIZER_NONE,
|
||||
VECTORIZER_STRIPMINE,
|
||||
@ -28,11 +32,6 @@ extern VectorizerChoice PollyVectorizerChoice;
|
||||
/// UnreachableInst.
|
||||
void markBlockUnreachable(BasicBlock &Block, PollyIRBuilder &Builder);
|
||||
|
||||
struct CodeGenerationPass final : PassInfoMixin<CodeGenerationPass> {
|
||||
PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &AR, SPMUpdater &U);
|
||||
};
|
||||
|
||||
extern bool PerfMonitoring;
|
||||
|
||||
bool runCodeGeneration(Scop &S, llvm::RegionInfo &RI, IslAstInfo &AI);
|
||||
|
||||
@ -22,12 +22,11 @@
|
||||
#define POLLY_ISLAST_H
|
||||
|
||||
#include "polly/DependenceInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "isl/ctx.h"
|
||||
|
||||
namespace polly {
|
||||
using llvm::raw_ostream;
|
||||
using llvm::SmallPtrSet;
|
||||
|
||||
class Dependences;
|
||||
@ -164,24 +163,6 @@ public:
|
||||
///}
|
||||
};
|
||||
|
||||
struct IslAstAnalysis : AnalysisInfoMixin<IslAstAnalysis> {
|
||||
static AnalysisKey Key;
|
||||
|
||||
using Result = IslAstInfo;
|
||||
|
||||
IslAstInfo run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR);
|
||||
};
|
||||
|
||||
struct IslAstPrinterPass final : PassInfoMixin<IslAstPrinterPass> {
|
||||
IslAstPrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
|
||||
PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &U);
|
||||
|
||||
raw_ostream &OS;
|
||||
};
|
||||
|
||||
std::unique_ptr<IslAstInfo> runIslAstGen(Scop &S,
|
||||
DependenceAnalysis::Result &DA);
|
||||
} // namespace polly
|
||||
|
||||
@ -13,19 +13,16 @@
|
||||
#ifndef POLLY_CODEPREPARATION_H
|
||||
#define POLLY_CODEPREPARATION_H
|
||||
|
||||
#include "llvm/IR/PassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
class DominatorTree;
|
||||
class Function;
|
||||
class LoopInfo;
|
||||
class RegionInfo;
|
||||
} // namespace llvm
|
||||
|
||||
namespace polly {
|
||||
struct CodePreparationPass final : llvm::PassInfoMixin<CodePreparationPass> {
|
||||
llvm::PreservedAnalyses run(llvm::Function &F,
|
||||
llvm::FunctionAnalysisManager &FAM);
|
||||
};
|
||||
bool runCodePreparation(llvm::Function &F, llvm::DominatorTree *DT,
|
||||
llvm::LoopInfo *LI, llvm::RegionInfo *RI);
|
||||
} // namespace polly
|
||||
|
||||
#endif /* POLLY_CODEPREPARATION_H */
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
#ifndef POLLY_DELICM_H
|
||||
#define POLLY_DELICM_H
|
||||
|
||||
#include "polly/ScopPass.h"
|
||||
#include "isl/isl-noexceptions.h"
|
||||
|
||||
namespace llvm {
|
||||
@ -25,23 +24,7 @@ class raw_ostream;
|
||||
} // namespace llvm
|
||||
|
||||
namespace polly {
|
||||
|
||||
struct DeLICMPass final : llvm::PassInfoMixin<DeLICMPass> {
|
||||
DeLICMPass() {}
|
||||
|
||||
llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U);
|
||||
};
|
||||
|
||||
struct DeLICMPrinterPass final : llvm::PassInfoMixin<DeLICMPrinterPass> {
|
||||
DeLICMPrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
|
||||
PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &);
|
||||
|
||||
private:
|
||||
llvm::raw_ostream &OS;
|
||||
};
|
||||
class Scop;
|
||||
|
||||
/// Determine whether two lifetimes are conflicting.
|
||||
///
|
||||
|
||||
@ -14,17 +14,9 @@
|
||||
#define POLLY_DEADCODEELIMINATION_H
|
||||
|
||||
#include "polly/DependenceInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
|
||||
namespace polly {
|
||||
|
||||
struct DeadCodeElimPass final : llvm::PassInfoMixin<DeadCodeElimPass> {
|
||||
DeadCodeElimPass() {}
|
||||
|
||||
llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U);
|
||||
};
|
||||
|
||||
bool runDeadCodeElim(Scop &S, DependenceAnalysis::Result &DA);
|
||||
} // namespace polly
|
||||
|
||||
|
||||
@ -22,11 +22,20 @@
|
||||
#ifndef POLLY_DEPENDENCE_INFO_H
|
||||
#define POLLY_DEPENDENCE_INFO_H
|
||||
|
||||
#include "polly/ScopPass.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "isl/ctx.h"
|
||||
#include "isl/isl-noexceptions.h"
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
}
|
||||
|
||||
namespace polly {
|
||||
class MemoryAccess;
|
||||
class Scop;
|
||||
class ScopStmt;
|
||||
|
||||
using llvm::DenseMap;
|
||||
|
||||
/// The accumulated dependence information for a SCoP.
|
||||
///
|
||||
@ -193,8 +202,7 @@ private:
|
||||
|
||||
extern Dependences::AnalysisLevel OptAnalysisLevel;
|
||||
|
||||
struct DependenceAnalysis final : public AnalysisInfoMixin<DependenceAnalysis> {
|
||||
static AnalysisKey Key;
|
||||
struct DependenceAnalysis final {
|
||||
struct Result {
|
||||
Scop &S;
|
||||
std::unique_ptr<Dependences> D[Dependences::NumAnalysisLevels];
|
||||
@ -219,18 +227,6 @@ struct DependenceAnalysis final : public AnalysisInfoMixin<DependenceAnalysis> {
|
||||
/// dependencies.
|
||||
void abandonDependences();
|
||||
};
|
||||
Result run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR);
|
||||
};
|
||||
|
||||
struct DependenceInfoPrinterPass final
|
||||
: PassInfoMixin<DependenceInfoPrinterPass> {
|
||||
DependenceInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
|
||||
PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &);
|
||||
|
||||
raw_ostream &OS;
|
||||
};
|
||||
|
||||
DependenceAnalysis::Result runDependenceAnalysis(Scop &S);
|
||||
|
||||
@ -13,27 +13,8 @@
|
||||
#ifndef POLLY_FORWARDOPTREE_H
|
||||
#define POLLY_FORWARDOPTREE_H
|
||||
|
||||
#include "polly/ScopPass.h"
|
||||
|
||||
namespace polly {
|
||||
|
||||
struct ForwardOpTreePass final : llvm::PassInfoMixin<ForwardOpTreePass> {
|
||||
ForwardOpTreePass() {}
|
||||
|
||||
llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U);
|
||||
};
|
||||
|
||||
struct ForwardOpTreePrinterPass final
|
||||
: llvm::PassInfoMixin<ForwardOpTreePrinterPass> {
|
||||
ForwardOpTreePrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
|
||||
PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &);
|
||||
|
||||
private:
|
||||
llvm::raw_ostream &OS;
|
||||
};
|
||||
class Scop;
|
||||
|
||||
/// Pass that redirects scalar reads to array elements that are known to contain
|
||||
/// the same value.
|
||||
|
||||
@ -10,26 +10,15 @@
|
||||
#define POLLY_JSONEXPORTER_H
|
||||
|
||||
#include "polly/DependenceInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
|
||||
namespace polly {
|
||||
|
||||
/// This pass exports a scop to a jscop file. The filename is generated from the
|
||||
/// concatenation of the function and scop name.
|
||||
struct JSONExportPass final : llvm::PassInfoMixin<JSONExportPass> {
|
||||
llvm::PreservedAnalyses run(Scop &, ScopAnalysisManager &,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &);
|
||||
};
|
||||
|
||||
/// This pass imports a scop from a jscop file. The filename is deduced from the
|
||||
/// concatenation of the function and scop name.
|
||||
struct JSONImportPass final : llvm::PassInfoMixin<JSONExportPass> {
|
||||
llvm::PreservedAnalyses run(Scop &, ScopAnalysisManager &,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &);
|
||||
};
|
||||
|
||||
void runImportJSON(Scop &S, DependenceAnalysis::Result &DA);
|
||||
|
||||
/// This pass exports a scop to a jscop file. The filename is generated from the
|
||||
/// concatenation of the function and scop name.
|
||||
void runExportJSON(Scop &S);
|
||||
} // namespace polly
|
||||
|
||||
|
||||
@ -15,29 +15,9 @@
|
||||
#define POLLY_MAXIMALSTATICEXPANSION_H
|
||||
|
||||
#include "polly/DependenceInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
|
||||
namespace polly {
|
||||
|
||||
class MaximalStaticExpansionPass
|
||||
: public llvm::PassInfoMixin<MaximalStaticExpansionPass> {
|
||||
public:
|
||||
llvm::PreservedAnalyses run(Scop &, ScopAnalysisManager &,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &);
|
||||
};
|
||||
|
||||
struct MaximalStaticExpansionPrinterPass
|
||||
: llvm::PassInfoMixin<MaximalStaticExpansionPrinterPass> {
|
||||
MaximalStaticExpansionPrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
|
||||
PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &);
|
||||
|
||||
private:
|
||||
llvm::raw_ostream &OS;
|
||||
};
|
||||
|
||||
void runMaximalStaticExpansion(Scop &S, DependenceAnalysis::Result &DI);
|
||||
} // namespace polly
|
||||
|
||||
|
||||
@ -17,14 +17,16 @@
|
||||
|
||||
#include "polly/DependenceInfo.h"
|
||||
#include "llvm/ADT/Bitset.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include <stddef.h>
|
||||
|
||||
namespace llvm {
|
||||
class Function;
|
||||
class Error;
|
||||
template <typename EnumT> struct enum_iteration_traits;
|
||||
} // namespace llvm
|
||||
|
||||
namespace polly {
|
||||
using llvm::Function;
|
||||
using llvm::StringRef;
|
||||
|
||||
/// Phases (in execution order) within the Polly pass.
|
||||
enum class PassPhase {
|
||||
|
||||
@ -13,17 +13,8 @@
|
||||
#ifndef POLLY_PRUNEUNPROFITABLE_H
|
||||
#define POLLY_PRUNEUNPROFITABLE_H
|
||||
|
||||
#include "polly/ScopPass.h"
|
||||
|
||||
namespace polly {
|
||||
|
||||
struct PruneUnprofitablePass final
|
||||
: llvm::PassInfoMixin<PruneUnprofitablePass> {
|
||||
PruneUnprofitablePass() {}
|
||||
|
||||
llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U);
|
||||
};
|
||||
class Scop;
|
||||
|
||||
bool runPruneUnprofitable(Scop &S);
|
||||
} // namespace polly
|
||||
|
||||
@ -10,29 +10,13 @@
|
||||
#define POLLY_SCHEDULEOPTIMIZER_H
|
||||
|
||||
#include "polly/DependenceInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
|
||||
namespace llvm {
|
||||
class TargetTransformInfo;
|
||||
}
|
||||
|
||||
namespace polly {
|
||||
|
||||
struct IslScheduleOptimizerPass final
|
||||
: llvm::PassInfoMixin<IslScheduleOptimizerPass> {
|
||||
IslScheduleOptimizerPass() {}
|
||||
|
||||
llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U);
|
||||
};
|
||||
|
||||
struct IslScheduleOptimizerPrinterPass final
|
||||
: llvm::PassInfoMixin<IslScheduleOptimizerPrinterPass> {
|
||||
IslScheduleOptimizerPrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
|
||||
PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &);
|
||||
|
||||
private:
|
||||
llvm::raw_ostream &OS;
|
||||
};
|
||||
|
||||
void runIslScheduleOptimizer(Scop &S, llvm::TargetTransformInfo *TTI,
|
||||
DependenceAnalysis::Result &Deps);
|
||||
} // namespace polly
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
#include "llvm/Analysis/RegionInfo.h"
|
||||
#include "llvm/Analysis/RegionIterator.h"
|
||||
#include "llvm/Analysis/RegionPrinter.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
#include "llvm/IR/DebugLoc.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
#include "isl/isl-noexceptions.h"
|
||||
#include <cassert>
|
||||
|
||||
@ -1,264 +0,0 @@
|
||||
//===--------- ScopPass.h - Pass for Static Control Parts --------*-C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the ScopPass class. ScopPasses are just RegionPasses,
|
||||
// except they operate on Polly IR (Scop and ScopStmt) built by ScopInfo Pass.
|
||||
// Because they operate on Polly IR, not the LLVM IR, ScopPasses are not allowed
|
||||
// to modify the LLVM IR. Due to this limitation, the ScopPass class takes
|
||||
// care of declaring that no LLVM passes are invalidated.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef POLLY_SCOP_PASS_H
|
||||
#define POLLY_SCOP_PASS_H
|
||||
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "llvm/ADT/PriorityWorklist.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/IR/PassManagerImpl.h"
|
||||
|
||||
namespace polly {
|
||||
using llvm::AllAnalysesOn;
|
||||
using llvm::AnalysisManager;
|
||||
using llvm::DominatorTreeAnalysis;
|
||||
using llvm::InnerAnalysisManagerProxy;
|
||||
using llvm::LoopAnalysis;
|
||||
using llvm::OuterAnalysisManagerProxy;
|
||||
using llvm::PassManager;
|
||||
using llvm::RegionInfoAnalysis;
|
||||
using llvm::ScalarEvolutionAnalysis;
|
||||
using llvm::SmallPriorityWorklist;
|
||||
using llvm::TargetIRAnalysis;
|
||||
using llvm::TargetTransformInfo;
|
||||
|
||||
class Scop;
|
||||
class SPMUpdater;
|
||||
struct ScopStandardAnalysisResults;
|
||||
|
||||
using ScopAnalysisManager =
|
||||
AnalysisManager<Scop, ScopStandardAnalysisResults &>;
|
||||
using ScopAnalysisManagerFunctionProxy =
|
||||
InnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
|
||||
using FunctionAnalysisManagerScopProxy =
|
||||
OuterAnalysisManagerProxy<FunctionAnalysisManager, Scop,
|
||||
ScopStandardAnalysisResults &>;
|
||||
} // namespace polly
|
||||
|
||||
namespace llvm {
|
||||
using polly::Scop;
|
||||
using polly::ScopAnalysisManager;
|
||||
using polly::ScopAnalysisManagerFunctionProxy;
|
||||
using polly::ScopInfo;
|
||||
using polly::ScopStandardAnalysisResults;
|
||||
using polly::SPMUpdater;
|
||||
|
||||
template <>
|
||||
class InnerAnalysisManagerProxy<ScopAnalysisManager, Function>::Result {
|
||||
public:
|
||||
explicit Result(ScopAnalysisManager &InnerAM, ScopInfo &SI)
|
||||
: InnerAM(&InnerAM), SI(&SI) {}
|
||||
Result(Result &&R) : InnerAM(std::move(R.InnerAM)), SI(R.SI) {
|
||||
R.InnerAM = nullptr;
|
||||
}
|
||||
Result &operator=(Result &&RHS) {
|
||||
InnerAM = RHS.InnerAM;
|
||||
SI = RHS.SI;
|
||||
RHS.InnerAM = nullptr;
|
||||
return *this;
|
||||
}
|
||||
~Result() {
|
||||
if (!InnerAM)
|
||||
return;
|
||||
InnerAM->clear();
|
||||
}
|
||||
|
||||
ScopAnalysisManager &getManager() { return *InnerAM; }
|
||||
|
||||
bool invalidate(Function &F, const PreservedAnalyses &PA,
|
||||
FunctionAnalysisManager::Invalidator &Inv);
|
||||
|
||||
private:
|
||||
ScopAnalysisManager *InnerAM;
|
||||
ScopInfo *SI;
|
||||
};
|
||||
|
||||
// A partial specialization of the require analysis template pass to handle
|
||||
// extra parameters
|
||||
template <typename AnalysisT>
|
||||
struct RequireAnalysisPass<AnalysisT, Scop, ScopAnalysisManager,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &>
|
||||
: PassInfoMixin<
|
||||
RequireAnalysisPass<AnalysisT, Scop, ScopAnalysisManager,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &>> {
|
||||
PreservedAnalyses run(Scop &L, ScopAnalysisManager &AM,
|
||||
ScopStandardAnalysisResults &AR, SPMUpdater &) {
|
||||
(void)AM.template getResult<AnalysisT>(L, AR);
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
InnerAnalysisManagerProxy<ScopAnalysisManager, Function>::Result
|
||||
InnerAnalysisManagerProxy<ScopAnalysisManager, Function>::run(
|
||||
Function &F, FunctionAnalysisManager &FAM);
|
||||
|
||||
template <>
|
||||
PreservedAnalyses
|
||||
PassManager<Scop, ScopAnalysisManager, ScopStandardAnalysisResults &,
|
||||
SPMUpdater &>::run(Scop &InitialS, ScopAnalysisManager &AM,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &);
|
||||
extern template class PassManager<Scop, ScopAnalysisManager,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &>;
|
||||
extern template class InnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
|
||||
extern template class OuterAnalysisManagerProxy<FunctionAnalysisManager, Scop,
|
||||
ScopStandardAnalysisResults &>;
|
||||
} // namespace llvm
|
||||
|
||||
namespace polly {
|
||||
|
||||
template <typename AnalysisManagerT, typename IRUnitT, typename... ExtraArgTs>
|
||||
class OwningInnerAnalysisManagerProxy final
|
||||
: public InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT> {
|
||||
public:
|
||||
OwningInnerAnalysisManagerProxy()
|
||||
: InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT>(InnerAM) {}
|
||||
using Result = typename InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT,
|
||||
ExtraArgTs...>::Result;
|
||||
Result run(IRUnitT &IR, AnalysisManager<IRUnitT, ExtraArgTs...> &AM,
|
||||
ExtraArgTs...) {
|
||||
return Result(InnerAM);
|
||||
}
|
||||
|
||||
AnalysisManagerT &getManager() { return InnerAM; }
|
||||
|
||||
private:
|
||||
AnalysisManagerT InnerAM;
|
||||
};
|
||||
|
||||
template <>
|
||||
OwningInnerAnalysisManagerProxy<ScopAnalysisManager, Function>::Result
|
||||
OwningInnerAnalysisManagerProxy<ScopAnalysisManager, Function>::run(
|
||||
Function &F, FunctionAnalysisManager &FAM);
|
||||
extern template class OwningInnerAnalysisManagerProxy<ScopAnalysisManager,
|
||||
Function>;
|
||||
|
||||
using OwningScopAnalysisManagerFunctionProxy =
|
||||
OwningInnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
|
||||
using ScopPassManager =
|
||||
PassManager<Scop, ScopAnalysisManager, ScopStandardAnalysisResults &,
|
||||
SPMUpdater &>;
|
||||
|
||||
struct ScopStandardAnalysisResults {
|
||||
DominatorTree &DT;
|
||||
ScopInfo &SI;
|
||||
ScalarEvolution &SE;
|
||||
LoopInfo &LI;
|
||||
RegionInfo &RI;
|
||||
TargetTransformInfo &TTI;
|
||||
};
|
||||
|
||||
class SPMUpdater final {
|
||||
public:
|
||||
SPMUpdater(SmallPriorityWorklist<Region *, 4> &Worklist,
|
||||
ScopAnalysisManager &SAM)
|
||||
: InvalidateCurrentScop(false), Worklist(Worklist), SAM(SAM) {}
|
||||
|
||||
bool invalidateCurrentScop() const { return InvalidateCurrentScop; }
|
||||
|
||||
void invalidateScop(Scop &S) {
|
||||
if (&S == CurrentScop)
|
||||
InvalidateCurrentScop = true;
|
||||
|
||||
Worklist.erase(&S.getRegion());
|
||||
SAM.clear(S, S.getName());
|
||||
}
|
||||
|
||||
private:
|
||||
Scop *CurrentScop;
|
||||
bool InvalidateCurrentScop;
|
||||
SmallPriorityWorklist<Region *, 4> &Worklist;
|
||||
ScopAnalysisManager &SAM;
|
||||
template <typename ScopPassT> friend struct FunctionToScopPassAdaptor;
|
||||
};
|
||||
|
||||
template <typename ScopPassT>
|
||||
struct FunctionToScopPassAdaptor final
|
||||
: PassInfoMixin<FunctionToScopPassAdaptor<ScopPassT>> {
|
||||
explicit FunctionToScopPassAdaptor(ScopPassT Pass) : Pass(std::move(Pass)) {}
|
||||
|
||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) {
|
||||
ScopDetection &SD = AM.getResult<ScopAnalysis>(F);
|
||||
ScopInfo &SI = AM.getResult<ScopInfoAnalysis>(F);
|
||||
if (SI.empty()) {
|
||||
// With no scops having been detected, no IR changes have been made and
|
||||
// therefore all analyses are preserved. However, we must still free the
|
||||
// Scop analysis results which may hold AssertingVH that cause an error
|
||||
// if its value is destroyed.
|
||||
PreservedAnalyses PA = PreservedAnalyses::all();
|
||||
PA.abandon<ScopInfoAnalysis>();
|
||||
PA.abandon<ScopAnalysis>();
|
||||
AM.invalidate(F, PA);
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
SmallPriorityWorklist<Region *, 4> Worklist;
|
||||
for (auto &S : SI)
|
||||
if (S.second)
|
||||
Worklist.insert(S.first);
|
||||
|
||||
ScopStandardAnalysisResults AR = {AM.getResult<DominatorTreeAnalysis>(F),
|
||||
AM.getResult<ScopInfoAnalysis>(F),
|
||||
AM.getResult<ScalarEvolutionAnalysis>(F),
|
||||
AM.getResult<LoopAnalysis>(F),
|
||||
AM.getResult<RegionInfoAnalysis>(F),
|
||||
AM.getResult<TargetIRAnalysis>(F)};
|
||||
|
||||
ScopAnalysisManager &SAM =
|
||||
AM.getResult<ScopAnalysisManagerFunctionProxy>(F).getManager();
|
||||
|
||||
SPMUpdater Updater{Worklist, SAM};
|
||||
|
||||
while (!Worklist.empty()) {
|
||||
Region *R = Worklist.pop_back_val();
|
||||
if (!SD.isMaxRegionInScop(*R, /*Verify=*/false))
|
||||
continue;
|
||||
Scop *scop = SI.getScop(R);
|
||||
if (!scop)
|
||||
continue;
|
||||
Updater.CurrentScop = scop;
|
||||
Updater.InvalidateCurrentScop = false;
|
||||
PreservedAnalyses PassPA = Pass.run(*scop, SAM, AR, Updater);
|
||||
|
||||
SAM.invalidate(*scop, PassPA);
|
||||
if (Updater.invalidateCurrentScop())
|
||||
SI.recompute();
|
||||
};
|
||||
|
||||
// FIXME: For the same reason as we add a BarrierNoopPass in the legacy pass
|
||||
// manager, do not preserve any analyses. While CodeGeneration may preserve
|
||||
// IR analyses sufficiently to process another Scop in the same function (it
|
||||
// has to, otherwise the ScopDetection result itself would need to be
|
||||
// invalidated), it is not sufficient for other purposes. For instance,
|
||||
// CodeGeneration does not inform LoopInfo about new loops in the
|
||||
// Polly-generated IR.
|
||||
return PreservedAnalyses::none();
|
||||
}
|
||||
|
||||
private:
|
||||
ScopPassT Pass;
|
||||
};
|
||||
|
||||
template <typename ScopPassT>
|
||||
FunctionToScopPassAdaptor<ScopPassT>
|
||||
createFunctionToScopPassAdaptor(ScopPassT Pass) {
|
||||
return FunctionToScopPassAdaptor<ScopPassT>(std::move(Pass));
|
||||
}
|
||||
} // namespace polly
|
||||
|
||||
#endif
|
||||
@ -13,11 +13,11 @@
|
||||
#ifndef POLLY_TRANSFORM_SIMPLIFY_H
|
||||
#define POLLY_TRANSFORM_SIMPLIFY_H
|
||||
|
||||
#include "polly/ScopPass.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
||||
namespace polly {
|
||||
class MemoryAccess;
|
||||
class Scop;
|
||||
class ScopStmt;
|
||||
|
||||
/// Return a vector that contains MemoryAccesses in the order in
|
||||
@ -36,28 +36,6 @@ class ScopStmt;
|
||||
/// undefined.
|
||||
llvm::SmallVector<MemoryAccess *, 32> getAccessesInOrder(ScopStmt &Stmt);
|
||||
|
||||
struct SimplifyPass final : PassInfoMixin<SimplifyPass> {
|
||||
SimplifyPass(int CallNo = 0) : CallNo(CallNo) {}
|
||||
|
||||
llvm::PreservedAnalyses run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &AR, SPMUpdater &U);
|
||||
|
||||
private:
|
||||
int CallNo;
|
||||
};
|
||||
|
||||
struct SimplifyPrinterPass final : PassInfoMixin<SimplifyPrinterPass> {
|
||||
SimplifyPrinterPass(raw_ostream &OS, int CallNo = 0)
|
||||
: OS(OS), CallNo(CallNo) {}
|
||||
|
||||
PreservedAnalyses run(Scop &S, ScopAnalysisManager &,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &);
|
||||
|
||||
private:
|
||||
raw_ostream &OS;
|
||||
int CallNo;
|
||||
};
|
||||
|
||||
bool runSimplify(Scop &S, int CallNo);
|
||||
} // namespace polly
|
||||
|
||||
|
||||
@ -858,33 +858,6 @@ void DependenceAnalysis::Result::abandonDependences() {
|
||||
Deps.release();
|
||||
}
|
||||
|
||||
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 them
|
||||
Dependences D(S.getSharedIslCtx(), OptAnalysisLevel);
|
||||
D.calculateDependences(S);
|
||||
D.print(OS);
|
||||
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
DependenceAnalysis::Result polly::runDependenceAnalysis(Scop &S) {
|
||||
DependenceAnalysis::Result Result{S, {}};
|
||||
return Result;
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
#include "polly/PruneUnprofitable.h"
|
||||
#include "polly/ScopDetection.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/IR/DebugLoc.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
@ -79,18 +78,3 @@ bool polly::runPruneUnprofitable(Scop &S) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
llvm::PreservedAnalyses
|
||||
PruneUnprofitablePass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U) {
|
||||
bool Changed = runPruneUnprofitable(S);
|
||||
|
||||
if (!Changed)
|
||||
return PreservedAnalyses::all();
|
||||
|
||||
PreservedAnalyses PA;
|
||||
PA.preserveSet<AllAnalysesOn<Module>>();
|
||||
PA.preserveSet<AllAnalysesOn<Function>>();
|
||||
PA.preserveSet<AllAnalysesOn<Loop>>();
|
||||
return PA;
|
||||
}
|
||||
|
||||
@ -72,7 +72,6 @@
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/Metadata.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/IR/Value.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/Regex.h"
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Value.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
//===- ScopPass.cpp - The base class of Passes that operate on Polly IR ---===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the definitions of the ScopPass members.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "polly/ScopPass.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "llvm/Analysis/BasicAliasAnalysis.h"
|
||||
#include "llvm/Analysis/GlobalsModRef.h"
|
||||
#include "llvm/Analysis/LazyBlockFrequencyInfo.h"
|
||||
#include "llvm/Analysis/LazyBranchProbabilityInfo.h"
|
||||
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
|
||||
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include <optional>
|
||||
|
||||
using namespace llvm;
|
||||
using namespace polly;
|
||||
|
||||
namespace polly {
|
||||
template class OwningInnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template class PassManager<Scop, ScopAnalysisManager,
|
||||
ScopStandardAnalysisResults &, SPMUpdater &>;
|
||||
template class InnerAnalysisManagerProxy<ScopAnalysisManager, Function>;
|
||||
template class OuterAnalysisManagerProxy<FunctionAnalysisManager, Scop,
|
||||
ScopStandardAnalysisResults &>;
|
||||
|
||||
template <>
|
||||
PreservedAnalyses
|
||||
PassManager<Scop, ScopAnalysisManager, ScopStandardAnalysisResults &,
|
||||
SPMUpdater &>::run(Scop &S, ScopAnalysisManager &AM,
|
||||
ScopStandardAnalysisResults &AR, SPMUpdater &U) {
|
||||
auto PA = PreservedAnalyses::all();
|
||||
for (auto &Pass : Passes) {
|
||||
auto PassPA = Pass->run(S, AM, AR, U);
|
||||
|
||||
AM.invalidate(S, PassPA);
|
||||
PA.intersect(std::move(PassPA));
|
||||
}
|
||||
|
||||
// All analyses for 'this' Scop have been invalidated above.
|
||||
// If ScopPasses affect break other scops they have to propagate this
|
||||
// information through the updater
|
||||
PA.preserveSet<AllAnalysesOn<Scop>>();
|
||||
return PA;
|
||||
}
|
||||
|
||||
bool ScopAnalysisManagerFunctionProxy::Result::invalidate(
|
||||
Function &F, const PreservedAnalyses &PA,
|
||||
FunctionAnalysisManager::Invalidator &Inv) {
|
||||
|
||||
// First, check whether our ScopInfo is about to be invalidated
|
||||
auto PAC = PA.getChecker<ScopAnalysisManagerFunctionProxy>();
|
||||
if (!(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>()) ||
|
||||
Inv.invalidate<ScopInfoAnalysis>(F, PA) ||
|
||||
Inv.invalidate<ScalarEvolutionAnalysis>(F, PA) ||
|
||||
Inv.invalidate<LoopAnalysis>(F, PA) ||
|
||||
Inv.invalidate<DominatorTreeAnalysis>(F, PA)) {
|
||||
|
||||
// As everything depends on ScopInfo, we must drop all existing results
|
||||
for (auto &S : *SI)
|
||||
if (auto *scop = S.second.get())
|
||||
if (InnerAM)
|
||||
InnerAM->clear(*scop, scop->getName());
|
||||
|
||||
InnerAM = nullptr;
|
||||
return true; // Invalidate the proxy result as well.
|
||||
}
|
||||
|
||||
bool allPreserved = PA.allAnalysesInSetPreserved<AllAnalysesOn<Scop>>();
|
||||
|
||||
// Invalidate all non-preserved analyses
|
||||
// Even if all analyses were preserved, we still need to run deferred
|
||||
// invalidation
|
||||
for (auto &S : *SI) {
|
||||
std::optional<PreservedAnalyses> InnerPA;
|
||||
auto *scop = S.second.get();
|
||||
if (!scop)
|
||||
continue;
|
||||
|
||||
if (auto *OuterProxy =
|
||||
InnerAM->getCachedResult<FunctionAnalysisManagerScopProxy>(*scop)) {
|
||||
for (const auto &InvPair : OuterProxy->getOuterInvalidations()) {
|
||||
auto *OuterAnalysisID = InvPair.first;
|
||||
const auto &InnerAnalysisIDs = InvPair.second;
|
||||
|
||||
if (Inv.invalidate(OuterAnalysisID, F, PA)) {
|
||||
if (!InnerPA)
|
||||
InnerPA = PA;
|
||||
for (auto *InnerAnalysisID : InnerAnalysisIDs)
|
||||
InnerPA->abandon(InnerAnalysisID);
|
||||
}
|
||||
}
|
||||
|
||||
if (InnerPA) {
|
||||
InnerAM->invalidate(*scop, *InnerPA);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allPreserved)
|
||||
InnerAM->invalidate(*scop, PA);
|
||||
}
|
||||
|
||||
return false; // This proxy is still valid
|
||||
}
|
||||
|
||||
template <>
|
||||
ScopAnalysisManagerFunctionProxy::Result
|
||||
ScopAnalysisManagerFunctionProxy::run(Function &F,
|
||||
FunctionAnalysisManager &FAM) {
|
||||
return Result(*InnerAM, FAM.getResult<ScopInfoAnalysis>(F));
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace polly {
|
||||
template <>
|
||||
OwningScopAnalysisManagerFunctionProxy::Result
|
||||
OwningScopAnalysisManagerFunctionProxy::run(Function &F,
|
||||
FunctionAnalysisManager &FAM) {
|
||||
return Result(InnerAM, FAM.getResult<ScopInfoAnalysis>(F));
|
||||
}
|
||||
} // namespace polly
|
||||
@ -48,7 +48,6 @@ add_llvm_pass_plugin(Polly
|
||||
Analysis/ScopInfo.cpp
|
||||
Analysis/ScopBuilder.cpp
|
||||
Analysis/ScopGraphPrinter.cpp
|
||||
Analysis/ScopPass.cpp
|
||||
Analysis/PruneUnprofitable.cpp
|
||||
CodeGen/BlockGenerators.cpp
|
||||
${ISL_CODEGEN_FILES}
|
||||
|
||||
@ -34,7 +34,6 @@
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
@ -318,18 +317,6 @@ static bool generateCode(Scop &S, IslAstInfo &AI, LoopInfo &LI,
|
||||
return true;
|
||||
}
|
||||
|
||||
PreservedAnalyses CodeGenerationPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &AR,
|
||||
SPMUpdater &U) {
|
||||
auto &AI = SAM.getResult<IslAstAnalysis>(S, AR);
|
||||
if (generateCode(S, AI, AR.LI, AR.DT, AR.SE, AR.RI)) {
|
||||
U.invalidateScop(S);
|
||||
return PreservedAnalyses::none();
|
||||
}
|
||||
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
bool polly::runCodeGeneration(Scop &S, RegionInfo &RI, IslAstInfo &AI) {
|
||||
return generateCode(S, AI, *S.getLI(), *S.getDT(), *S.getSE(), RI);
|
||||
}
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
#include "polly/Options.h"
|
||||
#include "polly/ScopDetection.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "polly/Support/GICHelper.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
@ -663,15 +662,6 @@ static std::unique_ptr<IslAstInfo> runIslAst(
|
||||
return Ast;
|
||||
}
|
||||
|
||||
IslAstInfo IslAstAnalysis::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR) {
|
||||
auto GetDeps = [&](Dependences::AnalysisLevel Lvl) -> const Dependences & {
|
||||
return SAM.getResult<DependenceAnalysis>(S, SAR).getDependences(Lvl);
|
||||
};
|
||||
|
||||
return std::move(*runIslAst(S, GetDeps));
|
||||
}
|
||||
|
||||
static __isl_give isl_printer *cbPrintUser(__isl_take isl_printer *P,
|
||||
__isl_take isl_ast_print_options *O,
|
||||
__isl_keep isl_ast_node *Node,
|
||||
@ -771,15 +761,6 @@ void IslAstInfo::print(raw_ostream &OS) {
|
||||
isl_printer_free(P);
|
||||
}
|
||||
|
||||
AnalysisKey IslAstAnalysis::Key;
|
||||
PreservedAnalyses IslAstPrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &U) {
|
||||
auto &Ast = SAM.getResult<IslAstAnalysis>(S, SAR);
|
||||
Ast.print(OS);
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
std::unique_ptr<IslAstInfo>
|
||||
polly::runIslAstGen(Scop &S, DependenceAnalysis::Result &DA) {
|
||||
auto GetDeps = [&](Dependences::AnalysisLevel Lvl) -> const Dependences & {
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#include "polly/DependenceInfo.h"
|
||||
#include "polly/Options.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "polly/Support/ISLTools.h"
|
||||
#include "polly/Support/ScopLocation.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
@ -716,32 +715,6 @@ static bool importScop(Scop &S, const Dependences &D, const DataLayout &DL,
|
||||
return true;
|
||||
}
|
||||
|
||||
PreservedAnalyses JSONExportPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &) {
|
||||
exportScop(S);
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
PreservedAnalyses JSONImportPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &) {
|
||||
const Dependences &D =
|
||||
SAM.getResult<DependenceAnalysis>(S, SAR).getDependences(
|
||||
Dependences::AL_Statement);
|
||||
const DataLayout &DL = S.getFunction().getParent()->getDataLayout();
|
||||
|
||||
if (!importScop(S, D, DL))
|
||||
report_fatal_error("Tried to import a malformed jscop file.");
|
||||
|
||||
// This invalidates all analyses on Scop.
|
||||
PreservedAnalyses PA;
|
||||
PA.preserveSet<AllAnalysesOn<Module>>();
|
||||
PA.preserveSet<AllAnalysesOn<Function>>();
|
||||
PA.preserveSet<AllAnalysesOn<Loop>>();
|
||||
return PA;
|
||||
}
|
||||
|
||||
void polly::runImportJSON(Scop &S, DependenceAnalysis::Result &DA) {
|
||||
const Dependences &D = DA.getDependences(Dependences::AL_Statement);
|
||||
const DataLayout &DL = S.getFunction().getParent()->getDataLayout();
|
||||
|
||||
@ -25,8 +25,10 @@
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/Simplify.h"
|
||||
#include "polly/Support/PollyDebug.h"
|
||||
#include "llvm/ADT/PriorityWorklist.h"
|
||||
#include "llvm/Analysis/AssumptionCache.h"
|
||||
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
|
||||
#define DEBUG_TYPE "polly-pass"
|
||||
@ -77,10 +79,13 @@ public:
|
||||
// TODO: Setting ModifiedIR will invalidate any analysis, even if DT, LI are
|
||||
// preserved.
|
||||
if (Opts.isPhaseEnabled(PassPhase::Prepare)) {
|
||||
PreservedAnalyses PA = CodePreparationPass().run(F, FAM);
|
||||
FAM.invalidate(F, PA);
|
||||
if (!PA.areAllPreserved())
|
||||
if (runCodePreparation(F, &DT, &LI, nullptr)) {
|
||||
PreservedAnalyses PA;
|
||||
PA.preserve<DominatorTreeAnalysis>();
|
||||
PA.preserve<LoopAnalysis>();
|
||||
FAM.invalidate(F, PA);
|
||||
ModifiedIR = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Can't do anything without detection
|
||||
|
||||
@ -11,53 +11,9 @@ MODULE_PASS("polly-custom", createModuleToFunctionPassAdaptor(PollyFunctionPass(
|
||||
CGSCC_PASS("polly-inline", ScopInlinerPass(), parseNoOptions)
|
||||
#undef CGSCC_PASS
|
||||
|
||||
#ifndef FUNCTION_ANALYSIS
|
||||
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS)
|
||||
#endif
|
||||
FUNCTION_ANALYSIS("polly-detect", ScopAnalysis())
|
||||
FUNCTION_ANALYSIS("polly-function-scops", ScopInfoAnalysis())
|
||||
#undef FUNCTION_ANALYSIS
|
||||
|
||||
#ifndef FUNCTION_PASS
|
||||
#define FUNCTION_PASS(NAME, CREATE_PASS, PARSER)
|
||||
#endif
|
||||
FUNCTION_PASS("polly-prepare", CodePreparationPass(), parseNoOptions)
|
||||
FUNCTION_PASS("print<polly-detect>", ScopAnalysisPrinterPass(llvm::errs()), parseNoOptions)
|
||||
FUNCTION_PASS("print<polly-function-scops>", ScopInfoPrinterPass(llvm::errs()), parseNoOptions)
|
||||
FUNCTION_PASS("polly-scop-viewer", ScopViewer(), parseNoOptions)
|
||||
FUNCTION_PASS("polly-scop-only-viewer", ScopOnlyViewer(), parseNoOptions)
|
||||
FUNCTION_PASS("polly-scop-printer", ScopPrinter(), parseNoOptions)
|
||||
FUNCTION_PASS("polly-scop-only-printer", ScopOnlyPrinter(), parseNoOptions)
|
||||
FUNCTION_PASS("polly", PollyFunctionPass(Opts), parsePollyDefaultOptions)
|
||||
FUNCTION_PASS("polly-custom", PollyFunctionPass(Opts), parsePollyCustomOptions)
|
||||
#undef FUNCTION_PASS
|
||||
|
||||
#ifndef SCOP_ANALYSIS
|
||||
#define SCOP_ANALYSIS(NAME, CREATE_PASS)
|
||||
#endif
|
||||
SCOP_ANALYSIS("pass-instrumentation", llvm::PassInstrumentationAnalysis(PIC))
|
||||
SCOP_ANALYSIS("polly-ast", IslAstAnalysis())
|
||||
SCOP_ANALYSIS("polly-dependences", DependenceAnalysis())
|
||||
#undef SCOP_ANALYSIS
|
||||
|
||||
#ifndef SCOP_PASS
|
||||
#define SCOP_PASS(NAME, CREATE_PASS)
|
||||
#endif
|
||||
SCOP_PASS("polly-export-jscop", JSONExportPass())
|
||||
SCOP_PASS("polly-import-jscop", JSONImportPass())
|
||||
SCOP_PASS("print<polly-ast>", IslAstPrinterPass(llvm::outs()))
|
||||
SCOP_PASS("print<polly-dependences>", DependenceInfoPrinterPass(llvm::outs()))
|
||||
SCOP_PASS("polly-codegen", CodeGenerationPass())
|
||||
SCOP_PASS("polly-simplify", SimplifyPass())
|
||||
SCOP_PASS("print<polly-simplify>", SimplifyPrinterPass(llvm::outs()))
|
||||
SCOP_PASS("polly-optree", ForwardOpTreePass())
|
||||
SCOP_PASS("print<polly-optree>", ForwardOpTreePrinterPass(llvm::outs()))
|
||||
SCOP_PASS("polly-delicm", DeLICMPass())
|
||||
SCOP_PASS("print<polly-delicm>", DeLICMPrinterPass(llvm::outs()))
|
||||
SCOP_PASS("polly-prune-unprofitable", PruneUnprofitablePass())
|
||||
SCOP_PASS("polly-opt-isl", IslScheduleOptimizerPass())
|
||||
SCOP_PASS("print<polly-opt-isl>", IslScheduleOptimizerPrinterPass(llvm::outs()))
|
||||
SCOP_PASS("polly-dce", DeadCodeElimPass())
|
||||
SCOP_PASS("polly-mse", MaximalStaticExpansionPass())
|
||||
SCOP_PASS("print<polly-mse>", MaximalStaticExpansionPrinterPass(llvm::outs()))
|
||||
#undef SCOP_PASS
|
||||
|
||||
@ -539,33 +539,6 @@ static llvm::Expected<std::monostate> parseNoOptions(StringRef Params) {
|
||||
return std::monostate{};
|
||||
}
|
||||
|
||||
static OwningScopAnalysisManagerFunctionProxy
|
||||
createScopAnalyses(FunctionAnalysisManager &FAM,
|
||||
PassInstrumentationCallbacks *PIC) {
|
||||
OwningScopAnalysisManagerFunctionProxy Proxy;
|
||||
#define SCOP_ANALYSIS(NAME, CREATE_PASS) \
|
||||
Proxy.getManager().registerPass([PIC] { \
|
||||
(void)PIC; \
|
||||
return CREATE_PASS; \
|
||||
});
|
||||
#include "PollyPasses.def"
|
||||
|
||||
Proxy.getManager().registerPass(
|
||||
[&FAM] { return FunctionAnalysisManagerScopProxy(FAM); });
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
static void registerFunctionAnalyses(FunctionAnalysisManager &FAM,
|
||||
PassInstrumentationCallbacks *PIC) {
|
||||
|
||||
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
|
||||
FAM.registerPass([] { return CREATE_PASS; });
|
||||
|
||||
#include "PollyPasses.def"
|
||||
|
||||
FAM.registerPass([&FAM, PIC] { return createScopAnalyses(FAM, PIC); });
|
||||
}
|
||||
|
||||
static llvm::Expected<bool>
|
||||
parseCGPipeline(StringRef Name, llvm::CGSCCPassManager &CGPM,
|
||||
PassInstrumentationCallbacks *PIC,
|
||||
@ -587,15 +560,6 @@ static llvm::Expected<bool>
|
||||
parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM,
|
||||
PassInstrumentationCallbacks *PIC,
|
||||
ArrayRef<PassBuilder::PipelineElement> Pipeline) {
|
||||
if (llvm::parseAnalysisUtilityPasses<OwningScopAnalysisManagerFunctionProxy>(
|
||||
"polly-scop-analyses", Name, FPM))
|
||||
return true;
|
||||
|
||||
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
|
||||
if (llvm::parseAnalysisUtilityPasses< \
|
||||
std::remove_reference<decltype(CREATE_PASS)>::type>(NAME, Name, \
|
||||
FPM)) \
|
||||
return true;
|
||||
|
||||
#define FUNCTION_PASS(NAME, CREATE_PASS, PARSER) \
|
||||
if (PassBuilder::checkParametrizedPassName(Name, NAME)) { \
|
||||
@ -612,83 +576,6 @@ parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool parseScopPass(StringRef Name, ScopPassManager &SPM,
|
||||
PassInstrumentationCallbacks *PIC) {
|
||||
#define SCOP_ANALYSIS(NAME, CREATE_PASS) \
|
||||
if (llvm::parseAnalysisUtilityPasses< \
|
||||
std::remove_reference<decltype(CREATE_PASS)>::type>(NAME, Name, \
|
||||
SPM)) \
|
||||
return true;
|
||||
|
||||
#define SCOP_PASS(NAME, CREATE_PASS) \
|
||||
if (Name == NAME) { \
|
||||
SPM.addPass(CREATE_PASS); \
|
||||
return true; \
|
||||
}
|
||||
|
||||
#include "PollyPasses.def"
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool parseScopPipeline(StringRef Name, FunctionPassManager &FPM,
|
||||
PassInstrumentationCallbacks *PIC,
|
||||
ArrayRef<PassBuilder::PipelineElement> Pipeline) {
|
||||
if (Name != "scop")
|
||||
return false;
|
||||
if (!Pipeline.empty()) {
|
||||
ScopPassManager SPM;
|
||||
for (const auto &E : Pipeline)
|
||||
if (!parseScopPass(E.Name, SPM, PIC))
|
||||
return false;
|
||||
FPM.addPass(createFunctionToScopPassAdaptor(std::move(SPM)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool isScopPassName(StringRef Name) {
|
||||
#define SCOP_ANALYSIS(NAME, CREATE_PASS) \
|
||||
if (Name == "require<" NAME ">") \
|
||||
return true; \
|
||||
if (Name == "invalidate<" NAME ">") \
|
||||
return true;
|
||||
|
||||
#define SCOP_PASS(NAME, CREATE_PASS) \
|
||||
if (Name == NAME) \
|
||||
return true;
|
||||
|
||||
#include "PollyPasses.def"
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
parseTopLevelPipeline(llvm::ModulePassManager &MPM,
|
||||
PassInstrumentationCallbacks *PIC,
|
||||
ArrayRef<PassBuilder::PipelineElement> Pipeline) {
|
||||
StringRef FirstName = Pipeline.front().Name;
|
||||
|
||||
if (!isScopPassName(FirstName))
|
||||
return false;
|
||||
|
||||
FunctionPassManager FPM;
|
||||
ScopPassManager SPM;
|
||||
|
||||
for (auto &Element : Pipeline) {
|
||||
auto &Name = Element.Name;
|
||||
auto &InnerPipeline = Element.InnerPipeline;
|
||||
if (!InnerPipeline.empty()) // Scop passes don't have inner pipelines
|
||||
return false;
|
||||
if (!parseScopPass(Name, SPM, PIC))
|
||||
return false;
|
||||
}
|
||||
|
||||
FPM.addPass(createFunctionToScopPassAdaptor(std::move(SPM)));
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static llvm::Expected<bool>
|
||||
parseModulePipeline(StringRef Name, llvm::ModulePassManager &MPM,
|
||||
PassInstrumentationCallbacks *PIC,
|
||||
@ -758,20 +645,12 @@ void registerPollyPasses(PassBuilder &PB) {
|
||||
}
|
||||
#include "PollyPasses.def"
|
||||
|
||||
PB.registerAnalysisRegistrationCallback([PIC](FunctionAnalysisManager &FAM) {
|
||||
registerFunctionAnalyses(FAM, PIC);
|
||||
});
|
||||
PB.registerPipelineParsingCallback(
|
||||
[PIC](StringRef Name, FunctionPassManager &FPM,
|
||||
ArrayRef<PassBuilder::PipelineElement> Pipeline) -> bool {
|
||||
ExitOnError Err("Unable to parse Polly module pass: ");
|
||||
return Err(parseFunctionPipeline(Name, FPM, PIC, Pipeline));
|
||||
});
|
||||
PB.registerPipelineParsingCallback(
|
||||
[PIC](StringRef Name, FunctionPassManager &FPM,
|
||||
ArrayRef<PassBuilder::PipelineElement> Pipeline) -> bool {
|
||||
return parseScopPipeline(Name, FPM, PIC, Pipeline);
|
||||
});
|
||||
PB.registerPipelineParsingCallback(
|
||||
[PIC](StringRef Name, CGSCCPassManager &CGPM,
|
||||
ArrayRef<PassBuilder::PipelineElement> Pipeline) -> bool {
|
||||
@ -784,11 +663,6 @@ void registerPollyPasses(PassBuilder &PB) {
|
||||
ExitOnError Err("Unable to parse Polly module pass: ");
|
||||
return Err(parseModulePipeline(Name, MPM, PIC, Pipeline));
|
||||
});
|
||||
PB.registerParseTopLevelPipelineCallback(
|
||||
[PIC](llvm::ModulePassManager &MPM,
|
||||
ArrayRef<PassBuilder::PipelineElement> Pipeline) -> bool {
|
||||
return parseTopLevelPipeline(MPM, PIC, Pipeline);
|
||||
});
|
||||
|
||||
switch (PassPosition) {
|
||||
case POSITION_EARLY:
|
||||
|
||||
@ -45,16 +45,7 @@ static bool runCodePreprationImpl(Function &F, DominatorTree *DT, LoopInfo *LI,
|
||||
return true;
|
||||
}
|
||||
|
||||
PreservedAnalyses CodePreparationPass::run(Function &F,
|
||||
FunctionAnalysisManager &FAM) {
|
||||
auto &DT = FAM.getResult<DominatorTreeAnalysis>(F);
|
||||
auto &LI = FAM.getResult<LoopAnalysis>(F);
|
||||
bool Changed = runCodePreprationImpl(F, &DT, &LI, nullptr);
|
||||
if (!Changed)
|
||||
return PreservedAnalyses::all();
|
||||
|
||||
PreservedAnalyses PA;
|
||||
PA.preserve<DominatorTreeAnalysis>();
|
||||
PA.preserve<LoopAnalysis>();
|
||||
return PA;
|
||||
bool polly::runCodePreparation(Function &F, DominatorTree *DT, LoopInfo *LI,
|
||||
RegionInfo *RI) {
|
||||
return runCodePreprationImpl(F, DT, LI, RI);
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
#include "polly/DeLICM.h"
|
||||
#include "polly/Options.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "polly/Support/GICHelper.h"
|
||||
#include "polly/Support/ISLOStream.h"
|
||||
#include "polly/Support/ISLTools.h"
|
||||
@ -1394,50 +1393,8 @@ static std::unique_ptr<DeLICMImpl> runDeLICMImpl(Scop &S, LoopInfo &LI) {
|
||||
|
||||
return Impl;
|
||||
}
|
||||
|
||||
static PreservedAnalyses runDeLICMUsingNPM(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &U, raw_ostream *OS) {
|
||||
LoopInfo &LI = SAR.LI;
|
||||
std::unique_ptr<DeLICMImpl> Impl = runDeLICMImpl(S, LI);
|
||||
|
||||
if (OS) {
|
||||
*OS << "Printing analysis 'Polly - DeLICM/DePRE' for region: '"
|
||||
<< S.getName() << "' in function '" << S.getFunction().getName()
|
||||
<< "':\n";
|
||||
if (Impl) {
|
||||
assert(Impl->getScop() == &S);
|
||||
|
||||
*OS << "DeLICM result:\n";
|
||||
Impl->print(*OS);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Impl->isModified())
|
||||
return PreservedAnalyses::all();
|
||||
|
||||
PreservedAnalyses PA;
|
||||
PA.preserveSet<AllAnalysesOn<Module>>();
|
||||
PA.preserveSet<AllAnalysesOn<Function>>();
|
||||
PA.preserveSet<AllAnalysesOn<Loop>>();
|
||||
return PA;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
llvm::PreservedAnalyses polly::DeLICMPass::run(Scop &S,
|
||||
ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &U) {
|
||||
return runDeLICMUsingNPM(S, SAM, SAR, U, nullptr);
|
||||
}
|
||||
|
||||
llvm::PreservedAnalyses DeLICMPrinterPass::run(Scop &S,
|
||||
ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &U) {
|
||||
return runDeLICMUsingNPM(S, SAM, SAR, U, &OS);
|
||||
}
|
||||
|
||||
bool polly::isConflicting(
|
||||
isl::union_set ExistingOccupied, isl::union_set ExistingUnused,
|
||||
isl::union_map ExistingKnown, isl::union_map ExistingWrites,
|
||||
|
||||
@ -143,26 +143,3 @@ bool polly::runDeadCodeElim(Scop &S, DependenceAnalysis::Result &DA) {
|
||||
|
||||
return Changed;
|
||||
}
|
||||
|
||||
llvm::PreservedAnalyses DeadCodeElimPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &U) {
|
||||
DependenceAnalysis::Result &DA = SAM.getResult<DependenceAnalysis>(S, SAR);
|
||||
const Dependences &Deps = DA.getDependences(Dependences::AL_Statement);
|
||||
|
||||
bool Changed = runDeadCodeElimination(S, DCEPreciseSteps, Deps);
|
||||
|
||||
// FIXME: We can probably avoid the recomputation of all dependences by
|
||||
// updating them explicitly.
|
||||
if (Changed)
|
||||
DA.recomputeDependences(Dependences::AL_Statement);
|
||||
|
||||
if (!Changed)
|
||||
return PreservedAnalyses::all();
|
||||
|
||||
PreservedAnalyses PA;
|
||||
PA.preserveSet<AllAnalysesOn<Module>>();
|
||||
PA.preserveSet<AllAnalysesOn<Function>>();
|
||||
PA.preserveSet<AllAnalysesOn<Loop>>();
|
||||
return PA;
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include "polly/FlattenAlgo.h"
|
||||
#include "polly/Options.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "polly/Support/ISLOStream.h"
|
||||
#include "polly/Support/ISLTools.h"
|
||||
#include "polly/Support/PollyDebug.h"
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#include "polly/Options.h"
|
||||
#include "polly/ScopBuilder.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "polly/Support/GICHelper.h"
|
||||
#include "polly/Support/ISLOStream.h"
|
||||
#include "polly/Support/ISLTools.h"
|
||||
@ -1070,49 +1069,8 @@ static std::unique_ptr<ForwardOpTreeImpl> runForwardOpTreeImpl(Scop &S,
|
||||
|
||||
return Impl;
|
||||
}
|
||||
|
||||
static PreservedAnalyses
|
||||
runForwardOpTreeUsingNPM(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U,
|
||||
raw_ostream *OS) {
|
||||
LoopInfo &LI = SAR.LI;
|
||||
|
||||
std::unique_ptr<ForwardOpTreeImpl> Impl = runForwardOpTreeImpl(S, LI);
|
||||
if (OS) {
|
||||
*OS << "Printing analysis 'Polly - Forward operand tree' for region: '"
|
||||
<< S.getName() << "' in function '" << S.getFunction().getName()
|
||||
<< "':\n";
|
||||
if (Impl) {
|
||||
assert(Impl->getScop() == &S);
|
||||
|
||||
Impl->print(*OS);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Impl->isModified())
|
||||
return PreservedAnalyses::all();
|
||||
|
||||
PreservedAnalyses PA;
|
||||
PA.preserveSet<AllAnalysesOn<Module>>();
|
||||
PA.preserveSet<AllAnalysesOn<Function>>();
|
||||
PA.preserveSet<AllAnalysesOn<Loop>>();
|
||||
return PA;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
llvm::PreservedAnalyses ForwardOpTreePass::run(Scop &S,
|
||||
ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &U) {
|
||||
return runForwardOpTreeUsingNPM(S, SAM, SAR, U, nullptr);
|
||||
}
|
||||
|
||||
llvm::PreservedAnalyses
|
||||
ForwardOpTreePrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U) {
|
||||
return runForwardOpTreeUsingNPM(S, SAM, SAR, U, &OS);
|
||||
}
|
||||
|
||||
bool polly::runForwardOpTree(Scop &S) {
|
||||
LoopInfo &LI = *S.getLI();
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include "polly/Options.h"
|
||||
#include "polly/ScheduleTreeTransform.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "polly/Simplify.h"
|
||||
#include "polly/Support/GICHelper.h"
|
||||
#include "polly/Support/ISLTools.h"
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
#include "polly/DependenceInfo.h"
|
||||
#include "polly/Options.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "polly/Support/ISLTools.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
@ -449,49 +448,8 @@ runMaximalStaticExpansionImpl(Scop &S, OptimizationRemarkEmitter &ORE,
|
||||
Impl->expand();
|
||||
return Impl;
|
||||
}
|
||||
|
||||
static PreservedAnalyses runMSEUsingNPM(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
raw_ostream *OS) {
|
||||
OptimizationRemarkEmitter ORE(&S.getFunction());
|
||||
|
||||
auto &DI = SAM.getResult<DependenceAnalysis>(S, SAR);
|
||||
auto &D = DI.getDependences(Dependences::AL_Reference);
|
||||
|
||||
std::unique_ptr<MaximalStaticExpansionImpl> Impl =
|
||||
runMaximalStaticExpansionImpl(S, ORE, D);
|
||||
|
||||
if (OS) {
|
||||
*OS << "Printing analysis 'Polly - Maximal static expansion of SCoP' for "
|
||||
"region: '"
|
||||
<< S.getName() << "' in function '" << S.getFunction().getName()
|
||||
<< "':\n";
|
||||
|
||||
if (Impl) {
|
||||
*OS << "MSE result:\n";
|
||||
Impl->print(*OS);
|
||||
}
|
||||
}
|
||||
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
PreservedAnalyses
|
||||
MaximalStaticExpansionPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &) {
|
||||
return runMSEUsingNPM(S, SAM, SAR, nullptr);
|
||||
}
|
||||
|
||||
PreservedAnalyses
|
||||
MaximalStaticExpansionPrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &) {
|
||||
return runMSEUsingNPM(S, SAM, SAR, &OS);
|
||||
}
|
||||
|
||||
void polly::runMaximalStaticExpansion(Scop &S, DependenceAnalysis::Result &DI) {
|
||||
OptimizationRemarkEmitter ORE(&S.getFunction());
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
#include "polly/MatmulOptimizer.h"
|
||||
#include "polly/Options.h"
|
||||
#include "polly/ScheduleTreeTransform.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/Support/ISLOStream.h"
|
||||
#include "polly/Support/ISLTools.h"
|
||||
#include "llvm/ADT/Sequence.h"
|
||||
@ -966,44 +967,6 @@ static void runScheduleOptimizerPrinter(raw_ostream &OS,
|
||||
|
||||
} // namespace
|
||||
|
||||
static llvm::PreservedAnalyses
|
||||
runIslScheduleOptimizerUsingNPM(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U,
|
||||
raw_ostream *OS) {
|
||||
DependenceAnalysis::Result &Deps = SAM.getResult<DependenceAnalysis>(S, SAR);
|
||||
auto GetDeps = [&Deps](Dependences::AnalysisLevel) -> const Dependences & {
|
||||
return Deps.getDependences(Dependences::AL_Statement);
|
||||
};
|
||||
OptimizationRemarkEmitter ORE(&S.getFunction());
|
||||
TargetTransformInfo *TTI = &SAR.TTI;
|
||||
isl::schedule LastSchedule;
|
||||
bool DepsChanged = false;
|
||||
runIslScheduleOptimizerImpl(S, GetDeps, TTI, &ORE, LastSchedule, DepsChanged);
|
||||
if (DepsChanged)
|
||||
Deps.abandonDependences();
|
||||
|
||||
if (OS) {
|
||||
*OS << "Printing analysis 'Polly - Optimize schedule of SCoP' for region: '"
|
||||
<< S.getName() << "' in function '" << S.getFunction().getName()
|
||||
<< "':\n";
|
||||
runScheduleOptimizerPrinter(*OS, LastSchedule);
|
||||
}
|
||||
return PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
llvm::PreservedAnalyses
|
||||
IslScheduleOptimizerPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U) {
|
||||
return runIslScheduleOptimizerUsingNPM(S, SAM, SAR, U, nullptr);
|
||||
}
|
||||
|
||||
llvm::PreservedAnalyses
|
||||
IslScheduleOptimizerPrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &U) {
|
||||
return runIslScheduleOptimizerUsingNPM(S, SAM, SAR, U, &OS);
|
||||
}
|
||||
|
||||
void polly::runIslScheduleOptimizer(Scop &S, TargetTransformInfo *TTI,
|
||||
DependenceAnalysis::Result &Deps) {
|
||||
auto GetDeps = [&Deps](Dependences::AnalysisLevel) -> const Dependences & {
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
|
||||
#include "llvm/Analysis/RegionInfo.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/Passes/PassBuilder.h"
|
||||
#include "llvm/Transforms/IPO/AlwaysInliner.h"
|
||||
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
#include "polly/Simplify.h"
|
||||
#include "polly/Options.h"
|
||||
#include "polly/ScopInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "polly/Support/GICHelper.h"
|
||||
#include "polly/Support/ISLOStream.h"
|
||||
#include "polly/Support/ISLTools.h"
|
||||
@ -761,42 +760,8 @@ void SimplifyImpl::printScop(raw_ostream &OS, Scop &S) const {
|
||||
printAccesses(OS);
|
||||
}
|
||||
|
||||
static llvm::PreservedAnalyses
|
||||
runSimplifyUsingNPM(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U, int CallNo,
|
||||
raw_ostream *OS) {
|
||||
SimplifyImpl Impl(CallNo);
|
||||
Impl.run(S, &SAR.LI);
|
||||
if (OS) {
|
||||
*OS << "Printing analysis 'Polly - Simplify' for region: '" << S.getName()
|
||||
<< "' in function '" << S.getFunction().getName() << "':\n";
|
||||
Impl.printScop(*OS, S);
|
||||
}
|
||||
|
||||
if (!Impl.isModified())
|
||||
return llvm::PreservedAnalyses::all();
|
||||
|
||||
PreservedAnalyses PA;
|
||||
PA.preserveSet<AllAnalysesOn<Module>>();
|
||||
PA.preserveSet<AllAnalysesOn<Function>>();
|
||||
PA.preserveSet<AllAnalysesOn<Loop>>();
|
||||
return PA;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
llvm::PreservedAnalyses SimplifyPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR,
|
||||
SPMUpdater &U) {
|
||||
return runSimplifyUsingNPM(S, SAM, SAR, U, CallNo, nullptr);
|
||||
}
|
||||
|
||||
llvm::PreservedAnalyses
|
||||
SimplifyPrinterPass::run(Scop &S, ScopAnalysisManager &SAM,
|
||||
ScopStandardAnalysisResults &SAR, SPMUpdater &U) {
|
||||
return runSimplifyUsingNPM(S, SAM, SAR, U, CallNo, &OS);
|
||||
}
|
||||
|
||||
SmallVector<MemoryAccess *, 32> polly::getAccessesInOrder(ScopStmt &Stmt) {
|
||||
SmallVector<MemoryAccess *, 32> Accesses;
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
; CHECK-NEXT: %polly.preload.tmp6.merge = phi ptr [ %polly.access.BPLoc.load, %polly.preload.exec ], [ null, %polly.preload.cond ]
|
||||
;
|
||||
; CHECK-LABEL: polly.stmt.bb5:
|
||||
; CHECK-NEXT: %[[offset:.*]] = shl nuw nsw i64 %polly.indvar6, 2
|
||||
; CHECK-NEXT: %[[offset:.*]] = shl nuw nsw i64 %polly.indvar16, 2
|
||||
; CHECK-NEXT: %{{.*}} = getelementptr i8, ptr %polly.preload.tmp6.merge, i64 %[[offset]]
|
||||
;
|
||||
; void f(int **BPLoc, int *A, int N) {
|
||||
|
||||
@ -27,6 +27,5 @@ endfunction()
|
||||
add_subdirectory(Isl)
|
||||
add_subdirectory(Flatten)
|
||||
add_subdirectory(DeLICM)
|
||||
add_subdirectory(ScopPassManager)
|
||||
add_subdirectory(ScheduleOptimizer)
|
||||
add_subdirectory(Support)
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
add_polly_unittest(ScopPassManagerTests
|
||||
PassManagerTest.cpp
|
||||
)
|
||||
if (NOT LLVM_LINK_LLVM_DYLIB)
|
||||
llvm_map_components_to_libnames(llvm_libs Passes Core Analysis)
|
||||
target_link_libraries(ScopPassManagerTests PRIVATE ${llvm_libs})
|
||||
endif()
|
||||
@ -1,66 +0,0 @@
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "polly/CodeGen/IslAst.h"
|
||||
#include "polly/DependenceInfo.h"
|
||||
#include "polly/ScopPass.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/CGSCCPassManager.h"
|
||||
#include "llvm/Passes/PassBuilder.h"
|
||||
#include "llvm/Transforms/Scalar/LoopPassManager.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace polly;
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class ScopPassRegistry : public ::testing::Test {
|
||||
protected:
|
||||
ModuleAnalysisManager MAM;
|
||||
FunctionAnalysisManager FAM;
|
||||
LoopAnalysisManager LAM;
|
||||
CGSCCAnalysisManager CGAM;
|
||||
ScopAnalysisManager SAM;
|
||||
AAManager AM;
|
||||
|
||||
public:
|
||||
ScopPassRegistry(ScopPassRegistry &&) = delete;
|
||||
ScopPassRegistry(const ScopPassRegistry &) = delete;
|
||||
ScopPassRegistry &operator=(ScopPassRegistry &&) = delete;
|
||||
ScopPassRegistry &operator=(const ScopPassRegistry &) = delete;
|
||||
ScopPassRegistry() {
|
||||
PassBuilder PB;
|
||||
|
||||
AM = PB.buildDefaultAAPipeline();
|
||||
PB.registerModuleAnalyses(MAM);
|
||||
PB.registerFunctionAnalyses(FAM);
|
||||
PB.registerLoopAnalyses(LAM);
|
||||
PB.registerCGSCCAnalyses(CGAM);
|
||||
|
||||
FAM.registerPass([] { return ScopAnalysis(); });
|
||||
FAM.registerPass([] { return ScopInfoAnalysis(); });
|
||||
FAM.registerPass([this] { return ScopAnalysisManagerFunctionProxy(SAM); });
|
||||
|
||||
// SAM.registerPass([] { return IslAstAnalysis(); });
|
||||
// SAM.registerPass([] { return DependenceAnalysis(); });
|
||||
SAM.registerPass([this] { return FunctionAnalysisManagerScopProxy(FAM); });
|
||||
|
||||
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ScopPassRegistry, PrintScops) {
|
||||
FunctionPassManager FPM;
|
||||
FPM.addPass(ScopAnalysisPrinterPass(errs()));
|
||||
}
|
||||
|
||||
TEST_F(ScopPassRegistry, PrintScopInfo) {
|
||||
FunctionPassManager FPM;
|
||||
FPM.addPass(ScopInfoPrinterPass(errs()));
|
||||
}
|
||||
|
||||
TEST_F(ScopPassRegistry, PrinIslAstInfo) {
|
||||
FunctionPassManager FPM;
|
||||
ScopPassManager SPM;
|
||||
// SPM.addPass(IslAstPrinterPass(errs()));
|
||||
FPM.addPass(createFunctionToScopPassAdaptor(std::move(SPM)));
|
||||
}
|
||||
} // namespace
|
||||
Loading…
x
Reference in New Issue
Block a user