Skip to content

Commit

Permalink
[profile] Don't publish VMO if there are no counters
Browse files Browse the repository at this point in the history
If there are no counters, there's no need to publish the VMO.

Differential Revision: https://reviews.llvm.org/D102786
  • Loading branch information
petrhosek committed Jun 19, 2021
1 parent e1adf90 commit d85c258
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
Expand Up @@ -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) {
Expand Down

0 comments on commit d85c258

Please sign in to comment.