[Openmp-commits] [PATCH] D126001: [OpenMP][libomp] Fix fallthrough attribute detection for Intel compilers

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu May 19 11:48:26 PDT 2022


jlpeyton created this revision.
jlpeyton added reviewers: tlwilmar, hbae, AndreyChurbanov.
jlpeyton added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
jlpeyton requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Force the feature off for icc.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126001

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


Index: openmp/tools/archer/ompt-tsan.cpp
===================================================================
--- openmp/tools/archer/ompt-tsan.cpp
+++ 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
Index: openmp/runtime/src/kmp_os.h
===================================================================
--- openmp/runtime/src/kmp_os.h
+++ openmp/runtime/src/kmp_os.h
@@ -339,6 +339,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 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126001.430761.patch
Type: text/x-patch
Size: 1325 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220519/a7334ce8/attachment.bin>


More information about the Openmp-commits mailing list