[compiler-rt] d85c258 - [profile] Don't publish VMO if there are no counters

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 19 14:48:17 PDT 2021


Author: Petr Hosek
Date: 2021-06-19T14:47:57-07:00
New Revision: d85c258fd1e7459cc8085b5f364e356f50b490a4

URL: https://github.com/llvm/llvm-project/commit/d85c258fd1e7459cc8085b5f364e356f50b490a4
DIFF: https://github.com/llvm/llvm-project/commit/d85c258fd1e7459cc8085b5f364e356f50b490a4.diff

LOG: [profile] Don't publish VMO if there are no counters

If there are no counters, there's no need to publish the VMO.

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

Added: 
    

Modified: 
    compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c b/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
index d8b7fa21d2573..0e62861d1b923 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
@@ -126,13 +126,20 @@ void __llvm_profile_initialize(void) {
 
   const __llvm_profile_data *DataBegin = __llvm_profile_begin_data();
   const __llvm_profile_data *DataEnd = __llvm_profile_end_data();
+  const uint64_t *CountersBegin = __llvm_profile_begin_counters();
+  const uint64_t *CountersEnd = __llvm_profile_end_counters();
   const uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);
   const uint64_t CountersOffset =
       sizeof(__llvm_profile_header) + (DataSize * sizeof(__llvm_profile_data));
+  uint64_t CountersSize = CountersEnd - CountersBegin;
+
+  /* Don't publish a VMO if there are no counters. */
+  if (!CounterSize)
+    return;
 
   zx_status_t Status;
 
-  /* Create VMO to hold the profile data. */
+  /* Create a VMO to hold the profile data. */
   zx_handle_t Vmo = ZX_HANDLE_INVALID;
   Status = _zx_vmo_create(0, ZX_VMO_RESIZABLE, &Vmo);
   if (Status != ZX_OK) {


        


More information about the llvm-commits mailing list