[Openmp-commits] [openmp] ed16143 - [OpenMP][FIX] Ensure __assert_fail is compatible with the host
Johannes Doerfert via Openmp-commits
openmp-commits at lists.llvm.org
Fri Aug 4 11:37:18 PDT 2023
Author: Johannes Doerfert
Date: 2023-08-04T11:36:58-07:00
New Revision: ed161435938378b20c27f62ee17e29a96ca25cac
URL: https://github.com/llvm/llvm-project/commit/ed161435938378b20c27f62ee17e29a96ca25cac
DIFF: https://github.com/llvm/llvm-project/commit/ed161435938378b20c27f62ee17e29a96ca25cac.diff
LOG: [OpenMP][FIX] Ensure __assert_fail is compatible with the host
Fixes: https://github.com/llvm/llvm-project/issues/64360
Added:
Modified:
openmp/libomptarget/DeviceRTL/include/Debug.h
openmp/libomptarget/DeviceRTL/src/Debug.cpp
openmp/libomptarget/test/api/assert.c
Removed:
################################################################################
diff --git a/openmp/libomptarget/DeviceRTL/include/Debug.h b/openmp/libomptarget/DeviceRTL/include/Debug.h
index 54628c03a3cc55..4eb90477532612 100644
--- a/openmp/libomptarget/DeviceRTL/include/Debug.h
+++ b/openmp/libomptarget/DeviceRTL/include/Debug.h
@@ -20,14 +20,17 @@
/// {
extern "C" {
void __assert_assume(bool condition);
-void __assert_fail(const char *expr, const char *msg, const char *file,
- unsigned line, const char *function);
+void __assert_fail(const char *expr, const char *file, unsigned line,
+ const char *function);
+void __assert_fail_internal(const char *expr, const char *msg, const char *file,
+ unsigned line, const char *function);
}
#define ASSERT(expr, msg) \
{ \
if (config::isDebugMode(config::DebugKind::Assertion) && !(expr)) \
- __assert_fail(#expr, msg, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
+ __assert_fail_internal(#expr, msg, __FILE__, __LINE__, \
+ __PRETTY_FUNCTION__); \
else \
__assert_assume(expr); \
}
diff --git a/openmp/libomptarget/DeviceRTL/src/Debug.cpp b/openmp/libomptarget/DeviceRTL/src/Debug.cpp
index 4ed5d742165ec1..dd627fc65d8f64 100644
--- a/openmp/libomptarget/DeviceRTL/src/Debug.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Debug.cpp
@@ -25,8 +25,12 @@ using namespace ompx;
extern "C" {
void __assert_assume(bool condition) { __builtin_assume(condition); }
-void __assert_fail(const char *expr, const char *msg, const char *file,
- unsigned line, const char *function) {
+void __assert_fail(const char *expr, const char *file, unsigned line,
+ const char *function) {
+ __assert_fail_internal(expr, nullptr, file, line, function);
+}
+void __assert_fail_internal(const char *expr, const char *msg, const char *file,
+ unsigned line, const char *function) {
if (msg) {
PRINTF("%s:%u: %s: Assertion %s (`%s') failed.\n", file, line, function,
msg, expr);
diff --git a/openmp/libomptarget/test/api/assert.c b/openmp/libomptarget/test/api/assert.c
index b1288777888ec6..9a9e770f196223 100644
--- a/openmp/libomptarget/test/api/assert.c
+++ b/openmp/libomptarget/test/api/assert.c
@@ -1,4 +1,5 @@
// RUN: %libomptarget-compile-run-and-check-generic
+// RUN: %libomptarget-compileopt-run-and-check-generic
#include <assert.h>
#include <stdio.h>
More information about the Openmp-commits
mailing list