Skip to content

Commit a6f33ad

Browse files
committed
[NFC][Profile] Rename Counters/DataSize to NumCounters/Data
Fixes some FIXMEs. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D158466
1 parent 7c9fe73 commit a6f33ad

File tree

5 files changed

+14
-23
lines changed

5 files changed

+14
-23
lines changed

compiler-rt/include/profile/InstrProfData.inc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,9 @@ INSTR_PROF_VALUE_NODE(PtrToNodeT, llvm::Type::getInt8PtrTy(Ctx), Next, \
128128
INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic())
129129
INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version())
130130
INSTR_PROF_RAW_HEADER(uint64_t, BinaryIdsSize, __llvm_write_binary_ids(NULL))
131-
/* FIXME: A more accurate name is NumData */
132-
INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize)
131+
INSTR_PROF_RAW_HEADER(uint64_t, NumData, NumData)
133132
INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesBeforeCounters, PaddingBytesBeforeCounters)
134-
/* FIXME: A more accurate name is NumCounters */
135-
INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize)
133+
INSTR_PROF_RAW_HEADER(uint64_t, NumCounters, NumCounters)
136134
INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesAfterCounters, PaddingBytesAfterCounters)
137135
INSTR_PROF_RAW_HEADER(uint64_t, NamesSize, NamesSize)
138136
INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta,

compiler-rt/lib/profile/InstrProfilingMerge.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ int __llvm_profile_check_compatibility(const char *ProfileData,
5252
SrcDataStart =
5353
(__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header) +
5454
Header->BinaryIdsSize);
55-
SrcDataEnd = SrcDataStart + Header->DataSize;
55+
SrcDataEnd = SrcDataStart + Header->NumData;
5656

5757
if (ProfileSize < sizeof(__llvm_profile_header))
5858
return 1;
5959

6060
/* Check the header first. */
6161
if (Header->Magic != __llvm_profile_get_magic() ||
6262
Header->Version != __llvm_profile_get_version() ||
63-
Header->DataSize !=
63+
Header->NumData !=
6464
__llvm_profile_get_num_data(__llvm_profile_begin_data(),
6565
__llvm_profile_end_data()) ||
66-
Header->CountersSize !=
66+
Header->NumCounters !=
6767
__llvm_profile_get_num_counters(__llvm_profile_begin_counters(),
6868
__llvm_profile_end_counters()) ||
6969
Header->NamesSize != (uint64_t)(__llvm_profile_end_names() -
@@ -73,8 +73,8 @@ int __llvm_profile_check_compatibility(const char *ProfileData,
7373

7474
if (ProfileSize <
7575
sizeof(__llvm_profile_header) + Header->BinaryIdsSize +
76-
Header->DataSize * sizeof(__llvm_profile_data) + Header->NamesSize +
77-
Header->CountersSize * __llvm_profile_counter_entry_size())
76+
Header->NumData * sizeof(__llvm_profile_data) + Header->NamesSize +
77+
Header->NumCounters * __llvm_profile_counter_entry_size())
7878
return 1;
7979

8080
for (SrcData = SrcDataStart,
@@ -119,10 +119,10 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
119119
SrcDataStart =
120120
(__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header) +
121121
Header->BinaryIdsSize);
122-
SrcDataEnd = SrcDataStart + Header->DataSize;
122+
SrcDataEnd = SrcDataStart + Header->NumData;
123123
SrcCountersStart = (char *)SrcDataEnd;
124124
SrcCountersEnd = SrcCountersStart +
125-
Header->CountersSize * __llvm_profile_counter_entry_size();
125+
Header->NumCounters * __llvm_profile_counter_entry_size();
126126
SrcNameStart = SrcCountersEnd;
127127
SrcValueProfDataStart =
128128
SrcNameStart + Header->NamesSize +
@@ -132,7 +132,7 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
132132

133133
// Merge counters when there is no data section and debug info correlation is
134134
// enabled.
135-
if (Header->DataSize == 0) {
135+
if (Header->NumData == 0) {
136136
if (!(__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE)) {
137137
PROF_ERR("%s\n", "Missing profile data section.");
138138
return 1;

compiler-rt/lib/profile/InstrProfilingWriter.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,6 @@ lprofWriteDataImpl(ProfDataWriter *Writer, const __llvm_profile_data *DataBegin,
286286
&PaddingBytesAfterNames);
287287

288288
{
289-
// TODO: Unfortunately the header's fields are named DataSize and
290-
// CountersSize when they should be named NumData and NumCounters,
291-
// respectively.
292-
const uint64_t CountersSize = NumCounters;
293-
const uint64_t DataSize = NumData;
294289
/* Initialize header structure. */
295290
#define INSTR_PROF_RAW_HEADER(Type, Name, Init) Header.Name = Init;
296291
#include "profile/InstrProfData.inc"

llvm/include/llvm/ProfileData/InstrProfData.inc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,9 @@ INSTR_PROF_VALUE_NODE(PtrToNodeT, llvm::Type::getInt8PtrTy(Ctx), Next, \
128128
INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic())
129129
INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version())
130130
INSTR_PROF_RAW_HEADER(uint64_t, BinaryIdsSize, __llvm_write_binary_ids(NULL))
131-
/* FIXME: A more accurate name is NumData */
132-
INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize)
131+
INSTR_PROF_RAW_HEADER(uint64_t, NumData, NumData)
133132
INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesBeforeCounters, PaddingBytesBeforeCounters)
134-
/* FIXME: A more accurate name is NumCounters */
135-
INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize)
133+
INSTR_PROF_RAW_HEADER(uint64_t, NumCounters, NumCounters)
136134
INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesAfterCounters, PaddingBytesAfterCounters)
137135
INSTR_PROF_RAW_HEADER(uint64_t, NamesSize, NamesSize)
138136
INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta,

llvm/lib/ProfileData/InstrProfReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,9 @@ Error RawInstrProfReader<IntPtrT>::readHeader(
550550

551551
CountersDelta = swap(Header.CountersDelta);
552552
NamesDelta = swap(Header.NamesDelta);
553-
auto NumData = swap(Header.DataSize);
553+
auto NumData = swap(Header.NumData);
554554
auto PaddingBytesBeforeCounters = swap(Header.PaddingBytesBeforeCounters);
555-
auto CountersSize = swap(Header.CountersSize) * getCounterTypeSize();
555+
auto CountersSize = swap(Header.NumCounters) * getCounterTypeSize();
556556
auto PaddingBytesAfterCounters = swap(Header.PaddingBytesAfterCounters);
557557
auto NamesSize = swap(Header.NamesSize);
558558
ValueKindLast = swap(Header.ValueKindLast);

0 commit comments

Comments
 (0)