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

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 08:46:20 PDT 2024


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

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.


>From 96b2ec0db3e82b50fba9f4682d570facbd3870ff Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 24 Jul 2024 10:29:01 -0500
Subject: [PATCH] [OpenMP] Do not define '__assert_fail' if we have the GPU
 libc

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.
---
 offload/DeviceRTL/src/Debug.cpp | 3 +++
 offload/test/libc/assert.c      | 4 ----
 2 files changed, 3 insertions(+), 4 deletions(-)

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>



More information about the llvm-commits mailing list