aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/compiler-rt/lib/profile/InstrProfiling.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/compiler-rt/lib/profile/InstrProfiling.c')
-rw-r--r--contrib/llvm-project/compiler-rt/lib/profile/InstrProfiling.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/contrib/llvm-project/compiler-rt/lib/profile/InstrProfiling.c b/contrib/llvm-project/compiler-rt/lib/profile/InstrProfiling.c
index fdb7b7cd806c..0dd5ff5ae633 100644
--- a/contrib/llvm-project/compiler-rt/lib/profile/InstrProfiling.c
+++ b/contrib/llvm-project/compiler-rt/lib/profile/InstrProfiling.c
@@ -20,6 +20,14 @@
#define INSTR_PROF_VALUE_PROF_DATA
#include "profile/InstrProfData.inc"
+static uint32_t __llvm_profile_global_timestamp = 1;
+
+COMPILER_RT_VISIBILITY
+void INSTR_PROF_PROFILE_SET_TIMESTAMP(uint64_t *Probe) {
+ if (*Probe == 0 || *Probe == (uint64_t)-1)
+ *Probe = __llvm_profile_global_timestamp++;
+}
+
COMPILER_RT_VISIBILITY uint64_t __llvm_profile_get_magic(void) {
return sizeof(void *) == sizeof(uint64_t) ? (INSTR_PROF_RAW_MAGIC_64)
: (INSTR_PROF_RAW_MAGIC_32);
@@ -42,6 +50,9 @@ COMPILER_RT_VISIBILITY uint64_t __llvm_profile_get_version(void) {
}
COMPILER_RT_VISIBILITY void __llvm_profile_reset_counters(void) {
+ if (__llvm_profile_get_version() & VARIANT_MASK_TEMPORAL_PROF)
+ __llvm_profile_global_timestamp = 1;
+
char *I = __llvm_profile_begin_counters();
char *E = __llvm_profile_end_counters();