diff options
| author | Siddharth Bhat <siddu.druid@gmail.com> | 2017-06-26 14:56:56 +0000 |
|---|---|---|
| committer | Siddharth Bhat <siddu.druid@gmail.com> | 2017-06-26 14:56:56 +0000 |
| commit | 65d7f72f2c1f58a14dc23033895c1bc65458f400 (patch) | |
| tree | f71f0097cff2ac9e44604ae79e2c1ed4071b9f7a | |
| parent | 15748d239eba9080dc99ff82e3201898b2a7294c (diff) | |
| download | bcm5719-llvm-65d7f72f2c1f58a14dc23033895c1bc65458f400.tar.gz bcm5719-llvm-65d7f72f2c1f58a14dc23033895c1bc65458f400.zip | |
[PPCGCodeGeneration] Add flag to allow polly to fail in GPU kernel fails.
- This is useful for debugging GPU code.
llvm-svn: 306290
| -rw-r--r-- | polly/lib/CodeGen/PPCGCodeGeneration.cpp | 15 | ||||
| -rw-r--r-- | polly/test/GPGPU/invalid-kernel-assert-verifymodule.ll | 47 |
2 files changed, 62 insertions, 0 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index bc07eecc628..199d741f8c3 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -94,6 +94,14 @@ static cl::opt<bool> ManagedMemory("polly-acc-codegen-managed-memory", 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::createKernelASM() { } 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 ""; } diff --git a/polly/test/GPGPU/invalid-kernel-assert-verifymodule.ll b/polly/test/GPGPU/invalid-kernel-assert-verifymodule.ll new file mode 100644 index 00000000000..0abbb8eec53 --- /dev/null +++ b/polly/test/GPGPU/invalid-kernel-assert-verifymodule.ll @@ -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 +} |

