[compiler-rt] 88d8177 - [InstrProf] Restore InstrProfData.inc to fix Fuchsia builds
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 19 10:11:02 PST 2022
Author: Ellis Hoag
Date: 2022-01-19T10:10:58-08:00
New Revision: 88d81770f1101c8306bd1717755ef4eea0724deb
URL: https://github.com/llvm/llvm-project/commit/88d81770f1101c8306bd1717755ef4eea0724deb
DIFF: https://github.com/llvm/llvm-project/commit/88d81770f1101c8306bd1717755ef4eea0724deb.diff
LOG: [InstrProf] Restore InstrProfData.inc to fix Fuchsia builds
https://reviews.llvm.org/D116179 introduced some changes to
`InstrProfData.inc` which broke some downstream builds. This commit
reverts those changes since they only changes two field names.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D117631
Added:
Modified:
compiler-rt/include/profile/InstrProfData.inc
compiler-rt/lib/profile/InstrProfilingMerge.c
compiler-rt/lib/profile/InstrProfilingWriter.c
llvm/include/llvm/ProfileData/InstrProfData.inc
llvm/lib/ProfileData/InstrProfReader.cpp
Removed:
################################################################################
diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc
index 23018493dbe0..27918ecdc057 100644
--- a/compiler-rt/include/profile/InstrProfData.inc
+++ b/compiler-rt/include/profile/InstrProfData.inc
@@ -128,9 +128,11 @@ INSTR_PROF_VALUE_NODE(PtrToNodeT, llvm::Type::getInt8PtrTy(Ctx), Next, \
INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic())
INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version())
INSTR_PROF_RAW_HEADER(uint64_t, BinaryIdsSize, __llvm_write_binary_ids(NULL))
-INSTR_PROF_RAW_HEADER(uint64_t, NumData, NumData)
+/* FIXME: A more accurate name is NumData */
+INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize)
INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesBeforeCounters, PaddingBytesBeforeCounters)
-INSTR_PROF_RAW_HEADER(uint64_t, NumCounters, NumCounters)
+/* FIXME: A more accurate name is NumCounters */
+INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize)
INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesAfterCounters, PaddingBytesAfterCounters)
INSTR_PROF_RAW_HEADER(uint64_t, NamesSize, NamesSize)
INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta,
@@ -644,6 +646,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
(uint64_t)'p' << 40 | (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | \
(uint64_t)'f' << 16 | (uint64_t)'R' << 8 | (uint64_t)129
+/* FIXME: Please remedy the fixme in the header before bumping the version.
/* Raw profile format version (start from 1). */
#define INSTR_PROF_RAW_VERSION 8
/* Indexed profile format version (start from 1). */
diff --git a/compiler-rt/lib/profile/InstrProfilingMerge.c b/compiler-rt/lib/profile/InstrProfilingMerge.c
index 7fd023046222..3a520f1488a7 100644
--- a/compiler-rt/lib/profile/InstrProfilingMerge.c
+++ b/compiler-rt/lib/profile/InstrProfilingMerge.c
@@ -48,7 +48,7 @@ int __llvm_profile_check_compatibility(const char *ProfileData,
SrcDataStart =
(__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header) +
Header->BinaryIdsSize);
- SrcDataEnd = SrcDataStart + Header->NumData;
+ SrcDataEnd = SrcDataStart + Header->DataSize;
if (ProfileSize < sizeof(__llvm_profile_header))
return 1;
@@ -56,10 +56,10 @@ int __llvm_profile_check_compatibility(const char *ProfileData,
/* Check the header first. */
if (Header->Magic != __llvm_profile_get_magic() ||
Header->Version != __llvm_profile_get_version() ||
- Header->NumData !=
+ Header->DataSize !=
__llvm_profile_get_num_data(__llvm_profile_begin_data(),
__llvm_profile_end_data()) ||
- Header->NumCounters !=
+ Header->CountersSize !=
__llvm_profile_get_num_counters(__llvm_profile_begin_counters(),
__llvm_profile_end_counters()) ||
Header->NamesSize != (uint64_t)(__llvm_profile_end_names() -
@@ -69,8 +69,8 @@ int __llvm_profile_check_compatibility(const char *ProfileData,
if (ProfileSize <
sizeof(__llvm_profile_header) + Header->BinaryIdsSize +
- Header->NumData * sizeof(__llvm_profile_data) + Header->NamesSize +
- Header->NumCounters * __llvm_profile_counter_entry_size())
+ Header->DataSize * sizeof(__llvm_profile_data) + Header->NamesSize +
+ Header->CountersSize * __llvm_profile_counter_entry_size())
return 1;
for (SrcData = SrcDataStart,
@@ -115,10 +115,10 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
SrcDataStart =
(__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header) +
Header->BinaryIdsSize);
- SrcDataEnd = SrcDataStart + Header->NumData;
+ SrcDataEnd = SrcDataStart + Header->DataSize;
SrcCountersStart = (char *)SrcDataEnd;
SrcNameStart = SrcCountersStart +
- Header->NumCounters * __llvm_profile_counter_entry_size();
+ Header->CountersSize * __llvm_profile_counter_entry_size();
SrcValueProfDataStart =
SrcNameStart + Header->NamesSize +
__llvm_profile_get_num_padding_bytes(Header->NamesSize);
diff --git a/compiler-rt/lib/profile/InstrProfilingWriter.c b/compiler-rt/lib/profile/InstrProfilingWriter.c
index 32c673a65e7d..800103d199ab 100644
--- a/compiler-rt/lib/profile/InstrProfilingWriter.c
+++ b/compiler-rt/lib/profile/InstrProfilingWriter.c
@@ -287,9 +287,16 @@ lprofWriteDataImpl(ProfDataWriter *Writer, const __llvm_profile_data *DataBegin,
DataSize, CountersSize, NamesSize, &PaddingBytesBeforeCounters,
&PaddingBytesAfterCounters, &PaddingBytesAfterNames);
+ {
+ // TODO: Unfortunately the header's fields are named DataSize and
+ // CountersSize when they should be named NumData and NumCounters,
+ // respectively.
+ const uint64_t CountersSize = NumCounters;
+ const uint64_t DataSize = NumData;
/* Initialize header structure. */
#define INSTR_PROF_RAW_HEADER(Type, Name, Init) Header.Name = Init;
#include "profile/InstrProfData.inc"
+ }
/* On WIN64, label
diff erences are truncated 32-bit values. Truncate
* CountersDelta to match. */
diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc
index 23018493dbe0..27918ecdc057 100644
--- a/llvm/include/llvm/ProfileData/InstrProfData.inc
+++ b/llvm/include/llvm/ProfileData/InstrProfData.inc
@@ -128,9 +128,11 @@ INSTR_PROF_VALUE_NODE(PtrToNodeT, llvm::Type::getInt8PtrTy(Ctx), Next, \
INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic())
INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version())
INSTR_PROF_RAW_HEADER(uint64_t, BinaryIdsSize, __llvm_write_binary_ids(NULL))
-INSTR_PROF_RAW_HEADER(uint64_t, NumData, NumData)
+/* FIXME: A more accurate name is NumData */
+INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize)
INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesBeforeCounters, PaddingBytesBeforeCounters)
-INSTR_PROF_RAW_HEADER(uint64_t, NumCounters, NumCounters)
+/* FIXME: A more accurate name is NumCounters */
+INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize)
INSTR_PROF_RAW_HEADER(uint64_t, PaddingBytesAfterCounters, PaddingBytesAfterCounters)
INSTR_PROF_RAW_HEADER(uint64_t, NamesSize, NamesSize)
INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta,
@@ -644,6 +646,7 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
(uint64_t)'p' << 40 | (uint64_t)'r' << 32 | (uint64_t)'o' << 24 | \
(uint64_t)'f' << 16 | (uint64_t)'R' << 8 | (uint64_t)129
+/* FIXME: Please remedy the fixme in the header before bumping the version.
/* Raw profile format version (start from 1). */
#define INSTR_PROF_RAW_VERSION 8
/* Indexed profile format version (start from 1). */
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 9ee859bfb762..2544e5bcf647 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -383,9 +383,9 @@ Error RawInstrProfReader<IntPtrT>::readHeader(
CountersDelta = swap(Header.CountersDelta);
NamesDelta = swap(Header.NamesDelta);
- auto NumData = swap(Header.NumData);
+ auto NumData = swap(Header.DataSize);
auto PaddingBytesBeforeCounters = swap(Header.PaddingBytesBeforeCounters);
- auto CountersSize = swap(Header.NumCounters) * getCounterTypeSize();
+ auto CountersSize = swap(Header.CountersSize) * getCounterTypeSize();
auto PaddingBytesAfterCounters = swap(Header.PaddingBytesAfterCounters);
auto NamesSize = swap(Header.NamesSize);
ValueKindLast = swap(Header.ValueKindLast);
More information about the llvm-commits
mailing list