[polly] r231593 - Add end user report message for unprofitable regions [NFC]

Johannes Doerfert doerfert at cs.uni-saarland.de
Sun Mar 8 08:11:50 PDT 2015


Author: jdoerfert
Date: Sun Mar  8 10:11:50 2015
New Revision: 231593

URL: http://llvm.org/viewvc/llvm-project?rev=231593&view=rev
Log:
Add end user report message for unprofitable regions [NFC]

Modified:
    polly/trunk/include/polly/ScopDetectionDiagnostic.h
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp
    polly/trunk/test/ScopDetectionDiagnostics/ReportUnprofitable.ll

Modified: polly/trunk/include/polly/ScopDetectionDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetectionDiagnostic.h?rev=231593&r1=231592&r2=231593&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetectionDiagnostic.h (original)
+++ polly/trunk/include/polly/ScopDetectionDiagnostic.h Sun Mar  8 10:11:50 2015
@@ -835,8 +835,10 @@ public:
 /// @brief Report regions that seem not profitable to be optimized.
 class ReportUnprofitable : public ReportOther {
   //===--------------------------------------------------------------------===//
+  Region *R;
+
 public:
-  ReportUnprofitable();
+  ReportUnprofitable(Region *R);
 
   /// @name LLVM-RTTI interface
   //@{
@@ -846,6 +848,8 @@ public:
   /// @name RejectReason interface
   //@{
   virtual std::string getMessage() const override;
+  virtual std::string getEndUserMessage() const override;
+  virtual const DebugLoc &getDebugLoc() const override;
   //@}
 };
 

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=231593&r1=231592&r2=231593&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Sun Mar  8 10:11:50 2015
@@ -761,12 +761,15 @@ static unsigned eraseAllChildren(ScopDet
 }
 
 void ScopDetection::findScops(Region &R) {
-  if (!DetectRegionsWithoutLoops && regionWithoutLoops(R, LI))
-    return;
-
   DetectionContext Context(R, *AA, NonAffineSubRegionMap[&R],
                            false /*verifying*/);
-  bool RegionIsValid = isValidRegion(Context);
+
+  bool RegionIsValid = false;
+  if (!DetectRegionsWithoutLoops && regionWithoutLoops(R, LI))
+    invalid<ReportUnprofitable>(Context, /*Assert=*/true, &R);
+  else
+    RegionIsValid = isValidRegion(Context);
+
   bool HasErrors = !RegionIsValid || Context.Log.size() > 0;
 
   if (PollyTrackFailures && HasErrors)
@@ -905,7 +908,7 @@ bool ScopDetection::isValidRegion(Detect
   // We can probably not do a lot on scops that only write or only read
   // data.
   if (!DetectUnprofitable && (!Context.hasStores || !Context.hasLoads))
-    invalid<ReportUnprofitable>(Context, /*Assert=*/true);
+    invalid<ReportUnprofitable>(Context, /*Assert=*/true, &CurRegion);
 
   DEBUG(dbgs() << "OK\n");
   return true;

Modified: polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp?rev=231593&r1=231592&r2=231593&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp Sun Mar  8 10:11:50 2015
@@ -594,12 +594,29 @@ bool ReportEntry::classof(const RejectRe
 
 //===----------------------------------------------------------------------===//
 // ReportUnprofitable.
-ReportUnprofitable::ReportUnprofitable() : ReportOther(rrkUnprofitable) {}
+ReportUnprofitable::ReportUnprofitable(Region *R)
+    : ReportOther(rrkUnprofitable), R(R) {}
 
 std::string ReportUnprofitable::getMessage() const {
   return "Region can not profitably be optimized!";
 }
 
+std::string ReportUnprofitable::getEndUserMessage() const {
+  return "The regions does not seem to be amendable to profitable polyhedral "
+         "optimization";
+}
+
+const DebugLoc &ReportUnprofitable::getDebugLoc() const {
+  for (const BasicBlock *BB : R->blocks())
+    for (const Instruction &Inst : *BB) {
+      const DebugLoc &DL = Inst.getDebugLoc();
+      if (!DL.isUnknown())
+        return DL;
+    }
+
+  return R->getEntry()->getTerminator()->getDebugLoc();
+}
+
 bool ReportUnprofitable::classof(const RejectReason *RR) {
   return RR->getKind() == rrkUnprofitable;
 }

Modified: polly/trunk/test/ScopDetectionDiagnostics/ReportUnprofitable.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopDetectionDiagnostics/ReportUnprofitable.ll?rev=231593&r1=231592&r2=231593&view=diff
==============================================================================
--- polly/trunk/test/ScopDetectionDiagnostics/ReportUnprofitable.ll (original)
+++ polly/trunk/test/ScopDetectionDiagnostics/ReportUnprofitable.ll Sun Mar  8 10:11:50 2015
@@ -13,9 +13,11 @@ target triple = "x86_64-unknown-linux-gn
 ; }
 
 ; CHECK: remark: /tmp/test.c:2:3: The following errors keep this region from being a Scop.
+; CHECK: remark: /tmp/test.c:2:3: The regions does not seem to be amendable to profitable polyhedral optimization
 ; CHECK: remark: /tmp/test.c:3:10: Invalid Scop candidate ends here.
 
 ; CHECK: remark: /tmp/test.c:7:3: The following errors keep this region from being a Scop.
+; CHECK: remark: /tmp/test.c:7:3: The regions does not seem to be amendable to profitable polyhedral optimization
 ; CHECK: remark: /tmp/test.c:8:10: Invalid Scop candidate ends here.
 
 





More information about the llvm-commits mailing list