diff options
| author | Xinliang David Li <davidxl@google.com> | 2015-12-22 18:57:15 +0000 | 
|---|---|---|
| committer | Xinliang David Li <davidxl@google.com> | 2015-12-22 18:57:15 +0000 | 
| commit | baf55d8266ba5c9a7f34f0db440c3d10a1c9ab5d (patch) | |
| tree | 13243ccc734b11e8ec662e3fd98d82bb6f0d452f | |
| parent | e93b8e1539857d770cdd5a815b4bc3f3eb474e51 (diff) | |
| download | bcm5719-llvm-baf55d8266ba5c9a7f34f0db440c3d10a1c9ab5d.tar.gz bcm5719-llvm-baf55d8266ba5c9a7f34f0db440c3d10a1c9ab5d.zip | |
[PGO] Move buffer write callback to a common file
This is a NFC refactoring enabling code sharing by file writer.
llvm-svn: 256264
| -rw-r--r-- | compiler-rt/lib/profile/InstrProfilingBuffer.c | 21 | ||||
| -rw-r--r-- | compiler-rt/lib/profile/InstrProfilingInternal.h | 2 | ||||
| -rw-r--r-- | compiler-rt/lib/profile/InstrProfilingWriter.c | 17 | 
3 files changed, 21 insertions, 19 deletions
| diff --git a/compiler-rt/lib/profile/InstrProfilingBuffer.c b/compiler-rt/lib/profile/InstrProfilingBuffer.c index 8bade76cfe0..4227ca6b66e 100644 --- a/compiler-rt/lib/profile/InstrProfilingBuffer.c +++ b/compiler-rt/lib/profile/InstrProfilingBuffer.c @@ -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_buffer_internal(           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);  } diff --git a/compiler-rt/lib/profile/InstrProfilingInternal.h b/compiler-rt/lib/profile/InstrProfilingInternal.h index d247ca43772..e1302d3a6ef 100644 --- a/compiler-rt/lib/profile/InstrProfilingInternal.h +++ b/compiler-rt/lib/profile/InstrProfilingInternal.h @@ -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); diff --git a/compiler-rt/lib/profile/InstrProfilingWriter.c b/compiler-rt/lib/profile/InstrProfilingWriter.c index 4c9e6796503..8519891f2a9 100644 --- a/compiler-rt/lib/profile/InstrProfilingWriter.c +++ b/compiler-rt/lib/profile/InstrProfilingWriter.c @@ -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, | 

