summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/profile/InstrProfilingMerge.c
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/profile/InstrProfilingMerge.c')
-rw-r--r--compiler-rt/lib/profile/InstrProfilingMerge.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingMerge.c b/compiler-rt/lib/profile/InstrProfilingMerge.c
index 9ea8bb5a76a..a2021154df7 100644
--- a/compiler-rt/lib/profile/InstrProfilingMerge.c
+++ b/compiler-rt/lib/profile/InstrProfilingMerge.c
@@ -19,6 +19,22 @@
COMPILER_RT_WEAK void (*VPMergeHook)(ValueProfData *,
__llvm_profile_data *) = NULL;
+COMPILER_RT_VISIBILITY
+uint64_t lprofGetLoadModuleSignature() {
+ /* A very fast way to compute a module signature. */
+ uint64_t CounterSize = (uint64_t)(__llvm_profile_end_counters() -
+ __llvm_profile_begin_counters());
+ uint64_t DataSize = __llvm_profile_get_data_size(__llvm_profile_begin_data(),
+ __llvm_profile_end_data());
+ uint64_t NamesSize =
+ (uint64_t)(__llvm_profile_end_names() - __llvm_profile_begin_names());
+ uint64_t NumVnodes =
+ (uint64_t)(__llvm_profile_end_vnodes() - __llvm_profile_begin_vnodes());
+ const __llvm_profile_data *FirstD = __llvm_profile_begin_data();
+
+ return (NamesSize << 40) + (CounterSize << 30) + (DataSize << 20) +
+ (NumVnodes << 10) + (DataSize > 0 ? FirstD->NameRef : 0);
+}
/* Returns 1 if profile is not structurally compatible. */
COMPILER_RT_VISIBILITY
@@ -31,6 +47,9 @@ int __llvm_profile_check_compatibility(const char *ProfileData,
(__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header));
SrcDataEnd = SrcDataStart + Header->DataSize;
+ if (ProfileSize < sizeof(__llvm_profile_header))
+ return 1;
+
/* Check the header first. */
if (Header->Magic != __llvm_profile_get_magic() ||
Header->Version != __llvm_profile_get_version() ||
OpenPOWER on IntegriCloud