[polly] r261320 - Codegen: Print error in Polly code verification and allow to disable verfication.

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 19 03:07:12 PST 2016


Author: grosser
Date: Fri Feb 19 05:07:12 2016
New Revision: 261320

URL: http://llvm.org/viewvc/llvm-project?rev=261320&view=rev
Log:
Codegen: Print error in Polly code verification and allow to disable verfication.

We now always print the reason why the code did not pass the LLVM verifier and
we also allow to disable verfication with -polly-codegen-verify=false. Before
this change the first assertion had generally no information why or what might
have gone wrong and it was also impossible to -view-cfg without recompile. This
change makes debugging bugs that result in incorrect IR a lot easier.

Modified:
    polly/trunk/lib/CodeGen/CodeGeneration.cpp

Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=261320&r1=261319&r2=261320&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Fri Feb 19 05:07:12 2016
@@ -24,6 +24,7 @@
 #include "polly/CodeGen/Utils.h"
 #include "polly/DependenceInfo.h"
 #include "polly/LinkAllPasses.h"
+#include "polly/Options.h"
 #include "polly/ScopInfo.h"
 #include "polly/Support/ScopHelper.h"
 #include "llvm/Analysis/AliasAnalysis.h"
@@ -40,6 +41,11 @@ using namespace llvm;
 
 #define DEBUG_TYPE "polly-codegen"
 
+static cl::opt<bool> Verify("polly-codegen-verify",
+                            cl::desc("Verify the function generated by Polly"),
+                            cl::Hidden, cl::init(true), cl::ZeroOrMore,
+                            cl::cat(PollyCategory));
+
 namespace {
 class CodeGeneration : public ScopPass {
 public:
@@ -74,9 +80,9 @@ public:
     return RTC;
   }
 
-  bool verifyGeneratedFunction(Scop &S, Function &F) {
-    if (!verifyFunction(F))
-      return false;
+  void verifyGeneratedFunction(Scop &S, Function &F) {
+    if (!verifyFunction(F, &errs()) || !Verify)
+      return;
 
     DEBUG({
       errs() << "== ISL Codegen created an invalid function ==\n\n== The "
@@ -86,11 +92,10 @@ public:
       AI->printScop(errs(), S);
       errs() << "\n== The invalid function ==\n";
       F.print(errs());
-      errs() << "\n== The errors ==\n";
-      verifyFunction(F, &errs());
     });
 
-    return true;
+    llvm_unreachable("Polly generated function could not be verified. Add "
+                     "-polly-codegen-verify=false to disable this assertion.");
   }
 
   // CodeGeneration adds a lot of BBs without updating the RegionInfo
@@ -174,8 +179,7 @@ public:
       fixRegionInfo(EnteringBB->getParent(), R->getParent());
     }
 
-    assert(!verifyGeneratedFunction(S, *EnteringBB->getParent()) &&
-           "Verification of generated function failed");
+    verifyGeneratedFunction(S, *EnteringBB->getParent());
 
     // Mark the function such that we run additional cleanup passes on this
     // function (e.g. mem2reg to rediscover phi nodes).




More information about the llvm-commits mailing list