D9302.partial2: cleanup of ittnotify checks, that eliminats redundant notifications in case of nested regions.

llvm-svn: 236631
diff --git a/openmp/runtime/src/kmp_sched.cpp b/openmp/runtime/src/kmp_sched.cpp
index 375cacb..46b5987 100644
--- a/openmp/runtime/src/kmp_sched.cpp
+++ b/openmp/runtime/src/kmp_sched.cpp
@@ -92,6 +92,7 @@
     register kmp_uint32  nth;
     register UT          trip_count;
     register kmp_team_t *team;
+    register kmp_info_t *th = __kmp_threads[ gtid ];
 
 #if OMPT_SUPPORT && OMPT_TRACE
     ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
@@ -157,13 +158,13 @@
     if ( schedtype > kmp_ord_upper ) {
         // we are in DISTRIBUTE construct
         schedtype += kmp_sch_static - kmp_distribute_static;      // AC: convert to usual schedule type
-        tid  = __kmp_threads[ gtid ]->th.th_team->t.t_master_tid;
-        team = __kmp_threads[ gtid ]->th.th_team->t.t_parent;
+        tid  = th->th.th_team->t.t_master_tid;
+        team = th->th.th_team->t.t_parent;
     } else
     #endif
     {
         tid  = __kmp_tid_from_gtid( global_tid );
-        team = __kmp_threads[ gtid ]->th.th_team;
+        team = th->th.th_team;
     }
 
     /* determine if "for" loop is an active worksharing construct */
@@ -318,7 +319,12 @@
 
 #if USE_ITT_BUILD
     // Report loop metadata
-    if ( KMP_MASTER_TID(tid) && __itt_metadata_add_ptr && __kmp_forkjoin_frames_mode == 3 ) {
+    if ( KMP_MASTER_TID(tid) && __itt_metadata_add_ptr && __kmp_forkjoin_frames_mode == 3 &&
+#if OMP_40_ENABLED
+        th->th.th_teams_microtask == NULL &&
+#endif
+        team->t.t_active_level == 1 )
+    {
         kmp_uint64 cur_chunk = chunk;
         // Calculate chunk in case it was not specified; it is specified for kmp_sch_static_chunked
         if ( schedtype == kmp_sch_static ) {