[libomptarget] Allow calls to omp_target_memcpy with 0 size.
authorGeorge Rokos <georgios.rokos@intel.com>
Wed, 6 Jan 2021 00:03:53 +0000 (16:03 -0800)
committerGeorge Rokos <georgios.rokos@intel.com>
Wed, 6 Jan 2021 00:03:53 +0000 (16:03 -0800)
Differential Revision: https://reviews.llvm.org/D94095

openmp/libomptarget/src/api.cpp

index 58f7cec..2d37610 100644 (file)
@@ -137,6 +137,11 @@ EXTERN int omp_target_memcpy(void *dst, void *src, size_t length,
       DPxPTR(src), dst_offset, src_offset, length);
 
   if (!dst || !src || length <= 0) {
+    if (length == 0) {
+      DP("Call to omp_target_memcpy with zero length, nothing to do\n");
+      return OFFLOAD_SUCCESS;
+    }
+
     REPORT("Call to omp_target_memcpy with invalid arguments\n");
     return OFFLOAD_FAIL;
   }