[OMPT] Fix parallel_data in implicit barrier-end

This is required to be NULL for implicit barriers at the end of a
parallel region. Noticed in review of D43191.

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

llvm-svn: 325922
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index c05e973..f902f04 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -7164,10 +7164,10 @@
 
   __kmp_join_barrier(gtid); /* wait for everyone */
 #if OMPT_SUPPORT
-  int ds_tid = this_thr->th.th_info.ds.ds_tid;
-  if (this_thr->th.ompt_thread_info.state == omp_state_wait_barrier_implicit) {
-    ompt_data_t *tId = OMPT_CUR_TASK_DATA(this_thr);
-    ompt_data_t *pId = OMPT_CUR_TEAM_DATA(this_thr);
+  if (ompt_enabled.enabled &&
+      this_thr->th.ompt_thread_info.state == omp_state_wait_barrier_implicit) {
+    int ds_tid = this_thr->th.th_info.ds.ds_tid;
+    ompt_data_t *task_data = OMPT_CUR_TASK_DATA(this_thr);
     this_thr->th.ompt_thread_info.state = omp_state_overhead;
 #if OMPT_OPTIONAL
     void *codeptr = NULL;
@@ -7178,19 +7178,17 @@
 
     if (ompt_enabled.ompt_callback_sync_region_wait) {
       ompt_callbacks.ompt_callback(ompt_callback_sync_region_wait)(
-          ompt_sync_region_barrier, ompt_scope_end, pId, tId, codeptr);
+          ompt_sync_region_barrier, ompt_scope_end, NULL, task_data, codeptr);
     }
     if (ompt_enabled.ompt_callback_sync_region) {
       ompt_callbacks.ompt_callback(ompt_callback_sync_region)(
-          ompt_sync_region_barrier, ompt_scope_end, pId, tId, codeptr);
+          ompt_sync_region_barrier, ompt_scope_end, NULL, task_data, codeptr);
     }
 #endif
     if (!KMP_MASTER_TID(ds_tid) && ompt_enabled.ompt_callback_implicit_task) {
       ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
-          ompt_scope_end, NULL, tId, 0, ds_tid);
+          ompt_scope_end, NULL, task_data, 0, ds_tid);
     }
-    // return to idle state
-    this_thr->th.ompt_thread_info.state = omp_state_overhead;
   }
 #endif