Revert "[profile] Simplify value profile writing"
This reverts commit r268840, as it breaks Thumb2 self-hosting. There is something
unstable in the profiling for Thumb2 that needs to be sorted out before we continue
implementing these changes to the profiler. See PR27667.
llvm-svn: 268864
diff --git a/compiler-rt/lib/profile/InstrProfilingWriter.c b/compiler-rt/lib/profile/InstrProfilingWriter.c
index 8b3136d..18b3f34 100644
--- a/compiler-rt/lib/profile/InstrProfilingWriter.c
+++ b/compiler-rt/lib/profile/InstrProfilingWriter.c
@@ -91,29 +91,42 @@
return 0;
}
+COMPILER_RT_VISIBILITY int lprofWriteData(WriterCallback Writer,
+ void *WriterCtx,
+ ValueProfData **ValueDataArray,
+ const uint64_t ValueDataSize) {
+ /* Match logic in __llvm_profile_write_buffer(). */
+ 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 char *NamesBegin = __llvm_profile_begin_names();
+ const char *NamesEnd = __llvm_profile_end_names();
+ return lprofWriteDataImpl(Writer, WriterCtx, DataBegin, DataEnd,
+ CountersBegin, CountersEnd, ValueDataArray,
+ ValueDataSize, NamesBegin, NamesEnd);
+}
+
#define VP_BUFFER_SIZE 8 * 1024
static int writeValueProfData(WriterCallback Writer, void *WriterCtx,
- VPGatherHookType VPDataGatherer,
- const __llvm_profile_data *DataBegin,
- const __llvm_profile_data *DataEnd) {
+ ValueProfData **ValueDataBegin,
+ uint64_t NumVData) {
ProfBufferIO *BufferIO;
- uint32_t BufferSz;
- const __llvm_profile_data *DI = 0;
+ uint32_t I = 0, BufferSz;
- if (!VPDataGatherer)
+ if (!ValueDataBegin)
return 0;
BufferSz = VPBufferSize ? VPBufferSize : VP_BUFFER_SIZE;
BufferIO = lprofCreateBufferIO(Writer, WriterCtx, BufferSz);
- for (DI = DataBegin; DI < DataEnd; DI++) {
- ValueProfData *CurVData = VPDataGatherer(DI);
+ for (I = 0; I < NumVData; I++) {
+ ValueProfData *CurVData = ValueDataBegin[I];
if (!CurVData)
continue;
if (lprofBufferIOWrite(BufferIO, (const uint8_t *)CurVData,
CurVData->TotalSize) != 0)
return -1;
- FreeHook(CurVData);
}
if (lprofBufferIOFlush(BufferIO) != 0)
@@ -123,28 +136,13 @@
return 0;
}
-COMPILER_RT_VISIBILITY int lprofWriteData(WriterCallback Writer,
- void *WriterCtx,
- VPGatherHookType VPDataGatherer) {
- /* Match logic in __llvm_profile_write_buffer(). */
- 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 char *NamesBegin = __llvm_profile_begin_names();
- const char *NamesEnd = __llvm_profile_end_names();
- return lprofWriteDataImpl(Writer, WriterCtx, DataBegin, DataEnd,
- CountersBegin, CountersEnd, VPDataGatherer,
- NamesBegin, NamesEnd);
-}
-
COMPILER_RT_VISIBILITY int
lprofWriteDataImpl(WriterCallback Writer, void *WriterCtx,
const __llvm_profile_data *DataBegin,
const __llvm_profile_data *DataEnd,
const uint64_t *CountersBegin, const uint64_t *CountersEnd,
- VPGatherHookType VPDataGatherer, const char *NamesBegin,
- const char *NamesEnd) {
+ ValueProfData **ValueDataBegin, const uint64_t ValueDataSize,
+ const char *NamesBegin, const char *NamesEnd) {
/* Calculate size of sections. */
const uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);
@@ -161,7 +159,7 @@
if (!DataSize)
return 0;
-/* Initialize header structure. */
+ /* Initialize header struture. */
#define INSTR_PROF_RAW_HEADER(Type, Name, Init) Header.Name = Init;
#include "InstrProfData.inc"
@@ -174,6 +172,5 @@
if (Writer(IOVec, sizeof(IOVec) / sizeof(*IOVec), &WriterCtx))
return -1;
- return writeValueProfData(Writer, WriterCtx, VPDataGatherer, DataBegin,
- DataEnd);
+ return writeValueProfData(Writer, WriterCtx, ValueDataBegin, DataSize);
}