[polly] r209572 - Store all RejectReasons that occurred in a log.

Andreas Simbuerger simbuerg at fim.uni-passau.de
Sat May 24 02:25:02 PDT 2014


Author: simbuerg
Date: Sat May 24 04:25:01 2014
New Revision: 209572

URL: http://llvm.org/viewvc/llvm-project?rev=209572&view=rev
Log:
Store all RejectReasons that occurred in a log.

This stores all RejectReasons created for one region
in a RejectLog inside the DetectionContext. For now
this only keeps track of the last error.

A separate patch will enable the tracking of all errors.
This patch itself does no harm (yet).

Modified:
    polly/trunk/include/polly/ScopDetection.h
    polly/trunk/include/polly/ScopDetectionDiagnostic.h
    polly/trunk/lib/Analysis/ScopDetection.cpp

Modified: polly/trunk/include/polly/ScopDetection.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetection.h?rev=209572&r1=209571&r2=209572&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetection.h (original)
+++ polly/trunk/include/polly/ScopDetection.h Sat May 24 04:25:01 2014
@@ -50,6 +50,8 @@
 #include "llvm/Pass.h"
 #include "llvm/Analysis/AliasSetTracker.h"
 
+#include "polly/ScopDetectionDiagnostic.h"
+
 #include <set>
 #include <map>
 
@@ -100,12 +102,13 @@ class ScopDetection : public FunctionPas
     Region &CurRegion;   // The region to check.
     AliasSetTracker AST; // The AliasSetTracker to hold the alias information.
     bool Verifying;      // If we are in the verification phase?
+    RejectLog Log;
 
     // Map a base pointer to all access functions accessing it.
     BaseToAFs NonAffineAccesses, AffineAccesses;
 
     DetectionContext(Region &R, AliasAnalysis &AA, bool Verify)
-        : CurRegion(R), AST(AA), Verifying(Verify) {}
+        : CurRegion(R), AST(AA), Verifying(Verify), Log(&R) {}
   };
 
   // Remember the valid regions
@@ -115,6 +118,9 @@ class ScopDetection : public FunctionPas
   // Invalid regions and the reason they fail.
   std::map<const Region *, std::string> InvalidRegions;
 
+  // Remember a list of errors for every region.
+  mutable std::map<const Region *, RejectLog> RejectLogs;
+
   // Remember the invalid functions producted by backends;
   typedef std::set<const Function *> FunctionSet;
   FunctionSet InvalidFunctions;
@@ -289,6 +295,22 @@ public:
   const_iterator end() const { return ValidRegions.end(); }
   //@}
 
+  /// @name Reject log iterators
+  ///
+  /// These iterators iterate over the logs of all rejected regions of this
+  //  function.
+  //@{
+  typedef std::map<const Region *, RejectLog>::iterator reject_iterator;
+  typedef std::map<const Region *, RejectLog>::const_iterator
+  const_reject_iterator;
+
+  reject_iterator reject_begin() { return RejectLogs.begin(); }
+  reject_iterator reject_end() { return RejectLogs.end(); }
+
+  const_reject_iterator reject_begin() const { return RejectLogs.begin(); }
+  const_reject_iterator reject_end() const { return RejectLogs.end(); }
+  //@}
+
   /// @brief Mark the function as invalid so we will not extract any scop from
   ///        the function.
   ///

Modified: polly/trunk/include/polly/ScopDetectionDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetectionDiagnostic.h?rev=209572&r1=209571&r2=209572&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetectionDiagnostic.h (original)
+++ polly/trunk/include/polly/ScopDetectionDiagnostic.h Sat May 24 04:25:01 2014
@@ -59,6 +59,25 @@ public:
   virtual std::string getMessage() const = 0;
 };
 
+typedef std::shared_ptr<RejectReason> RejectReasonPtr;
+
+/// @brief Stores all errors that ocurred during the detection.
+class RejectLog {
+  Region *R;
+  llvm::SmallVector<RejectReasonPtr, 1> ErrorReports;
+
+public:
+  explicit RejectLog(Region *R) : R(R) {};
+
+  typedef llvm::SmallVector<RejectReasonPtr, 1>::iterator iterator;
+
+  iterator begin() { return ErrorReports.begin(); }
+  iterator end() { return ErrorReports.end(); }
+
+  const Region *region() const { return R; }
+  void report(RejectReasonPtr Reject) { ErrorReports.push_back(Reject); }
+};
+
 //===----------------------------------------------------------------------===//
 /// @brief Base class for CFG related reject reasons.
 ///

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=209572&r1=209571&r2=209572&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Sat May 24 04:25:01 2014
@@ -182,11 +182,15 @@ inline bool ScopDetection::invalid(Detec
                                    Args &&... Arguments) const {
 
   if (!Context.Verifying) {
-    RR RejectReason = RR(Arguments...);
-    if (PollyTrackFailures)
-      LastFailure = RejectReason.getMessage();
+    RejectLog &Log = Context.Log;
+    std::shared_ptr<RR> RejectReason = std::make_shared<RR>(Arguments...);
 
-    DEBUG(dbgs() << RejectReason.getMessage());
+    if (PollyTrackFailures) {
+      Log.report(RejectReason);
+      LastFailure = RejectReason->getMessage();
+    }
+
+    DEBUG(dbgs() << RejectReason->getMessage());
     DEBUG(dbgs() << "\n");
   } else {
     assert(!Assert && "Verification of detected scop failed");
@@ -668,7 +672,16 @@ bool ScopDetection::isValidExit(Detectio
 
 bool ScopDetection::isValidRegion(Region &R) const {
   DetectionContext Context(R, *AA, false /*verifying*/);
-  return isValidRegion(Context);
+
+  bool RegionIsValid = isValidRegion(Context);
+  if (PollyTrackFailures && !RegionIsValid) {
+    // std::map::insert does not replace.
+    std::pair<reject_iterator, bool> InsertedValue =
+        RejectLogs.insert(std::make_pair(&R, Context.Log));
+    assert(InsertedValue.second && "Two logs generated for the same Region.");
+  }
+
+  return RegionIsValid;
 }
 
 bool ScopDetection::isValidRegion(DetectionContext &Context) const {
@@ -821,6 +834,8 @@ void ScopDetection::print(raw_ostream &O
 void ScopDetection::releaseMemory() {
   ValidRegions.clear();
   InvalidRegions.clear();
+  RejectLogs.clear();
+
   // Do not clear the invalid function set.
 }
 





More information about the llvm-commits mailing list