[compiler-rt] r256264 - [PGO] Move buffer write callback to a common file
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 22 10:57:16 PST 2015
Author: davidxl
Date: Tue Dec 22 12:57:15 2015
New Revision: 256264
URL: http://llvm.org/viewvc/llvm-project?rev=256264&view=rev
Log:
[PGO] Move buffer write callback to a common file
This is a NFC refactoring enabling code sharing by file writer.
Modified:
compiler-rt/trunk/lib/profile/InstrProfilingBuffer.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=256264&r1=256263&r2=256264&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingBuffer.c Tue Dec 22 12:57:15 2015
@@ -10,8 +10,6 @@
#include "InstrProfiling.h"
#include "InstrProfilingInternal.h"
-#include <string.h>
-
COMPILER_RT_VISIBILITY
uint64_t __llvm_profile_get_size_for_buffer(void) {
const __llvm_profile_data *DataBegin = __llvm_profile_begin_data();
@@ -40,30 +38,15 @@ uint64_t __llvm_profile_get_size_for_buf
PROFILE_RANGE_SIZE(Counters) * sizeof(uint64_t) + NamesSize + Padding;
}
-/* The buffer writer is reponsponsible in keeping writer state
- * across the call.
- */
-static uint32_t bufferWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
- void **WriterCtx) {
- uint32_t I;
- char **Buffer = (char **)WriterCtx;
- for (I = 0; I < NumIOVecs; I++) {
- size_t Length = IOVecs[I].ElmSize * IOVecs[I].NumElm;
- memcpy(*Buffer, IOVecs[I].Data, Length);
- *Buffer += Length;
- }
- return 0;
-}
-
COMPILER_RT_VISIBILITY int __llvm_profile_write_buffer(char *Buffer) {
- return llvmWriteProfData(bufferWriter, Buffer, 0, 0);
+ return llvmWriteProfData(llvmBufferWriter, Buffer, 0, 0);
}
COMPILER_RT_VISIBILITY 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(bufferWriter, Buffer, DataBegin, DataEnd,
+ return llvmWriteProfDataImpl(llvmBufferWriter, Buffer, DataBegin, DataEnd,
CountersBegin, CountersEnd, 0, 0, NamesBegin,
NamesEnd);
}
Modified: compiler-rt/trunk/lib/profile/InstrProfilingInternal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingInternal.h?rev=256264&r1=256263&r2=256264&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingInternal.h (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingInternal.h Tue Dec 22 12:57:15 2015
@@ -49,6 +49,8 @@ typedef struct ProfDataIOVec {
typedef uint32_t (*WriterCallback)(ProfDataIOVec *, uint32_t NumIOVecs,
void **WriterCtx);
+uint32_t llvmBufferWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
+ void **WriterCtx);
int llvmWriteProfData(WriterCallback Writer, void *WriterCtx,
const uint8_t *ValueDataBegin,
const uint64_t ValueDataSize);
Modified: compiler-rt/trunk/lib/profile/InstrProfilingWriter.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingWriter.c?rev=256264&r1=256263&r2=256264&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingWriter.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingWriter.c Tue Dec 22 12:57:15 2015
@@ -9,6 +9,23 @@
#include "InstrProfiling.h"
#include "InstrProfilingInternal.h"
+#include <string.h>
+
+/* The buffer writer is reponsponsible in keeping writer state
+ * across the call.
+ */
+COMPILER_RT_VISIBILITY uint32_t llvmBufferWriter(ProfDataIOVec *IOVecs,
+ uint32_t NumIOVecs,
+ void **WriterCtx) {
+ uint32_t I;
+ char **Buffer = (char **)WriterCtx;
+ for (I = 0; I < NumIOVecs; I++) {
+ size_t Length = IOVecs[I].ElmSize * IOVecs[I].NumElm;
+ memcpy(*Buffer, IOVecs[I].Data, Length);
+ *Buffer += Length;
+ }
+ return 0;
+}
COMPILER_RT_VISIBILITY int llvmWriteProfData(WriterCallback Writer,
void *WriterCtx,
More information about the llvm-commits
mailing list