[llvm] r282759 - Revert "[LAA, LV] Port to new streaming interface for opt remarks. Update LV"

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 29 13:17:38 PDT 2016


Author: anemet
Date: Thu Sep 29 15:17:37 2016
New Revision: 282759

URL: http://llvm.org/viewvc/llvm-project?rev=282759&view=rev
Log:
Revert "[LAA, LV] Port to new streaming interface for opt remarks.  Update LV"

This reverts commit r282758.

There are some clang failures I haven't seen.

Modified:
    llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h
    llvm/trunk/include/llvm/IR/DiagnosticInfo.h
    llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h?rev=282759&r1=282758&r2=282759&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h Thu Sep 29 15:17:37 2016
@@ -22,7 +22,6 @@
 #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"
@@ -596,7 +595,7 @@ public:
 
   /// \brief The diagnostics report generated for the analysis.  E.g. why we
   /// couldn't analyze the loop.
-  const OptimizationRemarkAnalysis *getReport() const { return Report.get(); }
+  const Optional<LoopAccessReport> &getReport() const { return Report; }
 
   /// \brief the Memory Dependence Checker which can determine the
   /// loop-independent and loop-carried dependences between memory accesses.
@@ -647,8 +646,7 @@ private:
   /// 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);
+  void recordAnalysis(LoopAccessReport &Message);
 
   /// \brief Collect memory access with loop invariant strides.
   ///
@@ -682,7 +680,7 @@ private:
 
   /// \brief The diagnostics report generated for the analysis.  E.g. why we
   /// couldn't analyze the loop.
-  std::unique_ptr<OptimizationRemarkAnalysis> Report;
+  Optional<LoopAccessReport> Report;
 
   /// \brief If an access has a symbolic strides, this maps the pointer value to
   /// the stride symbol.

Modified: llvm/trunk/include/llvm/IR/DiagnosticInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DiagnosticInfo.h?rev=282759&r1=282758&r2=282759&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DiagnosticInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DiagnosticInfo.h Thu Sep 29 15:17:37 2016
@@ -409,24 +409,6 @@ public:
         PassName(PassName), RemarkName(RemarkName), CodeRegion(CodeRegion),
         IsVerbose(false) {}
 
-  /// \brief This is ctor variant allows a pass to build an optimization remark
-  /// from an existing remark.
-  ///
-  /// This is useful when a transformation pass (e.g LV) wants to emit a remark
-  /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
-  /// remark.  The string \p Prepend will be emitted before the original
-  /// message.
-  DiagnosticInfoOptimizationBase(const char *PassName, StringRef Prepend,
-                                 const DiagnosticInfoOptimizationBase &Orig)
-      : DiagnosticInfoWithDebugLocBase((DiagnosticKind)Orig.getKind(),
-                                       Orig.getSeverity(), Orig.getFunction(),
-                                       Orig.getDebugLoc()),
-        PassName(PassName), RemarkName(Orig.RemarkName),
-        CodeRegion(Orig.getCodeRegion()) {
-    *this << Prepend;
-    std::copy(Orig.Args.begin(), Orig.Args.end(), std::back_inserter(Args));
-  }
-
   /// Legacy interface.
   /// \p PassName is the name of the pass emitting this diagnostic.
   /// \p Fn is the function where the diagnostic is being emitted. \p DLoc is
@@ -596,17 +578,6 @@ public:
   OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,
                              const DebugLoc &DLoc, Value *CodeRegion);
 
-  /// \brief This is ctor variant allows a pass to build an optimization remark
-  /// from an existing remark.
-  ///
-  /// This is useful when a transformation pass (e.g LV) wants to emit a remark
-  /// (\p Orig) generated by one of its analyses (e.g. LAA) as its own analysis
-  /// remark.  The string \p Prepend will be emitted before the original
-  /// message.
-  OptimizationRemarkAnalysis(const char *PassName, StringRef Prepend,
-                             const OptimizationRemarkAnalysis &Orig)
-      : DiagnosticInfoOptimizationBase(PassName, Prepend, Orig) {}
-
   /// \brief Same as above but \p Inst is used to derive code region and debug
   /// location.
   OptimizationRemarkAnalysis(const char *PassName, StringRef RemarkName,

Modified: llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp?rev=282759&r1=282758&r2=282759&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp Thu Sep 29 15:17:37 2016
@@ -1482,23 +1482,23 @@ bool LoopAccessInfo::canAnalyzeLoop() {
   // We can only analyze innermost loops.
   if (!TheLoop->empty()) {
     DEBUG(dbgs() << "LAA: loop is not the innermost loop\n");
-    recordAnalysis("NotInnerMostLoop") << "loop is not the innermost loop";
+    recordAnalysis(LoopAccessReport() << "loop is not the innermost loop");
     return false;
   }
 
   // We must have a single backedge.
   if (TheLoop->getNumBackEdges() != 1) {
     DEBUG(dbgs() << "LAA: loop control flow is not understood by analyzer\n");
-    recordAnalysis("CFGNotUnderstood")
-        << "loop control flow is not understood by analyzer";
+    recordAnalysis(LoopAccessReport()
+                   << "loop control flow is not understood by analyzer");
     return false;
   }
 
   // We must have a single exiting block.
   if (!TheLoop->getExitingBlock()) {
     DEBUG(dbgs() << "LAA: loop control flow is not understood by analyzer\n");
-    recordAnalysis("CFGNotUnderstood")
-        << "loop control flow is not understood by analyzer";
+    recordAnalysis(LoopAccessReport()
+                   << "loop control flow is not understood by analyzer");
     return false;
   }
 
@@ -1507,16 +1507,16 @@ bool LoopAccessInfo::canAnalyzeLoop() {
   // instructions in the loop are executed the same number of times.
   if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch()) {
     DEBUG(dbgs() << "LAA: loop control flow is not understood by analyzer\n");
-    recordAnalysis("CFGNotUnderstood")
-        << "loop control flow is not understood by analyzer";
+    recordAnalysis(LoopAccessReport()
+                   << "loop control flow is not understood by analyzer");
     return false;
   }
 
   // ScalarEvolution needs to be able to find the exit count.
   const SCEV *ExitCount = PSE->getBackedgeTakenCount();
   if (ExitCount == PSE->getSE()->getCouldNotCompute()) {
-    recordAnalysis("CantComputeNumberOfIterations")
-        << "could not determine number of loop iterations";
+    recordAnalysis(LoopAccessReport()
+                   << "could not determine number of loop iterations");
     DEBUG(dbgs() << "LAA: SCEV could not compute the loop exit count.\n");
     return false;
   }
@@ -1565,8 +1565,8 @@ void LoopAccessInfo::analyzeLoop(AliasAn
 
         auto *Ld = dyn_cast<LoadInst>(&I);
         if (!Ld || (!Ld->isSimple() && !IsAnnotatedParallel)) {
-          recordAnalysis("NonSimpleLoad", Ld)
-              << "read with atomic ordering or volatile read";
+          recordAnalysis(LoopAccessReport(Ld)
+                         << "read with atomic ordering or volatile read");
           DEBUG(dbgs() << "LAA: Found a non-simple load.\n");
           CanVecMem = false;
           return;
@@ -1583,14 +1583,14 @@ void LoopAccessInfo::analyzeLoop(AliasAn
       if (I.mayWriteToMemory()) {
         auto *St = dyn_cast<StoreInst>(&I);
         if (!St) {
-          recordAnalysis("CantVectorizeInstruction", St)
-              << "instruction cannot be vectorized";
+          recordAnalysis(LoopAccessReport(St)
+                         << "instruction cannot be vectorized");
           CanVecMem = false;
           return;
         }
         if (!St->isSimple() && !IsAnnotatedParallel) {
-          recordAnalysis("NonSimpleStore", St)
-              << "write with atomic ordering or volatile write";
+          recordAnalysis(LoopAccessReport(St)
+                         << "write with atomic ordering or volatile write");
           DEBUG(dbgs() << "LAA: Found a non-simple store.\n");
           CanVecMem = false;
           return;
@@ -1698,7 +1698,7 @@ void LoopAccessInfo::analyzeLoop(AliasAn
   bool CanDoRTIfNeeded = Accesses.canCheckPtrAtRT(*PtrRtChecking, PSE->getSE(),
                                                   TheLoop, SymbolicStrides);
   if (!CanDoRTIfNeeded) {
-    recordAnalysis("CantIdentifyArrayBounds") << "cannot identify array bounds";
+    recordAnalysis(LoopAccessReport() << "cannot identify array bounds");
     DEBUG(dbgs() << "LAA: We can't vectorize because we can't find "
                  << "the array bounds.\n");
     CanVecMem = false;
@@ -1729,8 +1729,8 @@ void LoopAccessInfo::analyzeLoop(AliasAn
 
       // Check that we found the bounds for the pointer.
       if (!CanDoRTIfNeeded) {
-        recordAnalysis("CantCheckMemDepsAtRunTime")
-            << "cannot check memory dependencies at runtime";
+        recordAnalysis(LoopAccessReport()
+                       << "cannot check memory dependencies at runtime");
         DEBUG(dbgs() << "LAA: Can't vectorize with memory checks\n");
         CanVecMem = false;
         return;
@@ -1745,11 +1745,12 @@ void LoopAccessInfo::analyzeLoop(AliasAn
                  << (PtrRtChecking->Need ? "" : " don't")
                  << " need runtime memory checks.\n");
   else {
-    recordAnalysis("UnsafeMemDep")
+    recordAnalysis(
+        LoopAccessReport()
         << "unsafe dependent memory operations in loop. Use "
            "#pragma loop distribute(enable) to allow loop distribution "
            "to attempt to isolate the offending operations into a separate "
-           "loop";
+           "loop");
     DEBUG(dbgs() << "LAA: unsafe dependent memory operations in loop\n");
   }
 }
@@ -1763,24 +1764,9 @@ bool LoopAccessInfo::blockNeedsPredicati
   return !DT->dominates(BB, Latch);
 }
 
-OptimizationRemarkAnalysis &LoopAccessInfo::recordAnalysis(StringRef RemarkName,
-                                                           Instruction *I) {
+void LoopAccessInfo::recordAnalysis(LoopAccessReport &Message) {
   assert(!Report && "Multiple reports generated");
-
-  Value *CodeRegion = TheLoop->getHeader();
-  DebugLoc DL = TheLoop->getStartLoc();
-
-  if (I) {
-    CodeRegion = I->getParent();
-    // If there is no debug location attached to the instruction, revert back to
-    // using the loop's.
-    if (I->getDebugLoc())
-      DL = I->getDebugLoc();
-  }
-
-  Report = make_unique<OptimizationRemarkAnalysis>(DEBUG_TYPE, RemarkName, DL,
-                                                   CodeRegion);
-  return *Report;
+  Report = Message;
 }
 
 bool LoopAccessInfo::isUniform(Value *V) const {
@@ -1988,7 +1974,7 @@ void LoopAccessInfo::print(raw_ostream &
   }
 
   if (Report)
-    OS.indent(Depth) << "Report: " << Report->getMsg() << "\n";
+    OS.indent(Depth) << "Report: " << Report->str() << "\n";
 
   if (auto *Dependences = DepChecker->getDependences()) {
     OS.indent(Depth) << "Dependences:\n";

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=282759&r1=282758&r2=282759&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Thu Sep 29 15:17:37 2016
@@ -5505,12 +5505,9 @@ void LoopVectorizationLegality::collectL
 bool LoopVectorizationLegality::canVectorizeMemory() {
   LAI = &(*GetLAA)(*TheLoop);
   InterleaveInfo.setLAI(LAI);
-  const OptimizationRemarkAnalysis *LAR = LAI->getReport();
-  if (LAR) {
-    OptimizationRemarkAnalysis VR(Hints->vectorizeAnalysisPassName(),
-                                  "loop not vectorized: ", *LAR);
-    ORE->emit(VR);
-  }
+  auto &OptionalReport = LAI->getReport();
+  if (OptionalReport)
+    emitAnalysis(VectorizationReport(*OptionalReport));
   if (!LAI->canVectorizeMemory())
     return false;
 




More information about the llvm-commits mailing list