diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp --- a/openmp/libomptarget/src/omptarget.cpp +++ b/openmp/libomptarget/src/omptarget.cpp @@ -581,11 +581,11 @@ // Adjust for proper alignment if this is a combined entry (for structs). // Look at the next argument - if that is MEMBER_OF this one, then this one // is a combined entry. - int64_t Padding = 0; const int NextI = I + 1; if (getParentIndex(ArgTypes[I]) < 0 && NextI < ArgNum && getParentIndex(ArgTypes[NextI]) == I) { - Padding = (int64_t)HstPtrBegin % Alignment; + int64_t Padding = std::min((int64_t)HstPtrBegin - (int64_t)HstPtrBase, + (int64_t)HstPtrBegin % Alignment); if (Padding) { DP("Using a padding of %" PRId64 " bytes for begin address " DPxMOD "\n", @@ -939,7 +939,8 @@ const int NextI = I + 1; if (getParentIndex(ArgTypes[I]) < 0 && NextI < ArgNum && getParentIndex(ArgTypes[NextI]) == I) { - int64_t Padding = (int64_t)HstPtrBegin % Alignment; + int64_t Padding = std::min((int64_t)HstPtrBegin - (int64_t)ArgBases[I], + (int64_t)HstPtrBegin % Alignment); if (Padding) { DP("Using a Padding of %" PRId64 " bytes for begin address " DPxMOD "\n",