[Openmp-commits] [PATCH] D106301: [OpenMP] Disable trap before unreachable for OpenMP device jobs

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Jul 19 12:07:00 PDT 2021


jdoerfert created this revision.
jdoerfert added reviewers: jhuber6, tianshilei1992, JonChesterfield.
Herald added subscribers: guansong, bollu, yaxunl.
jdoerfert requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

We want to fold more aggressively on the GPU and we therefore disable
the generation of `llvm.trap` before an unreachable  by default.

Depends on D106299 <https://reviews.llvm.org/D106299>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106301

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/openmp-offload-gpu.c


Index: clang/test/Driver/openmp-offload-gpu.c
===================================================================
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -214,11 +214,13 @@
 // DEBUG_DIRECTIVES-NOT: warning: debug
 // NO_DEBUG-NOT: warning: debug
 // NO_DEBUG: "-fopenmp-is-device"
+// NO_DEBUG-SAME: "-trap-before-unreachable=false"
 // NO_DEBUG-NOT: "-debug-info-kind=
 // NO_DEBUG: ptxas
 // DEBUG_DIRECTIVES: "-triple" "nvptx64-nvidia-cuda"
 // DEBUG_DIRECTIVES-SAME: "-debug-info-kind=line-directives-only"
 // DEBUG_DIRECTIVES-SAME: "-fopenmp-is-device"
+// DEBUG-DIRECTIVES-SAME: "-trap-before-unreachable=false"
 // DEBUG_DIRECTIVES: ptxas
 // DEBUG_DIRECTIVES: "-lineinfo"
 // NO_DEBUG-NOT: "-g"
@@ -251,6 +253,7 @@
 // HAS_DEBUG-SAME: "-debug-info-kind={{limited|line-tables-only}}"
 // HAS_DEBUG-SAME: "-dwarf-version=2"
 // HAS_DEBUG-SAME: "-fopenmp-is-device"
+// HAS_DEBUG-SAME: "-trap-before-unreachable=false"
 // HAS_DEBUG: ptxas
 // HAS_DEBUG-SAME: "-g"
 // HAS_DEBUG-SAME: "--dont-merge-basicblocks"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6621,6 +6621,10 @@
       CmdArgs.push_back("-fopenmp-host-ir-file-path");
       CmdArgs.push_back(Args.MakeArgString(OpenMPDeviceInput->getFilename()));
     }
+
+    // We disable `llvm.trap` generation in OpenMP offload code generation.
+    CmdArgs.push_back("-mllvm");
+    CmdArgs.push_back("-trap-before-unreachable=never");
   }
 
   if (Triple.isAMDGPU()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106301.359876.patch
Type: text/x-patch
Size: 1637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210719/ef192489/attachment.bin>


More information about the Openmp-commits mailing list