[compiler-rt] r204386 - PGO: Add function to reset counters at runtime
Duncan P. N. Exon Smith
dexonsmith at apple.com
Thu Mar 20 12:44:32 PDT 2014
Author: dexonsmith
Date: Thu Mar 20 14:44:31 2014
New Revision: 204386
URL: http://llvm.org/viewvc/llvm-project?rev=204386&view=rev
Log:
PGO: Add function to reset counters at runtime
Adding __llvm_pgo_reset_counters(), which sets all the counters to 0.
<rdar://problem/15943240>
Modified:
compiler-rt/trunk/lib/profile/InstrProfiling.c
compiler-rt/trunk/lib/profile/InstrProfiling.h
compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c
compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c
Modified: compiler-rt/trunk/lib/profile/InstrProfiling.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfiling.c?rev=204386&r1=204385&r2=204386&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfiling.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfiling.c Thu Mar 20 14:44:31 2014
@@ -8,6 +8,7 @@
\*===----------------------------------------------------------------------===*/
#include "InstrProfiling.h"
+#include <string.h>
/* TODO: void __llvm_pgo_get_size_for_buffer(void); */
@@ -34,3 +35,10 @@ void __llvm_pgo_write_buffer(FILE *Outpu
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));
+}
Modified: compiler-rt/trunk/lib/profile/InstrProfiling.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfiling.h?rev=204386&r1=204385&r2=204386&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfiling.h (original)
+++ compiler-rt/trunk/lib/profile/InstrProfiling.h Thu Mar 20 14:44:31 2014
@@ -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_b
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();
Modified: compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c?rev=204386&r1=204385&r2=204386&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingPlatformDarwin.c Thu Mar 20 14:44:31 2014
@@ -21,5 +21,5 @@ const __llvm_pgo_data *__llvm_pgo_data_b
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; }
Modified: compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c?rev=204386&r1=204385&r2=204386&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingPlatformOther.c Thu Mar 20 14:44:31 2014
@@ -13,8 +13,8 @@ static const __llvm_pgo_data *DataFirst
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_b
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; }
More information about the llvm-commits
mailing list