[polly] r230767 - Add verifier to the IslCodeGeneration

Johannes Doerfert doerfert at cs.uni-saarland.de
Fri Feb 27 09:37:05 PST 2015


Author: jdoerfert
Date: Fri Feb 27 11:37:05 2015
New Revision: 230767

URL: http://llvm.org/viewvc/llvm-project?rev=230767&view=rev
Log:
Add verifier to the IslCodeGeneration

  After a function was created we will verify it for Debug builds. If
  errors are found and debug-type equals "polly-codegen-isl" the SCoP,
  the isl AST, the function as well as the errors will be printed.


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

Modified: polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslCodeGeneration.cpp?rev=230767&r1=230766&r2=230767&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/IslCodeGeneration.cpp Fri Feb 27 11:37:05 2015
@@ -41,6 +41,7 @@
 #include "llvm/IR/Module.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/IR/Verifier.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 
@@ -920,6 +921,25 @@ public:
     return RTC;
   }
 
+  bool verifyGeneratedFunction(Scop &S, Function &F) {
+    if (!verifyFunction(F))
+      return false;
+
+    DEBUG({
+      errs() << "== ISL Codegen created an invalid function ==\n\n== The "
+                "SCoP ==\n";
+      S.print(errs());
+      errs() << "\n== The isl AST ==\n";
+      AI->printScop(errs());
+      errs() << "\n== The invalid function ==\n";
+      F.print(errs());
+      errs() << "\n== The errors ==\n";
+      verifyFunction(F, &errs());
+    });
+
+    return true;
+  }
+
   bool runOnScop(Scop &S) {
     AI = &getAnalysis<IslAstInfo>();
 
@@ -951,6 +971,9 @@ public:
     Builder.SetInsertPoint(StartBlock->begin());
 
     NodeBuilder.create(AstRoot);
+
+    assert(!verifyGeneratedFunction(S, *EnteringBB->getParent()) &&
+           "Verification of generated function failed");
     return true;
   }
 





More information about the llvm-commits mailing list