diff --git a/compiler-rt/lib/profile/InstrProfiling.c b/compiler-rt/lib/profile/InstrProfiling.c index c897052d8c48..936b8def38cb 100644 --- a/compiler-rt/lib/profile/InstrProfiling.c +++ b/compiler-rt/lib/profile/InstrProfiling.c @@ -8,6 +8,7 @@ \*===----------------------------------------------------------------------===*/ #include "InstrProfiling.h" +#include /* TODO: void __llvm_pgo_get_size_for_buffer(void); */ @@ -34,3 +35,10 @@ void __llvm_pgo_write_buffer(FILE *OutputFile) { I != E; ++I) writeFunction(OutputFile, I); } + +void __llvm_pgo_reset_counters(void) { + uint64_t *I = __llvm_pgo_counters_begin(); + uint64_t *E = __llvm_pgo_counters_end(); + + memset(I, 0, sizeof(uint64_t)*(E - I)); +} diff --git a/compiler-rt/lib/profile/InstrProfiling.h b/compiler-rt/lib/profile/InstrProfiling.h index a3e86ca557c5..9a659c04a64e 100644 --- a/compiler-rt/lib/profile/InstrProfiling.h +++ b/compiler-rt/lib/profile/InstrProfiling.h @@ -37,7 +37,7 @@ typedef struct __llvm_pgo_data { const uint32_t NumCounters; const uint64_t FuncHash; const char *const Name; - const uint64_t *const Counters; + uint64_t *const Counters; } __llvm_pgo_data; /* TODO: void __llvm_pgo_get_size_for_buffer(void); */ @@ -55,5 +55,5 @@ const __llvm_pgo_data *__llvm_pgo_data_begin(); const __llvm_pgo_data *__llvm_pgo_data_end(); const char *__llvm_pgo_names_begin(); const char *__llvm_pgo_names_end(); -const uint64_t *__llvm_pgo_counters_begin(); -const uint64_t *__llvm_pgo_counters_end(); +uint64_t *__llvm_pgo_counters_begin(); +uint64_t *__llvm_pgo_counters_end(); diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformDarwin.c b/compiler-rt/lib/profile/InstrProfilingPlatformDarwin.c index de388ee5ebda..decd6b09bb3e 100644 --- a/compiler-rt/lib/profile/InstrProfilingPlatformDarwin.c +++ b/compiler-rt/lib/profile/InstrProfilingPlatformDarwin.c @@ -21,5 +21,5 @@ const __llvm_pgo_data *__llvm_pgo_data_begin() { return &DataStart; } const __llvm_pgo_data *__llvm_pgo_data_end() { return &DataEnd; } const char *__llvm_pgo_names_begin() { return &NamesStart; } const char *__llvm_pgo_names_end() { return &NamesEnd; } -const uint64_t *__llvm_pgo_counters_begin() { return &CountersStart; } -const uint64_t *__llvm_pgo_counters_end() { return &CountersEnd; } +uint64_t *__llvm_pgo_counters_begin() { return &CountersStart; } +uint64_t *__llvm_pgo_counters_end() { return &CountersEnd; } diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c index d39f39f37183..dbd7d06ed1f3 100644 --- a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c +++ b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c @@ -13,8 +13,8 @@ static const __llvm_pgo_data *DataFirst = NULL; static const __llvm_pgo_data *DataLast = NULL; static const char *NamesFirst = NULL; static const char *NamesLast = NULL; -static const uint64_t *CountersFirst = NULL; -static const uint64_t *CountersLast = NULL; +static uint64_t *CountersFirst = NULL; +static uint64_t *CountersLast = NULL; /*! * \brief Register an instrumented function. @@ -55,5 +55,5 @@ const __llvm_pgo_data *__llvm_pgo_data_begin() { return DataFirst; } const __llvm_pgo_data *__llvm_pgo_data_end() { return DataLast; } const char *__llvm_pgo_names_begin() { return NamesFirst; } const char *__llvm_pgo_names_end() { return NamesLast; } -const uint64_t *__llvm_pgo_counters_begin() { return CountersFirst; } -const uint64_t *__llvm_pgo_counters_end() { return CountersLast; } +uint64_t *__llvm_pgo_counters_begin() { return CountersFirst; } +uint64_t *__llvm_pgo_counters_end() { return CountersLast; }