summaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/LoopAccessAnalysis.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Analysis/LoopAccessAnalysis.h')
-rw-r--r--include/llvm/Analysis/LoopAccessAnalysis.h62
1 files changed, 19 insertions, 43 deletions
diff --git a/include/llvm/Analysis/LoopAccessAnalysis.h b/include/llvm/Analysis/LoopAccessAnalysis.h
index 619fab283102..76066f6003e7 100644
--- a/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -20,7 +20,9 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AliasSetTracker.h"
+#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
+#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
@@ -34,6 +36,7 @@ class Loop;
class SCEV;
class SCEVUnionPredicate;
class LoopAccessInfo;
+class OptimizationRemarkEmitter;
/// Optimization analysis message produced during vectorization. Messages inform
/// the user why vectorization did not occur.
@@ -63,10 +66,9 @@ public:
/// \brief Emit an analysis note for \p PassName with the debug location from
/// the instruction in \p Message if available. Otherwise use the location of
/// \p TheLoop.
- static void emitAnalysis(const LoopAccessReport &Message,
- const Function *TheFunction,
- const Loop *TheLoop,
- const char *PassName);
+ static void emitAnalysis(const LoopAccessReport &Message, const Loop *TheLoop,
+ const char *PassName,
+ OptimizationRemarkEmitter &ORE);
};
/// \brief Collection of parameters shared beetween the Loop Vectorizer and the
@@ -516,38 +518,6 @@ public:
LoopAccessInfo(Loop *L, ScalarEvolution *SE, const TargetLibraryInfo *TLI,
AliasAnalysis *AA, DominatorTree *DT, LoopInfo *LI);
- // FIXME:
- // Hack for MSVC 2013 which sems like it can't synthesize this even
- // with default keyword:
- // LoopAccessInfo(LoopAccessInfo &&LAI) = default;
- LoopAccessInfo(LoopAccessInfo &&LAI)
- : PSE(std::move(LAI.PSE)), PtrRtChecking(std::move(LAI.PtrRtChecking)),
- DepChecker(std::move(LAI.DepChecker)), TheLoop(LAI.TheLoop),
- NumLoads(LAI.NumLoads), NumStores(LAI.NumStores),
- MaxSafeDepDistBytes(LAI.MaxSafeDepDistBytes), CanVecMem(LAI.CanVecMem),
- StoreToLoopInvariantAddress(LAI.StoreToLoopInvariantAddress),
- Report(std::move(LAI.Report)),
- SymbolicStrides(std::move(LAI.SymbolicStrides)),
- StrideSet(std::move(LAI.StrideSet)) {}
- // LoopAccessInfo &operator=(LoopAccessInfo &&LAI) = default;
- LoopAccessInfo &operator=(LoopAccessInfo &&LAI) {
- assert(this != &LAI);
-
- PSE = std::move(LAI.PSE);
- PtrRtChecking = std::move(LAI.PtrRtChecking);
- DepChecker = std::move(LAI.DepChecker);
- TheLoop = LAI.TheLoop;
- NumLoads = LAI.NumLoads;
- NumStores = LAI.NumStores;
- MaxSafeDepDistBytes = LAI.MaxSafeDepDistBytes;
- CanVecMem = LAI.CanVecMem;
- StoreToLoopInvariantAddress = LAI.StoreToLoopInvariantAddress;
- Report = std::move(LAI.Report);
- SymbolicStrides = std::move(LAI.SymbolicStrides);
- StrideSet = std::move(LAI.StrideSet);
- return *this;
- }
-
/// Return true we can analyze the memory accesses in the loop and there are
/// no memory dependence cycles.
bool canVectorizeMemory() const { return CanVecMem; }
@@ -594,7 +564,7 @@ public:
/// \brief The diagnostics report generated for the analysis. E.g. why we
/// couldn't analyze the loop.
- const Optional<LoopAccessReport> &getReport() const { return Report; }
+ const OptimizationRemarkAnalysis *getReport() const { return Report.get(); }
/// \brief the Memory Dependence Checker which can determine the
/// loop-independent and loop-carried dependences between memory accesses.
@@ -640,7 +610,13 @@ private:
/// pass.
bool canAnalyzeLoop();
- void emitAnalysis(LoopAccessReport &Message);
+ /// \brief Save the analysis remark.
+ ///
+ /// LAA does not directly emits the remarks. Instead it stores it which the
+ /// client can retrieve and presents as its own analysis
+ /// (e.g. -Rpass-analysis=loop-vectorize).
+ OptimizationRemarkAnalysis &recordAnalysis(StringRef RemarkName,
+ Instruction *Instr = nullptr);
/// \brief Collect memory access with loop invariant strides.
///
@@ -674,7 +650,7 @@ private:
/// \brief The diagnostics report generated for the analysis. E.g. why we
/// couldn't analyze the loop.
- Optional<LoopAccessReport> Report;
+ std::unique_ptr<OptimizationRemarkAnalysis> Report;
/// \brief If an access has a symbolic strides, this maps the pointer value to
/// the stride symbol.
@@ -712,7 +688,7 @@ const SCEV *replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE,
/// run-time assumptions.
int64_t getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, const Loop *Lp,
const ValueToValueMap &StridesMap = ValueToValueMap(),
- bool Assume = false);
+ bool Assume = false, bool ShouldCheckWrap = true);
/// \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.
@@ -773,11 +749,11 @@ private:
class LoopAccessAnalysis
: public AnalysisInfoMixin<LoopAccessAnalysis> {
friend AnalysisInfoMixin<LoopAccessAnalysis>;
- static char PassID;
+ static AnalysisKey Key;
public:
typedef LoopAccessInfo Result;
- Result run(Loop &, AnalysisManager<Loop> &);
+ Result run(Loop &, LoopAnalysisManager &);
static StringRef name() { return "LoopAccessAnalysis"; }
};
@@ -788,7 +764,7 @@ class LoopAccessInfoPrinterPass
public:
explicit LoopAccessInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
- PreservedAnalyses run(Loop &L, AnalysisManager<Loop> &AM);
+ PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM);
};
inline Instruction *MemoryDepChecker::Dependence::getSource(