[polly] r306290 - [PPCGCodeGeneration] Add flag to allow polly to fail in GPU kernel fails.

Siddharth Bhat via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 26 07:56:57 PDT 2017


Author: bollu
Date: Mon Jun 26 07:56:56 2017
New Revision: 306290

URL: http://llvm.org/viewvc/llvm-project?rev=306290&view=rev
Log:
[PPCGCodeGeneration] Add flag to allow polly to fail in GPU kernel fails.

- This is useful for debugging GPU code.

Added:
    polly/trunk/test/GPGPU/invalid-kernel-assert-verifymodule.ll
Modified:
    polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp

Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=306290&r1=306289&r2=306290&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Mon Jun 26 07:56:56 2017
@@ -94,6 +94,14 @@ static cl::opt<bool> ManagedMemory("poll
                                    cl::Hidden, cl::init(false), cl::ZeroOrMore,
                                    cl::cat(PollyCategory));
 
+static cl::opt<bool>
+    FailOnVerifyModuleFailure("polly-acc-fail-on-verify-module-failure",
+                              cl::desc("Fail and generate a backtrace if"
+                                       " verifyModule fails on the GPU "
+                                       " kernel module."),
+                              cl::Hidden, cl::init(false), cl::ZeroOrMore,
+                              cl::cat(PollyCategory));
+
 static cl::opt<std::string>
     CudaVersion("polly-acc-cuda-version",
                 cl::desc("The CUDA version to compile for"), cl::Hidden,
@@ -1900,7 +1908,14 @@ std::string GPUNodeBuilder::createKernel
 }
 
 std::string GPUNodeBuilder::finalizeKernelFunction() {
+
   if (verifyModule(*GPUModule)) {
+    DEBUG(dbgs() << "verifyModule failed on module:\n";
+          GPUModule->print(dbgs(), nullptr); dbgs() << "\n";);
+
+    if (FailOnVerifyModuleFailure)
+      llvm_unreachable("VerifyModule failed.");
+
     BuildSuccessful = false;
     return "";
   }

Added: polly/trunk/test/GPGPU/invalid-kernel-assert-verifymodule.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/invalid-kernel-assert-verifymodule.ll?rev=306290&view=auto
==============================================================================
--- polly/trunk/test/GPGPU/invalid-kernel-assert-verifymodule.ll (added)
+++ polly/trunk/test/GPGPU/invalid-kernel-assert-verifymodule.ll Mon Jun 26 07:56:56 2017
@@ -0,0 +1,47 @@
+; RUN: opt %loadPolly -polly-codegen-ppcg  -polly-acc-fail-on-verify-module-failure \
+; RUN: -disable-output < %s
+
+; Make sure that if -polly-acc-fail-on-verify-module-failure is on, we actually
+; fail on an illegal module.
+
+; REQUIRES: pollyacc
+; XFAIL: *
+;
+;    void foo(long A[1024], long B[1024]) {
+;      for (long i = 0; i < 1024; i++)
+;        A[i] += (B[i] + (long)&B[i]);
+;    }
+
+
+; RUN: opt %loadPolly -polly-codegen-ppcg -S < %s 
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @foo(i64* %A, i64* %B) {
+bb:
+  br label %bb1
+
+bb1:                                              ; preds = %bb10, %bb
+  %i.0 = phi i64 [ 0, %bb ], [ %tmp11, %bb10 ]
+  %exitcond = icmp ne i64 %i.0, 1024
+  br i1 %exitcond, label %bb2, label %bb12
+
+bb2:                                              ; preds = %bb1
+  %tmp = getelementptr inbounds i64, i64* %B, i64 %i.0
+  %tmp3 = load i64, i64* %tmp, align 8
+  %tmp4 = getelementptr inbounds i64, i64* %B, i64 %i.0
+  %tmp5 = ptrtoint i64* %tmp4 to i64
+  %tmp6 = add nsw i64 %tmp3, %tmp5
+  %tmp7 = getelementptr inbounds i64, i64* %A, i64 %i.0
+  %tmp8 = load i64, i64* %tmp7, align 8
+  %tmp9 = add nsw i64 %tmp8, %tmp6
+  store i64 %tmp9, i64* %tmp7, align 8
+  br label %bb10
+
+bb10:                                             ; preds = %bb2
+  %tmp11 = add nuw nsw i64 %i.0, 1
+  br label %bb1
+
+bb12:                                             ; preds = %bb1
+  ret void
+}




More information about the llvm-commits mailing list