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 #pragma omp begin declare target device_type(nohost) 25 26 extern "C" { 27 void __assert_assume(bool condition) { __builtin_assume(condition); } 28 29 #ifndef OMPTARGET_HAS_LIBC 30 [[gnu::weak]] void __assert_fail(const char *expr, const char *file, 31 unsigned line, const char *function) { 32 __assert_fail_internal(expr, nullptr, file, line, function); 33 } 34 #endif 35 36 void __assert_fail_internal(const char *expr, const char *msg, const char *file, 37 unsigned line, const char *function) { 38 if (msg) { 39 printf("%s:%u: %s: Assertion %s (`%s`) failed.\n", file, line, function, 40 msg, expr); 41 } else { 42 printf("%s:%u: %s: Assertion `%s` failed.\n", file, line, function, expr); 43 } 44 __builtin_trap(); 45 } 46 } 47 48 #pragma omp end declare target 49