diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-21 18:29:24 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-21 18:29:24 +0000 |
| commit | 812dcae09cc94dc2a265eb0595a0279a141e2ffb (patch) | |
| tree | 0020a55786232d2f8fb38bde38ecb392b260bc92 /compiler-rt/lib/profile/InstrProfilingBuffer.c | |
| parent | 117cf2bd1ff585f9754b5f30f5a4cfd65b230bbf (diff) | |
| download | bcm5719-llvm-812dcae09cc94dc2a265eb0595a0279a141e2ffb.tar.gz bcm5719-llvm-812dcae09cc94dc2a265eb0595a0279a141e2ffb.zip | |
InstrProf: Unify logic in two profile writers
<rdar://problem/15943240>
llvm-svn: 204500
Diffstat (limited to 'compiler-rt/lib/profile/InstrProfilingBuffer.c')
| -rw-r--r-- | compiler-rt/lib/profile/InstrProfilingBuffer.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingBuffer.c b/compiler-rt/lib/profile/InstrProfilingBuffer.c index 2d91961a616..250e2214359 100644 --- a/compiler-rt/lib/profile/InstrProfilingBuffer.c +++ b/compiler-rt/lib/profile/InstrProfilingBuffer.c @@ -11,13 +11,17 @@ #include <string.h> uint64_t __llvm_profile_get_size_for_buffer(void) { - return sizeof(uint64_t) * 7 + + /* Match logic in __llvm_profile_write_buffer(). */ + return sizeof(uint64_t) * PROFILE_HEADER_SIZE + PROFILE_RANGE_SIZE(data) * sizeof(__llvm_profile_data) + PROFILE_RANGE_SIZE(counters) * sizeof(uint64_t) + PROFILE_RANGE_SIZE(names) * sizeof(char); } int __llvm_profile_write_buffer(char *Buffer) { + /* Match logic in __llvm_profile_get_size_for_buffer(). + * Match logic in __llvm_profile_write_file(). + */ const __llvm_profile_data *DataBegin = __llvm_profile_data_begin(); const __llvm_profile_data *DataEnd = __llvm_profile_data_end(); const uint64_t *CountersBegin = __llvm_profile_counters_begin(); @@ -31,7 +35,7 @@ int __llvm_profile_write_buffer(char *Buffer) { const uint64_t NamesSize = NamesEnd - NamesBegin; /* Create the header. */ - uint64_t Header[] = { + uint64_t Header[PROFILE_HEADER_SIZE] = { __llvm_profile_get_magic(), __llvm_profile_get_version(), DataSize, @@ -47,10 +51,10 @@ int __llvm_profile_write_buffer(char *Buffer) { memcpy(Buffer, Data, Size); \ Buffer += Size; \ } while (0) - UPDATE_memcpy(Header, sizeof(Header)); - UPDATE_memcpy(DataBegin, DataSize * sizeof(__llvm_profile_data)); - UPDATE_memcpy(CountersBegin, CountersSize * sizeof(uint64_t)); - UPDATE_memcpy(NamesBegin, NamesSize * sizeof(char)); + UPDATE_memcpy(Header, PROFILE_HEADER_SIZE * sizeof(uint64_t)); + UPDATE_memcpy(DataBegin, DataSize * sizeof(__llvm_profile_data)); + UPDATE_memcpy(CountersBegin, CountersSize * sizeof(uint64_t)); + UPDATE_memcpy(NamesBegin, NamesSize * sizeof(char)); #undef UPDATE_memcpy return 0; |

