1 /*===- InstrProfilingPlatformOther.c - Profile data default platform ------===*\
3 |* The LLVM Compiler Infrastructure
5 |* This file is distributed under the University of Illinois Open Source
6 |* License. See LICENSE.TXT for details.
8 \*===----------------------------------------------------------------------===*/
10 #if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__) && \
11 !(defined(__sun__) && defined(__svr4__)) && !defined(__NetBSD__)
15 #include "InstrProfiling.h"
17 static const __llvm_profile_data *DataFirst = NULL;
18 static const __llvm_profile_data *DataLast = NULL;
19 static const char *NamesFirst = NULL;
20 static const char *NamesLast = NULL;
21 static uint64_t *CountersFirst = NULL;
22 static uint64_t *CountersLast = NULL;
24 static const void *getMinAddr(const void *A1, const void *A2) {
25 return A1 < A2 ? A1 : A2;
28 static const void *getMaxAddr(const void *A1, const void *A2) {
29 return A1 > A2 ? A1 : A2;
33 * \brief Register an instrumented function.
35 * Calls to this are emitted by clang with -fprofile-instr-generate. Such
36 * calls are only required (and only emitted) on targets where we haven't
37 * implemented linker magic to find the bounds of the sections.
39 COMPILER_RT_VISIBILITY
40 void __llvm_profile_register_function(void *Data_) {
41 /* TODO: Only emit this function if we can't use linker magic. */
42 const __llvm_profile_data *Data = (__llvm_profile_data *)Data_;
46 CountersFirst = Data->CounterPtr;
47 CountersLast = (uint64_t *)Data->CounterPtr + Data->NumCounters;
51 DataFirst = (const __llvm_profile_data *)getMinAddr(DataFirst, Data);
52 CountersFirst = (uint64_t *)getMinAddr(CountersFirst, Data->CounterPtr);
54 DataLast = (const __llvm_profile_data *)getMaxAddr(DataLast, Data + 1);
55 CountersLast = (uint64_t *)getMaxAddr(
56 CountersLast, (uint64_t *)Data->CounterPtr + Data->NumCounters);
59 COMPILER_RT_VISIBILITY
60 void __llvm_profile_register_names_function(void *NamesStart,
63 NamesFirst = (const char *)NamesStart;
64 NamesLast = (const char *)NamesStart + NamesSize;
67 NamesFirst = (const char *)getMinAddr(NamesFirst, NamesStart);
69 (const char *)getMaxAddr(NamesLast, (const char *)NamesStart + NamesSize);
72 COMPILER_RT_VISIBILITY
73 const __llvm_profile_data *__llvm_profile_begin_data(void) { return DataFirst; }
74 COMPILER_RT_VISIBILITY
75 const __llvm_profile_data *__llvm_profile_end_data(void) { return DataLast; }
76 COMPILER_RT_VISIBILITY
77 const char *__llvm_profile_begin_names(void) { return NamesFirst; }
78 COMPILER_RT_VISIBILITY
79 const char *__llvm_profile_end_names(void) { return NamesLast; }
80 COMPILER_RT_VISIBILITY
81 uint64_t *__llvm_profile_begin_counters(void) { return CountersFirst; }
82 COMPILER_RT_VISIBILITY
83 uint64_t *__llvm_profile_end_counters(void) { return CountersLast; }
85 COMPILER_RT_VISIBILITY
86 ValueProfNode *__llvm_profile_begin_vnodes(void) {
89 COMPILER_RT_VISIBILITY
90 ValueProfNode *__llvm_profile_end_vnodes(void) { return 0; }
92 COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = 0;
93 COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = 0;