aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-06-09 03:22:39 +0000
committerXinliang David Li <davidxl@google.com>2016-06-09 03:22:39 +0000
commitecde1c7f3de37f009723645935afc1badacf79a7 (patch)
tree7b08cde1307bdb9a0985781ee117c75e0e395112
parentd3568e3ba32712603c2bfe53b2dafa948ec46a3e (diff)
downloadllvm-ecde1c7f3de37f009723645935afc1badacf79a7.zip
llvm-ecde1c7f3de37f009723645935afc1badacf79a7.tar.gz
llvm-ecde1c7f3de37f009723645935afc1badacf79a7.tar.bz2
Revert r272194 No need for it if loop Analysis Manager is used
llvm-svn: 272243
-rw-r--r--llvm/include/llvm/Analysis/LoopAccessAnalysis.h66
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp23
-rw-r--r--llvm/lib/Transforms/Scalar/LoopDistribute.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp2
-rw-r--r--llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp2
-rw-r--r--llvm/lib/Transforms/Utils/LoopVersioning.cpp2
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp2
7 files changed, 37 insertions, 62 deletions
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index 71d81b5..795f4cd 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -670,48 +670,10 @@ int getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, const Loop *Lp,
bool Assume = false);
/// \brief Returns true if the memory operations \p A and \p B are consecutive.
-/// This is a simple API that does not depend on the analysis pass.
+/// This is a simple API that does not depend on the analysis pass.
bool isConsecutiveAccess(Value *A, Value *B, const DataLayout &DL,
ScalarEvolution &SE, bool CheckType = true);
-/// \brief This class holds the result of LoopAccessAnalysis pass.
-class LoopAccessAnalysisResult {
-public:
- void setDepAnalyses(AliasAnalysis *AA, DominatorTree *DT, LoopInfo *LI,
- ScalarEvolution *SCEV, TargetLibraryInfo *TLI) {
- this->AA = AA;
- this->DT = DT;
- this->LI = LI;
- this->SCEV = SCEV;
- this->TLI = TLI;
- }
- /// \brief Query the result of the loop access information for the loop \p L.
- ///
- /// If the client speculates (and then issues run-time checks) for the values
- /// of symbolic strides, \p Strides provides the mapping (see
- /// replaceSymbolicStrideSCEV). If there is no cached result available run
- /// the analysis.
- const LoopAccessInfo &getInfo(Loop *L, const ValueToValueMap &Strides);
-
- void print(raw_ostream &OS, const Module *M = nullptr) const;
-
- /// \brief Invalidate the cache when the pass is freed.
- void releaseMemory() {
- LoopAccessInfoMap.clear();
- }
-
-private:
- /// \brief LoopAccessInfo is created on demand. This map caches
- /// the computed results.
- DenseMap<Loop *, std::unique_ptr<LoopAccessInfo>> LoopAccessInfoMap;
-
- AliasAnalysis *AA = nullptr;
- DominatorTree *DT = nullptr;
- LoopInfo *LI = nullptr;
- ScalarEvolution *SCEV = nullptr;
- TargetLibraryInfo *TLI = nullptr;
-};
-
/// \brief This analysis provides dependence information for the memory accesses
/// of a loop.
///
@@ -723,7 +685,7 @@ class LoopAccessAnalysis : public FunctionPass {
public:
static char ID;
- LoopAccessAnalysis() : FunctionPass(ID), LAAR() {
+ LoopAccessAnalysis() : FunctionPass(ID) {
initializeLoopAccessAnalysisPass(*PassRegistry::getPassRegistry());
}
@@ -731,20 +693,32 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const override;
- LoopAccessAnalysisResult &getResult() { return LAAR; }
+ /// \brief Query the result of the loop access information for the loop \p L.
+ ///
+ /// If the client speculates (and then issues run-time checks) for the values
+ /// of symbolic strides, \p Strides provides the mapping (see
+ /// replaceSymbolicStrideSCEV). If there is no cached result available run
+ /// the analysis.
+ const LoopAccessInfo &getInfo(Loop *L, const ValueToValueMap &Strides);
void releaseMemory() override {
// Invalidate the cache when the pass is freed.
- LAAR.releaseMemory();
+ LoopAccessInfoMap.clear();
}
/// \brief Print the result of the analysis when invoked with -analyze.
- void print(raw_ostream &OS, const Module *M = nullptr) const override {
- LAAR.print(OS, M);
- }
+ void print(raw_ostream &OS, const Module *M = nullptr) const override;
private:
- LoopAccessAnalysisResult LAAR;
+ /// \brief The cache.
+ DenseMap<Loop *, std::unique_ptr<LoopAccessInfo>> LoopAccessInfoMap;
+
+ // The used analysis passes.
+ ScalarEvolution *SE;
+ const TargetLibraryInfo *TLI;
+ AliasAnalysis *AA;
+ DominatorTree *DT;
+ LoopInfo *LI;
};
inline Instruction *MemoryDepChecker::Dependence::getSource(
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 23e913a..ff5bc59 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1932,7 +1932,7 @@ void LoopAccessInfo::print(raw_ostream &OS, unsigned Depth) const {
}
const LoopAccessInfo &
-LoopAccessAnalysisResult::getInfo(Loop *L, const ValueToValueMap &Strides) {
+LoopAccessAnalysis::getInfo(Loop *L, const ValueToValueMap &Strides) {
auto &LAI = LoopAccessInfoMap[L];
#ifndef NDEBUG
@@ -1942,8 +1942,8 @@ LoopAccessAnalysisResult::getInfo(Loop *L, const ValueToValueMap &Strides) {
if (!LAI) {
const DataLayout &DL = L->getHeader()->getModule()->getDataLayout();
- LAI = llvm::make_unique<LoopAccessInfo>(L, SCEV, DL, TLI, AA, DT, LI,
- Strides);
+ LAI =
+ llvm::make_unique<LoopAccessInfo>(L, SE, DL, TLI, AA, DT, LI, Strides);
#ifndef NDEBUG
LAI->NumSymbolicStrides = Strides.size();
#endif
@@ -1951,25 +1951,26 @@ LoopAccessAnalysisResult::getInfo(Loop *L, const ValueToValueMap &Strides) {
return *LAI.get();
}
-void LoopAccessAnalysisResult::print(raw_ostream &OS, const Module *M) const {
+void LoopAccessAnalysis::print(raw_ostream &OS, const Module *M) const {
+ LoopAccessAnalysis &LAA = *const_cast<LoopAccessAnalysis *>(this);
+
ValueToValueMap NoSymbolicStrides;
for (Loop *TopLevelLoop : *LI)
for (Loop *L : depth_first(TopLevelLoop)) {
OS.indent(2) << L->getHeader()->getName() << ":\n";
- auto &LAI = const_cast<LoopAccessAnalysisResult *>(this)->getInfo(
- L, NoSymbolicStrides);
+ auto &LAI = LAA.getInfo(L, NoSymbolicStrides);
LAI.print(OS, 4);
}
}
bool LoopAccessAnalysis::runOnFunction(Function &F) {
+ SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
- LAAR.setDepAnalyses(&getAnalysis<AAResultsWrapperPass>().getAAResults(),
- &getAnalysis<DominatorTreeWrapperPass>().getDomTree(),
- &getAnalysis<LoopInfoWrapperPass>().getLoopInfo(),
- &getAnalysis<ScalarEvolutionWrapperPass>().getSE(),
- TLIP ? &TLIP->getTLI() : nullptr);
+ TLI = TLIP ? &TLIP->getTLI() : nullptr;
+ AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
+ DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
return false;
}
diff --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
index 3d82eb8..48405a2 100644
--- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
@@ -608,7 +608,7 @@ public:
return fail("multiple exit blocks");
// LAA will check that we only have a single exiting block.
- LAI = &LAA->getResult().getInfo(L, ValueToValueMap());
+ LAI = &LAA->getInfo(L, ValueToValueMap());
// Currently, we only distribute to isolate the part of the loop with
// dependence cycles to enable partial vectorization.
diff --git a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
index 32c0bd6..8f2b3ac 100644
--- a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
@@ -552,7 +552,7 @@ public:
// Now walk the identified inner loops.
bool Changed = false;
for (Loop *L : Worklist) {
- const LoopAccessInfo &LAI = LAA->getResult().getInfo(L, ValueToValueMap());
+ const LoopAccessInfo &LAI = LAA->getInfo(L, ValueToValueMap());
// The actual work is performed by LoadEliminationForLoop.
LoadEliminationForLoop LEL(L, LI, LAI, DT);
Changed |= LEL.processLoop();
diff --git a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
index dab4ba1..7ccf227 100644
--- a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
@@ -411,7 +411,7 @@ bool LoopVersioningLICM::legalLoopInstructions() {
return false;
}
// Get LoopAccessInfo from current loop.
- LAI = &LAA->getResult().getInfo(CurLoop, Strides);
+ LAI = &LAA->getInfo(CurLoop, Strides);
// Check LoopAccessInfo for need of runtime check.
if (LAI->getRuntimePointerChecking()->getChecks().empty()) {
DEBUG(dbgs() << " LAA: Runtime check not found !!\n");
diff --git a/llvm/lib/Transforms/Utils/LoopVersioning.cpp b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
index 3e677d8..736d79a 100644
--- a/llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -268,7 +268,7 @@ public:
// Now walk the identified inner loops.
bool Changed = false;
for (Loop *L : Worklist) {
- const LoopAccessInfo &LAI = LAA->getResult().getInfo(L, ValueToValueMap());
+ const LoopAccessInfo &LAI = LAA->getInfo(L, ValueToValueMap());
if (LAI.getNumRuntimePointerChecks() ||
!LAI.PSE.getUnionPredicate().isAlwaysTrue()) {
LoopVersioning LVer(LAI, L, LI, DT, SE);
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 78ea58c..144eab5 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4931,7 +4931,7 @@ void LoopVectorizationLegality::collectLoopUniforms() {
}
bool LoopVectorizationLegality::canVectorizeMemory() {
- LAI = &LAA->getResult().getInfo(TheLoop, Strides);
+ LAI = &LAA->getInfo(TheLoop, Strides);
auto &OptionalReport = LAI->getReport();
if (OptionalReport)
emitAnalysis(VectorizationReport(*OptionalReport));