Show the reason a region is not a SCoP in the DOT graphs.

llvm-svn: 141458
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 8fc6335..ff77b3b 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -77,6 +77,11 @@
 
 #define INVALID(NAME, MESSAGE) \
   do { \
+    std::string Buf; \
+    raw_string_ostream fmt(Buf); \
+    fmt << MESSAGE; \
+    fmt.flush(); \
+    LastFailure = Buf; \
     DEBUG(dbgs() << MESSAGE); \
     DEBUG(dbgs() << "\n"); \
     STATSCOP(NAME); \
@@ -102,6 +107,14 @@
   return ValidRegions.count(&R);
 }
 
+std::string ScopDetection::regionIsInvalidBecause(const Region *R) const {
+  if (!InvalidRegions.count(R))
+    return "";
+
+  return InvalidRegions.find(R)->second;
+}
+
+
 bool ScopDetection::isValidAffineFunction(const SCEV *S, Region &RefRegion,
                                           Value **BasePtr) const {
   assert(S && "S must not be null!");
@@ -438,6 +451,8 @@
     return;
   }
 
+  InvalidRegions[&R] = LastFailure;
+
   for (Region::iterator I = R.begin(), E = R.end(); I != E; ++I)
     findScops(**I);
 
@@ -583,6 +598,7 @@
 
 void ScopDetection::releaseMemory() {
   ValidRegions.clear();
+  InvalidRegions.clear();
   // Do not clear the invalid function set.
 }