[Openmp-commits] [PATCH] D69492: [libomptarget] Always call malloc, free via SafeMalloc, SafeFree wrapper

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sun Oct 27 18:01:28 PDT 2019


JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, ABataev, grokos.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

[libomptarget] Always call malloc, free via SafeMalloc, SafeFree wrapper

NFC for release, adds some verbosity to debug printing. Motivation is to provide
one place where local modifications can be made to the behaviour of all heap
allocation or deallocation while debugging.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69492

Files:
  openmp/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu


Index: openmp/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu
+++ openmp/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu
@@ -180,13 +180,14 @@
         } else {
           DSPRINT(DSFLAG, "Cleaning up -failed reuse - %016llx\n",
                   (unsigned long long)SlotP->Next);
-          free(ExistingSlot);
+          SafeFree(ExistingSlot, "Failed reuse");
         }
       }
 
       if (!NewSlot) {
-        NewSlot = (__kmpc_data_sharing_slot *)malloc(
-            sizeof(__kmpc_data_sharing_slot) + NewSize);
+        NewSlot = (__kmpc_data_sharing_slot *)SafeMalloc(
+            sizeof(__kmpc_data_sharing_slot) + NewSize,
+            "Warp master slot allocation");
         DSPRINT(DSFLAG, "New slot allocated %016llx (data size=%016llx)\n",
                 (unsigned long long)NewSlot, NewSize);
       }
@@ -205,7 +206,7 @@
       if (SlotP->Next) {
         DSPRINT(DSFLAG, "Cleaning up - old not required - %016llx\n",
                 (unsigned long long)SlotP->Next);
-        free(SlotP->Next);
+        SafeFree(SlotP->Next, "Old slot not required");
         SlotP->Next = 0;
       }
 
@@ -243,7 +244,7 @@
                                         : DataSharingState.SlotPtr[WID];
 
       if (S->Next) {
-        free(S->Next);
+        SafeFree(S->Next, "Sharing environment end");
         S->Next = 0;
       }
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69492.226602.patch
Type: text/x-patch
Size: 1483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20191028/0d20354e/attachment.bin>


More information about the Openmp-commits mailing list