[OpenMP][Offloading] Only get trip count if team construct

Reviewed By: grokos

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

GitOrigin-RevId: 2a30c03c62070d12ce6729441c2c58360dcc1024
diff --git a/libomptarget/src/omptarget.cpp b/libomptarget/src/omptarget.cpp
index 5ec0609..06370ac 100644
--- a/libomptarget/src/omptarget.cpp
+++ b/libomptarget/src/omptarget.cpp
@@ -1441,9 +1441,6 @@
     }
   }
 
-  // Get loop trip count
-  uint64_t LoopTripCount = getLoopTripCount(DeviceId);
-
   // Launch device execution.
   void *TgtEntryPtr = TargetTable->EntriesBegin[TM->Index].addr;
   DP("Launching target execution %s with pointer " DPxMOD " (index=%d).\n",
@@ -1455,7 +1452,7 @@
     if (IsTeamConstruct)
       Ret = Device.runTeamRegion(TgtEntryPtr, &TgtArgs[0], &TgtOffsets[0],
                                  TgtArgs.size(), TeamNum, ThreadLimit,
-                                 LoopTripCount, AsyncInfo);
+                                 getLoopTripCount(DeviceId), AsyncInfo);
     else
       Ret = Device.runRegion(TgtEntryPtr, &TgtArgs[0], &TgtOffsets[0],
                              TgtArgs.size(), AsyncInfo);