[PATCH] D29904: [OpenMP] Prevent emission of exception handling code when using OpenMP to offload to NVIDIA devices.

Gheorghe-Teodor Bercea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 31 09:32:27 PDT 2017


gtbercea updated this revision to Diff 93670.
gtbercea added a comment.

run clang-format on test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29904

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/OpenMP/target_parallel_no_exceptions.cpp


Index: test/OpenMP/target_parallel_no_exceptions.cpp
===================================================================
--- /dev/null
+++ test/OpenMP/target_parallel_no_exceptions.cpp
@@ -0,0 +1,17 @@
+/// Make sure no exception messages are inclided in the llvm output.
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHK-EXCEPTION
+
+void test_increment() {
+#pragma omp target
+  {
+    []() { return; }();
+  }
+}
+
+int main() {
+  test_increment();
+  return 0;
+}
+
+//CHK-EXCEPTION-NOT: invoke
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2224,6 +2224,13 @@
         break;
       }
     }
+
+    // Set the flag to prevent the implementation from emitting device exception
+    // handling code for those requiring so.
+    if (Opts.OpenMPIsDevice && T.isNVPTX()) {
+      Opts.Exceptions = 0;
+      Opts.CXXExceptions = 0;
+    }
   }
 
   // Get the OpenMP target triples if any.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29904.93670.patch
Type: text/x-patch
Size: 1376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170331/b1f56ec0/attachment.bin>


More information about the cfe-commits mailing list