Rename the Dependences pass to DependenceInfo [NFC]

We rename the Dependences pass to DependenceInfo as a first step to a
  caching pass policy. The new DependenceInfo pass will later provide
  "Dependences" for a SCoP.

  To keep consistency the test folder is renamed too.

llvm-svn: 231308
This commit is contained in:
Johannes Doerfert 2015-03-04 22:43:40 +00:00
parent eca5151780
commit f6557f98a2
35 changed files with 78 additions and 76 deletions

View File

@ -1,4 +1,4 @@
//===------ polly/Dependences.h - Polyhedral dependency analysis *- C++ -*-===//
//===--- polly/DependenceInfo.h - Polyhedral dependency analysis *- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -43,7 +43,7 @@ class Scop;
class ScopStmt;
class MemoryAccess;
class Dependences : public ScopPass {
class DependenceInfo : public ScopPass {
public:
static char ID;
@ -77,7 +77,7 @@ public:
typedef std::map<ScopStmt *, isl_map *> StatementToIslMapTy;
Dependences();
DependenceInfo();
/// @brief Check if a new scattering is valid.
///
@ -165,7 +165,7 @@ private:
namespace llvm {
class PassRegistry;
void initializeDependencesPass(llvm::PassRegistry &);
void initializeDependenceInfoPass(llvm::PassRegistry &);
}
#endif

View File

@ -28,7 +28,7 @@ class RegionPass;
namespace polly {
llvm::Pass *createCodePreparationPass();
llvm::Pass *createDeadCodeElimPass();
llvm::Pass *createDependencesPass();
llvm::Pass *createDependenceInfoPass();
llvm::Pass *createDOTOnlyPrinterPass();
llvm::Pass *createDOTOnlyViewerPass();
llvm::Pass *createDOTPrinterPass();
@ -63,7 +63,7 @@ struct PollyForcePassLinking {
polly::createCodePreparationPass();
polly::createDeadCodeElimPass();
polly::createDependencesPass();
polly::createDependenceInfoPass();
polly::createDOTOnlyPrinterPass();
polly::createDOTOnlyViewerPass();
polly::createDOTPrinterPass();

View File

@ -20,7 +20,7 @@
//
//===----------------------------------------------------------------------===//
//
#include "polly/Dependences.h"
#include "polly/DependenceInfo.h"
#include "polly/LinkAllPasses.h"
#include "polly/Options.h"
#include "polly/ScopInfo.h"
@ -63,12 +63,13 @@ static cl::opt<enum AnalysisType> OptAnalysisType(
cl::cat(PollyCategory));
//===----------------------------------------------------------------------===//
Dependences::Dependences() : ScopPass(ID) { RAW = WAR = WAW = nullptr; }
DependenceInfo::DependenceInfo() : ScopPass(ID) { RAW = WAR = WAW = nullptr; }
void Dependences::collectInfo(Scop &S, isl_union_map **Read,
isl_union_map **Write, isl_union_map **MayWrite,
isl_union_map **AccessSchedule,
isl_union_map **StmtSchedule) {
void DependenceInfo::collectInfo(Scop &S, isl_union_map **Read,
isl_union_map **Write,
isl_union_map **MayWrite,
isl_union_map **AccessSchedule,
isl_union_map **StmtSchedule) {
isl_space *Space = S.getParamSpace();
*Read = isl_union_map_empty(isl_space_copy(Space));
*Write = isl_union_map_empty(isl_space_copy(Space));
@ -173,7 +174,7 @@ static int fixSetToZero(__isl_take isl_set *Zero, void *user) {
///
/// Note: This function also computes the (reverse) transitive closure of the
/// reduction dependences.
void Dependences::addPrivatizationDependences() {
void DependenceInfo::addPrivatizationDependences() {
isl_union_map *PrivRAW, *PrivWAW, *PrivWAR;
// The transitive closure might be over approximated, thus could lead to
@ -216,7 +217,7 @@ void Dependences::addPrivatizationDependences() {
isl_union_set_free(Universe);
}
void Dependences::calculateDependences(Scop &S) {
void DependenceInfo::calculateDependences(Scop &S) {
isl_union_map *Read, *Write, *MayWrite, *AccessSchedule, *StmtSchedule,
*Schedule;
@ -432,18 +433,18 @@ void Dependences::calculateDependences(Scop &S) {
DEBUG(printScop(dbgs(), S));
}
void Dependences::recomputeDependences() {
void DependenceInfo::recomputeDependences() {
releaseMemory();
calculateDependences(*S);
}
bool Dependences::runOnScop(Scop &ScopVar) {
bool DependenceInfo::runOnScop(Scop &ScopVar) {
S = &ScopVar;
recomputeDependences();
return false;
}
bool Dependences::isValidScattering(StatementToIslMapTy *NewScattering) {
bool DependenceInfo::isValidScattering(StatementToIslMapTy *NewScattering) {
Scop &S = *this->S;
if (LegalityCheckDisabled)
@ -501,8 +502,8 @@ bool Dependences::isValidScattering(StatementToIslMapTy *NewScattering) {
// dimension, then the loop is parallel. The distance is zero in the current
// dimension if it is a subset of a map with equal values for the current
// dimension.
bool Dependences::isParallel(isl_union_map *Schedule, isl_union_map *Deps,
isl_pw_aff **MinDistancePtr) {
bool DependenceInfo::isParallel(isl_union_map *Schedule, isl_union_map *Deps,
isl_pw_aff **MinDistancePtr) {
isl_set *Deltas, *Distance;
isl_map *ScheduleDeps;
unsigned Dimension;
@ -556,7 +557,7 @@ static void printDependencyMap(raw_ostream &OS, __isl_keep isl_union_map *DM) {
OS << "n/a\n";
}
void Dependences::printScop(raw_ostream &OS, Scop &) const {
void DependenceInfo::printScop(raw_ostream &OS, Scop &) const {
OS << "\tRAW dependences:\n\t\t";
printDependencyMap(OS, RAW);
OS << "\tWAR dependences:\n\t\t";
@ -569,7 +570,7 @@ void Dependences::printScop(raw_ostream &OS, Scop &) const {
printDependencyMap(OS, TC_RED);
}
void Dependences::releaseMemory() {
void DependenceInfo::releaseMemory() {
isl_union_map_free(RAW);
isl_union_map_free(WAR);
isl_union_map_free(WAW);
@ -583,7 +584,7 @@ void Dependences::releaseMemory() {
ReductionDependences.clear();
}
isl_union_map *Dependences::getDependences(int Kinds) {
isl_union_map *DependenceInfo::getDependences(int Kinds) {
assert(hasValidDependences() && "No valid dependences available");
isl_space *Space = isl_union_map_get_space(RAW);
isl_union_map *Deps = isl_union_map_empty(Space);
@ -608,30 +609,30 @@ isl_union_map *Dependences::getDependences(int Kinds) {
return Deps;
}
bool Dependences::hasValidDependences() {
bool DependenceInfo::hasValidDependences() {
return (RAW != nullptr) && (WAR != nullptr) && (WAW != nullptr);
}
isl_map *Dependences::getReductionDependences(MemoryAccess *MA) {
isl_map *DependenceInfo::getReductionDependences(MemoryAccess *MA) {
return isl_map_copy(ReductionDependences[MA]);
}
void Dependences::setReductionDependences(MemoryAccess *MA, isl_map *D) {
void DependenceInfo::setReductionDependences(MemoryAccess *MA, isl_map *D) {
assert(ReductionDependences.count(MA) == 0 &&
"Reduction dependences set twice!");
ReductionDependences[MA] = D;
}
void Dependences::getAnalysisUsage(AnalysisUsage &AU) const {
void DependenceInfo::getAnalysisUsage(AnalysisUsage &AU) const {
ScopPass::getAnalysisUsage(AU);
}
char Dependences::ID = 0;
char DependenceInfo::ID = 0;
Pass *polly::createDependencesPass() { return new Dependences(); }
Pass *polly::createDependenceInfoPass() { return new DependenceInfo(); }
INITIALIZE_PASS_BEGIN(Dependences, "polly-dependences",
INITIALIZE_PASS_BEGIN(DependenceInfo, "polly-dependences",
"Polly - Calculate dependences", false, false);
INITIALIZE_PASS_DEPENDENCY(ScopInfo);
INITIALIZE_PASS_END(Dependences, "polly-dependences",
INITIALIZE_PASS_END(DependenceInfo, "polly-dependences",
"Polly - Calculate dependences", false, false)

View File

@ -104,7 +104,7 @@ set (ISL_FILES
add_polly_library(Polly
Analysis/Dependences.cpp
Analysis/DependenceInfo.cpp
Analysis/ScopDetection.cpp
Analysis/ScopDetectionDiagnostic.cpp
Analysis/ScopInfo.cpp

View File

@ -21,7 +21,7 @@
#include "polly/CodeGen/CodeGeneration.h"
#include "polly/CodeGen/IslAst.h"
#include "polly/Dependences.h"
#include "polly/DependenceInfo.h"
#include "polly/LinkAllPasses.h"
#include "polly/Options.h"
#include "polly/ScopInfo.h"
@ -73,7 +73,7 @@ static cl::opt<bool> NoEarlyExit(
namespace polly {
class IslAst {
public:
IslAst(Scop *Scop, Dependences &D);
IslAst(Scop *Scop, DependenceInfo &D);
~IslAst();
@ -111,7 +111,7 @@ struct AstBuildUserInfo {
: Deps(nullptr), InParallelFor(false), LastForNodeId(nullptr) {}
/// @brief The dependence information used for the parallelism check.
Dependences *Deps;
DependenceInfo *Deps;
/// @brief Flag to indicate that we are inside a parallel for node.
bool InParallelFor;
@ -197,20 +197,21 @@ static isl_printer *cbPrintFor(__isl_take isl_printer *Printer,
/// we can perform the parallelism check as we are only interested in a zero
/// (or non-zero) dependence distance on the dimension in question.
static bool astScheduleDimIsParallel(__isl_keep isl_ast_build *Build,
Dependences *D,
DependenceInfo *D,
IslAstUserPayload *NodeInfo) {
if (!D->hasValidDependences())
return false;
isl_union_map *Schedule = isl_ast_build_get_schedule(Build);
isl_union_map *Deps = D->getDependences(
Dependences::TYPE_RAW | Dependences::TYPE_WAW | Dependences::TYPE_WAR);
isl_union_map *Deps =
D->getDependences(DependenceInfo::TYPE_RAW | DependenceInfo::TYPE_WAW |
DependenceInfo::TYPE_WAR);
if (!D->isParallel(Schedule, Deps, &NodeInfo->MinimalDependenceDistance) &&
!isl_union_map_free(Schedule))
return false;
isl_union_map *RedDeps = D->getDependences(Dependences::TYPE_TC_RED);
isl_union_map *RedDeps = D->getDependences(DependenceInfo::TYPE_TC_RED);
if (!D->isParallel(Schedule, RedDeps))
NodeInfo->IsReductionParallel = true;
@ -362,7 +363,7 @@ static bool benefitsFromPolly(Scop *Scop, bool PerformParallelTest) {
return true;
}
IslAst::IslAst(Scop *Scop, Dependences &D)
IslAst::IslAst(Scop *Scop, DependenceInfo &D)
: S(Scop), Root(nullptr), RunCondition(nullptr) {
bool PerformParallelTest = PollyParallel || DetectParallel ||
@ -427,7 +428,7 @@ bool IslAstInfo::runOnScop(Scop &Scop) {
S = &Scop;
Dependences &D = getAnalysis<Dependences>();
DependenceInfo &D = getAnalysis<DependenceInfo>();
Ast = new IslAst(&Scop, D);
@ -567,7 +568,7 @@ void IslAstInfo::getAnalysisUsage(AnalysisUsage &AU) const {
// Get the Common analysis usage of ScopPasses.
ScopPass::getAnalysisUsage(AU);
AU.addRequired<ScopInfo>();
AU.addRequired<Dependences>();
AU.addRequired<DependenceInfo>();
}
char IslAstInfo::ID = 0;
@ -578,6 +579,6 @@ INITIALIZE_PASS_BEGIN(IslAstInfo, "polly-ast",
"Polly - Generate an AST of the SCoP (isl)", false,
false);
INITIALIZE_PASS_DEPENDENCY(ScopInfo);
INITIALIZE_PASS_DEPENDENCY(Dependences);
INITIALIZE_PASS_DEPENDENCY(DependenceInfo);
INITIALIZE_PASS_END(IslAstInfo, "polly-ast",
"Polly - Generate an AST from the SCoP (isl)", false, false)

View File

@ -25,7 +25,7 @@
#include "polly/CodeGen/IslAst.h"
#include "polly/CodeGen/LoopGenerators.h"
#include "polly/CodeGen/Utils.h"
#include "polly/Dependences.h"
#include "polly/DependenceInfo.h"
#include "polly/LinkAllPasses.h"
#include "polly/ScopInfo.h"
#include "polly/Support/GICHelper.h"
@ -1002,7 +1002,7 @@ public:
AU.addRequired<ScopInfo>();
AU.addRequired<LoopInfoWrapperPass>();
AU.addPreserved<Dependences>();
AU.addPreserved<DependenceInfo>();
AU.addPreserved<LoopInfoWrapperPass>();
AU.addPreserved<DominatorTreeWrapperPass>();
@ -1026,7 +1026,7 @@ Pass *polly::createIslCodeGenerationPass() { return new IslCodeGeneration(); }
INITIALIZE_PASS_BEGIN(IslCodeGeneration, "polly-codegen-isl",
"Polly - Create LLVM-IR from SCoPs", false, false);
INITIALIZE_PASS_DEPENDENCY(Dependences);
INITIALIZE_PASS_DEPENDENCY(DependenceInfo);
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass);
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass);
INITIALIZE_PASS_DEPENDENCY(RegionInfoPass);

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "polly/LinkAllPasses.h"
#include "polly/Dependences.h"
#include "polly/DependenceInfo.h"
#include "polly/Options.h"
#include "polly/ScopInfo.h"
#include "polly/ScopPass.h"
@ -178,11 +178,11 @@ void JSONImporter::printScop(raw_ostream &OS, Scop &S) const {
OS << "New access function '" << *I << "'detected in JSCOP file\n";
}
typedef Dependences::StatementToIslMapTy StatementToIslMapTy;
typedef DependenceInfo::StatementToIslMapTy StatementToIslMapTy;
bool JSONImporter::runOnScop(Scop &S) {
Region &R = S.getRegion();
Dependences *D = &getAnalysis<Dependences>();
DependenceInfo *D = &getAnalysis<DependenceInfo>();
const DataLayout &DL = getAnalysis<DataLayoutPass>().getDataLayout();
std::string FileName = ImportDir + "/" + getFileName(S);
@ -355,7 +355,7 @@ bool JSONImporter::runOnScop(Scop &S) {
void JSONImporter::getAnalysisUsage(AnalysisUsage &AU) const {
ScopPass::getAnalysisUsage(AU);
AU.addRequired<Dependences>();
AU.addRequired<DependenceInfo>();
AU.addRequired<DataLayoutPass>();
}
Pass *polly::createJSONImporterPass() { return new JSONImporter(); }
@ -364,7 +364,7 @@ INITIALIZE_PASS_BEGIN(JSONExporter, "polly-export-jscop",
"Polly - Export Scops as JSON"
" (Writes a .jscop file for each Scop)",
false, false);
INITIALIZE_PASS_DEPENDENCY(Dependences)
INITIALIZE_PASS_DEPENDENCY(DependenceInfo)
INITIALIZE_PASS_END(JSONExporter, "polly-export-jscop",
"Polly - Export Scops as JSON"
" (Writes a .jscop file for each Scop)",
@ -374,7 +374,7 @@ INITIALIZE_PASS_BEGIN(JSONImporter, "polly-import-jscop",
"Polly - Import Scops from JSON"
" (Reads a .jscop file for each Scop)",
false, false);
INITIALIZE_PASS_DEPENDENCY(Dependences)
INITIALIZE_PASS_DEPENDENCY(DependenceInfo)
INITIALIZE_PASS_DEPENDENCY(DataLayoutPass)
INITIALIZE_PASS_END(JSONImporter, "polly-import-jscop",
"Polly - Import Scops from JSON"

View File

@ -119,7 +119,7 @@ SOURCES= Polly.cpp \
Support/SCEVValidator.cpp \
Support/RegisterPasses.cpp \
Support/ScopHelper.cpp \
Analysis/Dependences.cpp \
Analysis/DependenceInfo.cpp \
Analysis/ScopDetection.cpp \
Analysis/ScopDetectionDiagnostic.cpp \
Analysis/ScopInfo.cpp \

View File

@ -22,7 +22,7 @@
#include "polly/RegisterPasses.h"
#include "polly/Canonicalization.h"
#include "polly/CodeGen/CodeGeneration.h"
#include "polly/Dependences.h"
#include "polly/DependenceInfo.h"
#include "polly/LinkAllPasses.h"
#include "polly/Options.h"
#include "polly/ScopDetection.h"
@ -142,7 +142,7 @@ void initializePollyPasses(PassRegistry &Registry) {
initializeIslCodeGenerationPass(Registry);
initializeCodePreparationPass(Registry);
initializeDeadCodeElimPass(Registry);
initializeDependencesPass(Registry);
initializeDependenceInfoPass(Registry);
initializeIndependentBlocksPass(Registry);
initializeJSONExporterPass(Registry);
initializeJSONImporterPass(Registry);

View File

@ -32,7 +32,7 @@
//
//===----------------------------------------------------------------------===//
#include "polly/Dependences.h"
#include "polly/DependenceInfo.h"
#include "polly/LinkAllPasses.h"
#include "polly/ScopInfo.h"
#include "llvm/Support/CommandLine.h"
@ -112,14 +112,14 @@ isl_union_set *DeadCodeElim::getLiveOut(Scop &S) {
/// combine a certain number of precise steps with one approximating step that
/// simplifies the life set with an affine hull.
bool DeadCodeElim::eliminateDeadCode(Scop &S, int PreciseSteps) {
Dependences *D = &getAnalysis<Dependences>();
DependenceInfo *D = &getAnalysis<DependenceInfo>();
if (!D->hasValidDependences())
return false;
isl_union_set *Live = getLiveOut(S);
isl_union_map *Dep =
D->getDependences(Dependences::TYPE_RAW | Dependences::TYPE_RED);
D->getDependences(DependenceInfo::TYPE_RAW | DependenceInfo::TYPE_RED);
Dep = isl_union_map_reverse(Dep);
if (PreciseSteps == -1)
@ -168,14 +168,14 @@ void DeadCodeElim::printScop(raw_ostream &, Scop &) const {}
void DeadCodeElim::getAnalysisUsage(AnalysisUsage &AU) const {
ScopPass::getAnalysisUsage(AU);
AU.addRequired<Dependences>();
AU.addRequired<DependenceInfo>();
}
Pass *polly::createDeadCodeElimPass() { return new DeadCodeElim(); }
INITIALIZE_PASS_BEGIN(DeadCodeElim, "polly-dce",
"Polly - Remove dead iterations", false, false)
INITIALIZE_PASS_DEPENDENCY(Dependences)
INITIALIZE_PASS_DEPENDENCY(DependenceInfo)
INITIALIZE_PASS_DEPENDENCY(ScopInfo)
INITIALIZE_PASS_END(DeadCodeElim, "polly-dce", "Polly - Remove dead iterations",
false, false)

View File

@ -15,7 +15,7 @@
#ifdef PLUTO_FOUND
#include "polly/CodeGen/CodeGeneration.h"
#include "polly/Dependences.h"
#include "polly/DependenceInfo.h"
#include "polly/LinkAllPasses.h"
#include "polly/Options.h"
#include "polly/ScopInfo.h"
@ -172,10 +172,10 @@ bool PlutoOptimizer::runOnScop(Scop &S) {
isl_union_map *Deps, *ToPlutoNames, *Schedule;
PlutoOptions *Options;
Dependences *D = &getAnalysis<Dependences>();
DependenceInfo *D = &getAnalysis<DependenceInfo>();
int DependencesKinds =
Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW;
int DependencesKinds = DependenceInfo::TYPE_RAW | DependenceInfo::TYPE_WAR |
DependenceInfo::TYPE_WAW;
Deps = D->getDependences(DependencesKinds);
Domain = S.getDomains();
@ -254,7 +254,7 @@ void PlutoOptimizer::printScop(raw_ostream &, Scop &) const {}
void PlutoOptimizer::getAnalysisUsage(AnalysisUsage &AU) const {
ScopPass::getAnalysisUsage(AU);
AU.addRequired<Dependences>();
AU.addRequired<DependenceInfo>();
}
Pass *polly::createPlutoOptimizerPass() { return new PlutoOptimizer(); }
@ -262,7 +262,7 @@ Pass *polly::createPlutoOptimizerPass() { return new PlutoOptimizer(); }
INITIALIZE_PASS_BEGIN(PlutoOptimizer, "polly-opt-pluto",
"Polly - Optimize schedule of SCoP (Pluto)", false,
false);
INITIALIZE_PASS_DEPENDENCY(Dependences);
INITIALIZE_PASS_DEPENDENCY(DependenceInfo);
INITIALIZE_PASS_DEPENDENCY(ScopInfo);
INITIALIZE_PASS_END(PlutoOptimizer, "polly-opt-pluto",
"Polly - Optimize schedule of SCoP (Pluto)", false, false)

View File

@ -26,7 +26,7 @@
#include "isl/schedule.h"
#include "isl/space.h"
#include "polly/CodeGen/CodeGeneration.h"
#include "polly/Dependences.h"
#include "polly/DependenceInfo.h"
#include "polly/LinkAllPasses.h"
#include "polly/Options.h"
#include "polly/ScopInfo.h"
@ -481,7 +481,7 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) {
return false;
}
Dependences *D = &getAnalysis<Dependences>();
DependenceInfo *D = &getAnalysis<DependenceInfo>();
if (!D->hasValidDependences())
return false;
@ -490,20 +490,20 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) {
LastSchedule = nullptr;
// Build input data.
int ValidityKinds =
Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW;
int ValidityKinds = DependenceInfo::TYPE_RAW | DependenceInfo::TYPE_WAR |
DependenceInfo::TYPE_WAW;
int ProximityKinds;
if (OptimizeDeps == "all")
ProximityKinds =
Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW;
ProximityKinds = DependenceInfo::TYPE_RAW | DependenceInfo::TYPE_WAR |
DependenceInfo::TYPE_WAW;
else if (OptimizeDeps == "raw")
ProximityKinds = Dependences::TYPE_RAW;
ProximityKinds = DependenceInfo::TYPE_RAW;
else {
errs() << "Do not know how to optimize for '" << OptimizeDeps << "'"
<< " Falling back to optimizing all dependences.\n";
ProximityKinds =
Dependences::TYPE_RAW | Dependences::TYPE_WAR | Dependences::TYPE_WAW;
ProximityKinds = DependenceInfo::TYPE_RAW | DependenceInfo::TYPE_WAR |
DependenceInfo::TYPE_WAW;
}
isl_union_set *Domain = S.getDomains();
@ -648,7 +648,7 @@ void IslScheduleOptimizer::printScop(raw_ostream &OS, Scop &) const {
void IslScheduleOptimizer::getAnalysisUsage(AnalysisUsage &AU) const {
ScopPass::getAnalysisUsage(AU);
AU.addRequired<Dependences>();
AU.addRequired<DependenceInfo>();
}
Pass *polly::createIslScheduleOptimizerPass() {
@ -657,7 +657,7 @@ Pass *polly::createIslScheduleOptimizerPass() {
INITIALIZE_PASS_BEGIN(IslScheduleOptimizer, "polly-opt-isl",
"Polly - Optimize schedule of SCoP", false, false);
INITIALIZE_PASS_DEPENDENCY(Dependences);
INITIALIZE_PASS_DEPENDENCY(DependenceInfo);
INITIALIZE_PASS_DEPENDENCY(ScopInfo);
INITIALIZE_PASS_END(IslScheduleOptimizer, "polly-opt-isl",
"Polly - Optimize schedule of SCoP", false, false)