[Openmp-commits] [PATCH] D112842: [OpenMP] Use the assertion formatting from assert.h
Joseph Huber via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Oct 29 12:51:16 PDT 2021
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.
This patch changes the `assert_assume` function used for internal
assumptions in the device runtime to use a more standard formatting for
the assumption message.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D112842
Files:
openmp/libomptarget/DeviceRTL/include/Debug.h
openmp/libomptarget/DeviceRTL/src/Debug.cpp
Index: openmp/libomptarget/DeviceRTL/src/Debug.cpp
===================================================================
--- openmp/libomptarget/DeviceRTL/src/Debug.cpp
+++ openmp/libomptarget/DeviceRTL/src/Debug.cpp
@@ -21,13 +21,15 @@
#pragma omp declare target
extern "C" {
-void __assert_assume(bool cond, const char *exp, const char *file, int line) {
- if (!cond && config::isDebugMode(config::DebugKind::Assertion)) {
- PRINTF("ASSERTION failed: %s at %s, line %d\n", exp, file, line);
+void __assert_assume(bool condition, const char *assertion, const char *file,
+ int line, const char *function) {
+ if (config::isDebugMode(config::DebugKind::Assertion) && !condition) {
+ PRINTF("%s:%u: %s: Assertion `%s' failed.\n", file, line, function,
+ assertion);
__builtin_trap();
}
- __builtin_assume(cond);
+ __builtin_assume(condition);
}
void __assert_fail(const char *assertion, const char *file, unsigned line,
Index: openmp/libomptarget/DeviceRTL/include/Debug.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/Debug.h
+++ openmp/libomptarget/DeviceRTL/include/Debug.h
@@ -16,12 +16,14 @@
///
/// {
extern "C" {
-void __assert_assume(bool cond, const char *exp, const char *file, int line);
+void __assert_assume(bool cond, const char *assertion, const char *file,
+ int line, const char *function);
void __assert_fail(const char *assertion, const char *file, unsigned line,
const char *function);
}
-#define ASSERT(e) __assert_assume(e, #e, __FILE__, __LINE__)
+#define ASSERT(e) \
+ __assert_assume(e, #e, __FILE__, __LINE__, __PRETTY_FUNCTION__)
///}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112842.383469.patch
Type: text/x-patch
Size: 1795 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20211029/4dc54773/attachment.bin>
More information about the Openmp-commits
mailing list