[compiler-rt] r253545 - [PGO] Minor cleanups (from review feedback)
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 18 23:21:47 PST 2015
Author: davidxl
Date: Thu Nov 19 01:21:47 2015
New Revision: 253545
URL: http://llvm.org/viewvc/llvm-project?rev=253545&view=rev
Log:
[PGO] Minor cleanups (from review feedback)
1. fix naming problem of file/buffer writer
2. change BufferOrFile to WriterCtx
3. move writer and writerctx together
Modified:
compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c
compiler-rt/trunk/lib/profile/InstrProfilingFile.c
compiler-rt/trunk/lib/profile/InstrProfilingInternal.h
compiler-rt/trunk/lib/profile/InstrProfilingWriter.c
Modified: compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c?rev=253545&r1=253544&r2=253545&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c Thu Nov 19 01:21:47 2015
@@ -41,7 +41,7 @@ uint64_t __llvm_profile_get_size_for_buf
PROFILE_RANGE_SIZE(Counters) * sizeof(uint64_t) + NamesSize + Padding;
}
-static size_t BufferWriter(const void *Data, size_t ElmSize, size_t NumElm,
+static size_t bufferWriter(const void *Data, size_t ElmSize, size_t NumElm,
void **Buffer) {
size_t Length = ElmSize * NumElm;
memcpy(*Buffer, Data, Length);
@@ -51,14 +51,14 @@ static size_t BufferWriter(const void *D
__attribute__((visibility("hidden"))) int
__llvm_profile_write_buffer(char *Buffer) {
- return llvmWriteProfData(Buffer, 0, 0, BufferWriter);
+ return llvmWriteProfData(Buffer, bufferWriter, 0, 0);
}
__attribute__((visibility("hidden"))) int __llvm_profile_write_buffer_internal(
char *Buffer, const __llvm_profile_data *DataBegin,
const __llvm_profile_data *DataEnd, const uint64_t *CountersBegin,
const uint64_t *CountersEnd, const char *NamesBegin, const char *NamesEnd) {
- return llvmWriteProfDataImpl(Buffer, BufferWriter, DataBegin, DataEnd,
+ return llvmWriteProfDataImpl(Buffer, bufferWriter, DataBegin, DataEnd,
CountersBegin, CountersEnd, 0, 0, NamesBegin,
NamesEnd);
}
Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=253545&r1=253544&r2=253545&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Thu Nov 19 01:21:47 2015
@@ -17,7 +17,7 @@
#define UNCONST(ptr) ((void *)(uintptr_t)(ptr))
-static size_t FileWriter(const void *Data, size_t ElmSize, size_t NumElm,
+static size_t fileWriter(const void *Data, size_t ElmSize, size_t NumElm,
void **File) {
return fwrite(Data, ElmSize, NumElm, (FILE *)*File);
}
@@ -27,7 +27,7 @@ static int writeFile(FILE *File) {
uint8_t *ValueDataBegin = NULL;
const uint64_t ValueDataSize =
__llvm_profile_gather_value_data(&ValueDataBegin);
- int r = llvmWriteProfData(File, ValueDataBegin, ValueDataSize, FileWriter);
+ int r = llvmWriteProfData(File, fileWriter, ValueDataBegin, ValueDataSize);
free(ValueDataBegin);
return r;
}
Modified: compiler-rt/trunk/lib/profile/InstrProfilingInternal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingInternal.h?rev=253545&r1=253544&r2=253545&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingInternal.h (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingInternal.h Thu Nov 19 01:21:47 2015
@@ -43,9 +43,10 @@ int __llvm_profile_write_buffer_internal
*/
typedef size_t (*WriterCallback)(const void *Data, size_t ElmS, size_t NumElm,
void **BufferOrFile);
-int llvmWriteProfData(void *BufferOrFile, const uint8_t *ValueDataBegin,
- const uint64_t ValueDataSize, WriterCallback Writer);
-int llvmWriteProfDataImpl(void *BufferOrFile, WriterCallback Writer,
+int llvmWriteProfData(void *WriterCtx, WriterCallback Writer,
+ const uint8_t *ValueDataBegin,
+ const uint64_t ValueDataSize);
+int llvmWriteProfDataImpl(void *WriterCtx, WriterCallback Writer,
const __llvm_profile_data *DataBegin,
const __llvm_profile_data *DataEnd,
const uint64_t *CountersBegin,
Modified: compiler-rt/trunk/lib/profile/InstrProfilingWriter.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingWriter.c?rev=253545&r1=253544&r2=253545&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingWriter.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingWriter.c Thu Nov 19 01:21:47 2015
@@ -11,8 +11,8 @@
#include "InstrProfilingInternal.h"
__attribute__((visibility("hidden"))) int
-llvmWriteProfData(void *BufferOrFile, const uint8_t *ValueDataBegin,
- const uint64_t ValueDataSize, WriterCallback Writer) {
+llvmWriteProfData(void *WriterCtx, WriterCallback Writer,
+ const uint8_t *ValueDataBegin, 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();
@@ -20,13 +20,13 @@ llvmWriteProfData(void *BufferOrFile, co
const uint64_t *CountersEnd = __llvm_profile_end_counters();
const char *NamesBegin = __llvm_profile_begin_names();
const char *NamesEnd = __llvm_profile_end_names();
- return llvmWriteProfDataImpl(BufferOrFile, Writer, DataBegin, DataEnd,
+ return llvmWriteProfDataImpl(WriterCtx, Writer, DataBegin, DataEnd,
CountersBegin, CountersEnd, ValueDataBegin,
ValueDataSize, NamesBegin, NamesEnd);
}
__attribute__((visibility("hidden"))) int llvmWriteProfDataImpl(
- void *BufferOrFile, WriterCallback Writer,
+ void *WriterCtx, WriterCallback Writer,
const __llvm_profile_data *DataBegin, const __llvm_profile_data *DataEnd,
const uint64_t *CountersBegin, const uint64_t *CountersEnd,
const uint8_t *ValueDataBegin, const uint64_t ValueDataSize,
@@ -64,13 +64,13 @@ __attribute__((visibility("hidden"))) in
if (Writer(Data, Size, Length, &BuffOrFile) != Length) \
return -1; \
} while (0)
- CHECK_write(&Header, sizeof(__llvm_profile_header), 1, BufferOrFile);
- CHECK_write(DataBegin, sizeof(__llvm_profile_data), DataSize, BufferOrFile);
- CHECK_write(CountersBegin, sizeof(uint64_t), CountersSize, BufferOrFile);
- CHECK_write(NamesBegin, sizeof(char), NamesSize, BufferOrFile);
- CHECK_write(Zeroes, sizeof(char), Padding, BufferOrFile);
+ CHECK_write(&Header, sizeof(__llvm_profile_header), 1, WriterCtx);
+ CHECK_write(DataBegin, sizeof(__llvm_profile_data), DataSize, WriterCtx);
+ CHECK_write(CountersBegin, sizeof(uint64_t), CountersSize, WriterCtx);
+ CHECK_write(NamesBegin, sizeof(char), NamesSize, WriterCtx);
+ CHECK_write(Zeroes, sizeof(char), Padding, WriterCtx);
if (ValueDataBegin)
- CHECK_write(ValueDataBegin, sizeof(char), ValueDataSize, BufferOrFile);
+ CHECK_write(ValueDataBegin, sizeof(char), ValueDataSize, WriterCtx);
#undef CHECK_write
return 0;
}
More information about the llvm-commits
mailing list