[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
Thu Mar 30 11:47:32 PDT 2017


gtbercea updated this revision to Diff 93513.
gtbercea added a comment.
Herald added a subscriber: rengolin.

Clean-up 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,27 @@
+/// Make sure no exception messages are inclided in the llvm output.
+// RUN: %clang -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CHK-EXCEPTION %s
+
+int inc(int a) {
+  return a + 1;
+}
+
+int test_increment() {
+  int a;
+#pragma omp target
+  {
+#pragma omp parallel
+    {
+      a = inc(a);
+    }
+  }
+  return a;
+}
+
+int main() {
+  return test_increment();
+}
+
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLE____START__ openmp-nvptx64-nvidia-cuda
+//CHK-EXCEPTION-NOT: __cxa_begin_catch
+//CHK-EXCEPTION-NOT: terminate.lpad
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLE____END__ openmp-nvptx64-nvidia-cuda
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.93513.patch
Type: text/x-patch
Size: 1412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170330/81c15e08/attachment.bin>


More information about the cfe-commits mailing list