[LoopAccesses] Stash the report from the analysis rather than emitting it

The transformation passes will query this and then emit them as part of
their own report.  The currently only user LV is modified to do just
that.

This is part of the patchset that converts LoopAccessAnalysis into an
actual analysis pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Adam Nemet 2015-02-19 19:14:56 +00:00
parent 4b86046b7c
commit 7b507eb2a5
3 changed files with 22 additions and 9 deletions

View File

@ -16,6 +16,7 @@
#define LLVM_ANALYSIS_LOOPACCESSANALYSIS_H #define LLVM_ANALYSIS_LOOPACCESSANALYSIS_H
#include "llvm/ADT/EquivalenceClasses.h" #include "llvm/ADT/EquivalenceClasses.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SetVector.h" #include "llvm/ADT/SetVector.h"
#include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Analysis/AliasSetTracker.h"
@ -135,11 +136,11 @@ public:
SmallVector<unsigned, 2> AliasSetId; SmallVector<unsigned, 2> AliasSetId;
}; };
LoopAccessInfo(Function *F, Loop *L, ScalarEvolution *SE, LoopAccessInfo(Loop *L, ScalarEvolution *SE, const DataLayout *DL,
const DataLayout *DL, const TargetLibraryInfo *TLI, const TargetLibraryInfo *TLI, AliasAnalysis *AA,
AliasAnalysis *AA, DominatorTree *DT) : DominatorTree *DT) :
TheFunction(F), TheLoop(L), SE(SE), DL(DL), TLI(TLI), AA(AA), DT(DT), TheLoop(L), SE(SE), DL(DL), TLI(TLI), AA(AA), DT(DT), NumLoads(0),
NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1U) {} NumStores(0), MaxSafeDepDistBytes(-1U) {}
/// Return true we can analyze the memory accesses in the loop and there are /// Return true we can analyze the memory accesses in the loop and there are
/// no memory dependence cycles. Replaces symbolic strides using Strides. /// no memory dependence cycles. Replaces symbolic strides using Strides.
@ -166,13 +167,16 @@ public:
/// second value is the final comparator value or NULL if no check is needed. /// second value is the final comparator value or NULL if no check is needed.
std::pair<Instruction *, Instruction *> addRuntimeCheck(Instruction *Loc); std::pair<Instruction *, Instruction *> addRuntimeCheck(Instruction *Loc);
/// \brief The diagnostics report generated for the analysis. E.g. why we
/// couldn't analyze the loop.
Optional<VectorizationReport> &getReport() { return Report; }
private: private:
void emitAnalysis(VectorizationReport &Message); void emitAnalysis(VectorizationReport &Message);
/// We need to check that all of the pointers in this list are disjoint /// We need to check that all of the pointers in this list are disjoint
/// at runtime. /// at runtime.
RuntimePointerCheck PtrRtCheck; RuntimePointerCheck PtrRtCheck;
Function *TheFunction;
Loop *TheLoop; Loop *TheLoop;
ScalarEvolution *SE; ScalarEvolution *SE;
const DataLayout *DL; const DataLayout *DL;
@ -184,6 +188,10 @@ private:
unsigned NumStores; unsigned NumStores;
unsigned MaxSafeDepDistBytes; unsigned MaxSafeDepDistBytes;
/// \brief The diagnostics report generated for the analysis. E.g. why we
/// couldn't analyze the loop.
Optional<VectorizationReport> Report;
}; };
Value *stripIntegerCast(Value *V); Value *stripIntegerCast(Value *V);

View File

@ -1120,7 +1120,8 @@ bool LoopAccessInfo::blockNeedsPredication(BasicBlock *BB, Loop *TheLoop,
} }
void LoopAccessInfo::emitAnalysis(VectorizationReport &Message) { void LoopAccessInfo::emitAnalysis(VectorizationReport &Message) {
VectorizationReport::emitAnalysis(Message, TheFunction, TheLoop); assert(!Report && "Multiple reports generated");
Report = Message;
} }
bool LoopAccessInfo::isUniform(Value *V) { bool LoopAccessInfo::isUniform(Value *V) {

View File

@ -535,7 +535,7 @@ public:
: NumPredStores(0), TheLoop(L), SE(SE), DL(DL), : NumPredStores(0), TheLoop(L), SE(SE), DL(DL),
TLI(TLI), TheFunction(F), TTI(TTI), DT(DT), Induction(nullptr), TLI(TLI), TheFunction(F), TTI(TTI), DT(DT), Induction(nullptr),
WidestIndTy(nullptr), WidestIndTy(nullptr),
LAI(F, L, SE, DL, TLI, AA, DT), LAI(L, SE, DL, TLI, AA, DT),
HasFunNoNaNAttr(false) {} HasFunNoNaNAttr(false) {}
/// This enum represents the kinds of reductions that we support. /// This enum represents the kinds of reductions that we support.
@ -3807,7 +3807,11 @@ void LoopVectorizationLegality::collectLoopUniforms() {
} }
bool LoopVectorizationLegality::canVectorizeMemory() { bool LoopVectorizationLegality::canVectorizeMemory() {
return LAI.canVectorizeMemory(Strides); bool Success = LAI.canVectorizeMemory(Strides);
auto &OptionalReport = LAI.getReport();
if (OptionalReport)
emitAnalysis(*OptionalReport);
return Success;
} }
static bool hasMultipleUsesOf(Instruction *I, static bool hasMultipleUsesOf(Instruction *I,