[Openmp-commits] [openmp] 28c8da2 - [OpenMP][libomp] Fix fallthrough attribute detection for Intel compilers

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Tue Jul 19 11:04:37 PDT 2022


Author: Jonathan Peyton
Date: 2022-07-19T13:04:25-05:00
New Revision: 28c8da29654dd4a3da675dfcafbb70f357a7e1bd

URL: https://github.com/llvm/llvm-project/commit/28c8da29654dd4a3da675dfcafbb70f357a7e1bd
DIFF: https://github.com/llvm/llvm-project/commit/28c8da29654dd4a3da675dfcafbb70f357a7e1bd.diff

LOG: [OpenMP][libomp] Fix fallthrough attribute detection for Intel compilers

icc does not properly detect lack of fallthrough attribute since it
defines __GNU__ > 7 and also icc's __has_cpp_attribute/__has_attribute
feature detectors do not properly detect the lack of fallthrough attribute.

Differential Revision: https://reviews.llvm.org/D126001

Added: 
    

Modified: 
    openmp/runtime/src/kmp_os.h
    openmp/tools/archer/ompt-tsan.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h
index 5db97bb421396..02efaa1b2613f 100644
--- a/openmp/runtime/src/kmp_os.h
+++ b/openmp/runtime/src/kmp_os.h
@@ -345,6 +345,9 @@ extern "C" {
 // Use a function like macro to imply that it must be followed by a semicolon
 #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
 #define KMP_FALLTHROUGH() [[fallthrough]]
+// icc cannot properly tell this attribute is absent so force off
+#elif KMP_COMPILER_ICC
+#define KMP_FALLTHROUGH() ((void)0)
 #elif __has_cpp_attribute(clang::fallthrough)
 #define KMP_FALLTHROUGH() [[clang::fallthrough]]
 #elif __has_attribute(fallthrough) || __GNUC__ >= 7

diff  --git a/openmp/tools/archer/ompt-tsan.cpp b/openmp/tools/archer/ompt-tsan.cpp
index 6bd117552b9af..a3cc0a2ec30d4 100644
--- a/openmp/tools/archer/ompt-tsan.cpp
+++ b/openmp/tools/archer/ompt-tsan.cpp
@@ -42,6 +42,9 @@
 // Use a function like macro to imply that it must be followed by a semicolon
 #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
 #define KMP_FALLTHROUGH() [[fallthrough]]
+// icc cannot properly tell this attribute is absent so force off
+#elif defined(__INTEL_COMPILER)
+#define KMP_FALLTHROUGH() ((void)0)
 #elif __has_cpp_attribute(clang::fallthrough)
 #define KMP_FALLTHROUGH() [[clang::fallthrough]]
 #elif __has_attribute(fallthrough) || __GNUC__ >= 7


        


More information about the Openmp-commits mailing list