[LoopAccesses] Stash the report from the analysis rather than emitting it
[oota-llvm.git] / include / llvm / Analysis / LoopAccessAnalysis.h
index 471959855aab000a64e18f09752501f8530db9ab..98e9c91f64f917bb197d0a18f330b7b0486602d9 100644 (file)
@@ -16,6 +16,7 @@
 #define LLVM_ANALYSIS_LOOPACCESSANALYSIS_H
 
 #include "llvm/ADT/EquivalenceClasses.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AliasSetTracker.h"
@@ -135,11 +136,11 @@ public:
     SmallVector<unsigned, 2> AliasSetId;
   };
 
-  LoopAccessInfo(Function *F, Loop *L, ScalarEvolution *SE,
-                 const DataLayout *DL, const TargetLibraryInfo *TLI,
-                 AliasAnalysis *AA, DominatorTree *DT) :
-      TheFunction(F), TheLoop(L), SE(SE), DL(DL), TLI(TLI), AA(AA), DT(DT),
-      NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1U) {}
+  LoopAccessInfo(Loop *L, ScalarEvolution *SE, const DataLayout *DL,
+                 const TargetLibraryInfo *TLI, AliasAnalysis *AA,
+                 DominatorTree *DT) :
+      TheLoop(L), SE(SE), DL(DL), TLI(TLI), AA(AA), DT(DT), NumLoads(0),
+      NumStores(0), MaxSafeDepDistBytes(-1U) {}
 
   /// Return true we can analyze the memory accesses in the loop and there are
   /// 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.
   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:
   void emitAnalysis(VectorizationReport &Message);
 
   /// We need to check that all of the pointers in this list are disjoint
   /// at runtime.
   RuntimePointerCheck PtrRtCheck;
-  Function *TheFunction;
   Loop *TheLoop;
   ScalarEvolution *SE;
   const DataLayout *DL;
@@ -184,6 +188,10 @@ private:
   unsigned NumStores;
 
   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);