diff options
| author | Joachim Protze <protze@itc.rwth-aachen.de> | 2019-02-04 15:59:42 +0000 | 
|---|---|---|
| committer | Joachim Protze <protze@itc.rwth-aachen.de> | 2019-02-04 15:59:42 +0000 | 
| commit | 0c599c388dbb4c5852019c90eeb642839dc52ebe (patch) | |
| tree | b056e74c7ec23d0d000428afccd05061013eda80 | |
| parent | 6e5350a3679f820d5263d2e3793de5c262ef7b5b (diff) | |
| download | bcm5719-llvm-0c599c388dbb4c5852019c90eeb642839dc52ebe.tar.gz bcm5719-llvm-0c599c388dbb4c5852019c90eeb642839dc52ebe.zip  | |
[OMPT] Make sure that OMPT is enabled when accessing internals of the runtime
The three switch fallthrough generate a warning with -Wimplicit-fallthrough.
Two are documented as fallthrough, one is not, but I think the intention is to also fallthrough in kmp_tasking.cpp.
Not sure whether kmp.h is the best place to define the macro.
Reviewers: jlpeyton, AndreyChurbanov, Hahnfeld
Reviewed By: jlpeyton
Tags: #openmp
Differential Revision: https://reviews.llvm.org/D56397
llvm-svn: 353052
| -rw-r--r-- | openmp/runtime/src/kmp_dispatch.cpp | 1 | ||||
| -rw-r--r-- | openmp/runtime/src/kmp_os.h | 14 | ||||
| -rw-r--r-- | openmp/runtime/src/kmp_runtime.cpp | 1 | ||||
| -rw-r--r-- | openmp/runtime/src/kmp_tasking.cpp | 1 | 
4 files changed, 17 insertions, 0 deletions
diff --git a/openmp/runtime/src/kmp_dispatch.cpp b/openmp/runtime/src/kmp_dispatch.cpp index f3e52184f34..872b96de139 100644 --- a/openmp/runtime/src/kmp_dispatch.cpp +++ b/openmp/runtime/src/kmp_dispatch.cpp @@ -348,6 +348,7 @@ void __kmp_dispatch_init_algorithm(ident_t *loc, int gtid,        /* too few iterations: fall-through to kmp_sch_static_balanced */      } // if      /* FALL-THROUGH to static balanced */ +    KMP_FALLTHROUGH();    } // case  #endif    case kmp_sch_static_balanced: { diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h index 6c701705823..f229cccbb50 100644 --- a/openmp/runtime/src/kmp_os.h +++ b/openmp/runtime/src/kmp_os.h @@ -296,6 +296,20 @@ extern "C" {  #define KMP_CACHE_PREFETCH(ADDR) /* nothing */ +// Define attribute that indicates that the fall through from the previous  +// case label is intentional and should not be diagnosed by a compiler +//   Code from libcxx/include/__config +// 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]] +#elif __has_cpp_attribute(clang::fallthrough) +#  define KMP_FALLTHROUGH() [[clang::fallthrough]] +#elif __has_attribute(fallthough) || _GNUC_VER >= 700 +#  define KMP_FALLTHROUGH() __attribute__((__fallthrough__)) +#else +#  define KMP_FALLTHROUGH() ((void)0) +#endif +  // Define attribute that indicates a function does not return  #if __cplusplus >= 201103L  #define KMP_NORETURN [[noreturn]] diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp index 724f231ccf5..e7b50ff0b8a 100644 --- a/openmp/runtime/src/kmp_runtime.cpp +++ b/openmp/runtime/src/kmp_runtime.cpp @@ -6421,6 +6421,7 @@ void __kmp_register_library_startup(void) {          // library. Assume the other library is alive.          // WARN( ... ); // TODO: Issue a warning.          file_name = "unknown library"; +        KMP_FALLTHROUGH();        // Attention! Falling to the next case. That's intentional.        case 1: { // Neighbor is alive.          // Check it is allowed. diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp index 7848d242bcf..9e8b22ae4c7 100644 --- a/openmp/runtime/src/kmp_tasking.cpp +++ b/openmp/runtime/src/kmp_tasking.cpp @@ -4205,6 +4205,7 @@ void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t *task, int if_val,    case 0: // no schedule clause specified, we can choose the default      // let's try to schedule (team_size*10) tasks      grainsize = thread->th.th_team_nproc * 10; +    KMP_FALLTHROUGH();    case 2: // num_tasks provided      if (grainsize > tc) {        num_tasks = tc; // too big num_tasks requested, adjust values  | 

