[Openmp-commits] [openmp] 6baeeb9 - [libomptarget] Fixed MSVC build fail caused by __attribute__((used)).
Vyacheslav Zakharin via Openmp-commits
openmp-commits at lists.llvm.org
Wed Feb 24 10:00:31 PST 2021
Author: Vyacheslav Zakharin
Date: 2021-02-24T09:59:39-08:00
New Revision: 6baeeb9efa8ec6d64d66fdceac7240b5b08fb40b
URL: https://github.com/llvm/llvm-project/commit/6baeeb9efa8ec6d64d66fdceac7240b5b08fb40b
DIFF: https://github.com/llvm/llvm-project/commit/6baeeb9efa8ec6d64d66fdceac7240b5b08fb40b.diff
LOG: [libomptarget] Fixed MSVC build fail caused by __attribute__((used)).
Differential Revision: https://reviews.llvm.org/D97348
Added:
Modified:
openmp/libomptarget/include/Debug.h
Removed:
################################################################################
diff --git a/openmp/libomptarget/include/Debug.h b/openmp/libomptarget/include/Debug.h
index 958518431966..371019228241 100644
--- a/openmp/libomptarget/include/Debug.h
+++ b/openmp/libomptarget/include/Debug.h
@@ -53,8 +53,17 @@ enum OpenMPInfoType : uint32_t {
OMP_INFOTYPE_ALL = 0xffffffff,
};
+#define GCC_VERSION \
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+
+#if !defined(__clang__) && defined(__GNUC__) && GCC_VERSION < 70100
+#define USED __attribute__((used))
+#else
+#define USED
+#endif
+
// Add __attribute__((used)) to work around a bug in gcc 5/6.
-static inline uint32_t __attribute__((used)) getInfoLevel() {
+USED static inline uint32_t getInfoLevel() {
static uint32_t InfoLevel = 0;
static std::once_flag Flag{};
std::call_once(Flag, []() {
@@ -66,7 +75,7 @@ static inline uint32_t __attribute__((used)) getInfoLevel() {
}
// Add __attribute__((used)) to work around a bug in gcc 5/6.
-static inline uint32_t __attribute__((used)) getDebugLevel() {
+USED static inline uint32_t getDebugLevel() {
static uint32_t DebugLevel = 0;
static std::once_flag Flag{};
std::call_once(Flag, []() {
@@ -77,6 +86,9 @@ static inline uint32_t __attribute__((used)) getDebugLevel() {
return DebugLevel;
}
+#undef USED
+#undef GCC_VERSION
+
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
More information about the Openmp-commits
mailing list