1 | //===--- Debug.cpp -------- Debug utilities ----------------------- C++ -*-===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file contains debug utilities |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "Shared/Environment.h" |
14 | |
15 | #include "Configuration.h" |
16 | #include "Debug.h" |
17 | #include "DeviceTypes.h" |
18 | #include "Interface.h" |
19 | #include "Mapping.h" |
20 | #include "State.h" |
21 | |
22 | using namespace ompx; |
23 | |
24 | extern "C"{ |
25 | void __assert_assume(bool condition) { __builtin_assume(condition); } |
26 | |
27 | #ifndef OMPTARGET_HAS_LIBC |
28 | [[gnu::weak]] void __assert_fail(const char *expr, const char *file, |
29 | unsigned line, const char *function) { |
30 | __assert_fail_internal(expr, nullptr, file, line, function); |
31 | } |
32 | #endif |
33 | |
34 | void __assert_fail_internal(const char *expr, const char *msg, const char *file, |
35 | unsigned line, const char *function) { |
36 | if (msg) { |
37 | printf("%s:%u: %s: Assertion %s (`%s`) failed.\n", file, line, function, |
38 | msg, expr); |
39 | } else { |
40 | printf("%s:%u: %s: Assertion `%s` failed.\n", file, line, function, expr); |
41 | } |
42 | __builtin_trap(); |
43 | } |
44 | } |
45 |