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 | 32f16ac9c2115863331d5615f9472e93cd6d072b (patch) | |
tree | fecac55617b1b82aaae6ba3ecacb6fb986170423 /lib/profile/InstrProfilingWriter.c | |
parent | d800108a722bf428fb4a5e493007cb13299d3948 (diff) |
[PGO] Move buffer write callback to a common file
This is a NFC refactoring enabling code sharing by file writer.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256264 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/InstrProfilingWriter.c')
-rw-r--r-- | lib/profile/InstrProfilingWriter.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/profile/InstrProfilingWriter.c b/lib/profile/InstrProfilingWriter.c index 4c9e67965..8519891f2 100644 --- a/lib/profile/InstrProfilingWriter.c +++ b/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, |