[llvm] [OpenMP] Do not define '__assert_fail' if we have the GPU libc (PR #100409)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 08:47:06 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-offload

Author: Joseph Huber (jhuber6)

<details>
<summary>Changes</summary>

Summary:
The C library is intended to provide `__assert_fail`, so in the cases
that we have both we should defer to that. This means that if you build
the C library for GPUs you'll get the RPC based asser, and if not you'll
get the trap based one.


---
Full diff: https://github.com/llvm/llvm-project/pull/100409.diff


2 Files Affected:

- (modified) offload/DeviceRTL/src/Debug.cpp (+3) 
- (modified) offload/test/libc/assert.c (-4) 


``````````diff
diff --git a/offload/DeviceRTL/src/Debug.cpp b/offload/DeviceRTL/src/Debug.cpp
index 4e16591cc6c51..5a2c84c7ee38a 100644
--- a/offload/DeviceRTL/src/Debug.cpp
+++ b/offload/DeviceRTL/src/Debug.cpp
@@ -26,10 +26,13 @@ using namespace ompx;
 extern "C" {
 void __assert_assume(bool condition) { __builtin_assume(condition); }
 
+#ifndef OMPTARGET_HAS_LIBC
 [[gnu::weak]] void __assert_fail(const char *expr, const char *file,
                                  unsigned line, const char *function) {
   __assert_fail_internal(expr, nullptr, file, line, function);
 }
+#endif
+
 void __assert_fail_internal(const char *expr, const char *msg, const char *file,
                             unsigned line, const char *function) {
   if (msg) {
diff --git a/offload/test/libc/assert.c b/offload/test/libc/assert.c
index 0501e36329024..bf155b6f463bf 100644
--- a/offload/test/libc/assert.c
+++ b/offload/test/libc/assert.c
@@ -2,10 +2,6 @@
 // RUN:   %fcheck-generic --check-prefix=CHECK
 
 // REQUIRES: libc
-
-// AMDGPU and NVPTX without LTO uses the implementation in OpenMP currently.
-// UNSUPPORTED: nvptx64-nvidia-cuda
-// UNSUPPORTED: amdgcn-amd-amdhsa
 // REQUIRES: gpu
 
 #include <assert.h>

``````````

</details>


https://github.com/llvm/llvm-project/pull/100409


More information about the llvm-commits mailing list