2014-05-15 10:22:34 +08:00
|
|
|
/*===- InstrProfilingPlatformOther.c - Profile data default platform ------===*\
|
2014-03-20 11:23:10 +08:00
|
|
|
|*
|
|
|
|
|* The LLVM Compiler Infrastructure
|
|
|
|
|*
|
|
|
|
|* This file is distributed under the University of Illinois Open Source
|
|
|
|
|* License. See LICENSE.TXT for details.
|
|
|
|
|*
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
#include "InstrProfiling.h"
|
2014-04-23 02:49:32 +08:00
|
|
|
|
2015-10-19 12:17:19 +08:00
|
|
|
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__)
|
2016-02-09 02:14:02 +08:00
|
|
|
|
2014-03-22 02:29:15 +08:00
|
|
|
#include <stdlib.h>
|
2014-03-20 11:23:10 +08:00
|
|
|
|
2014-03-21 04:00:44 +08:00
|
|
|
static const __llvm_profile_data *DataFirst = NULL;
|
|
|
|
static const __llvm_profile_data *DataLast = NULL;
|
2014-03-20 11:23:10 +08:00
|
|
|
static const char *NamesFirst = NULL;
|
|
|
|
static const char *NamesLast = NULL;
|
2014-03-21 03:44:31 +08:00
|
|
|
static uint64_t *CountersFirst = NULL;
|
|
|
|
static uint64_t *CountersLast = NULL;
|
2014-03-20 11:23:10 +08:00
|
|
|
|
2016-02-09 02:14:02 +08:00
|
|
|
static const void *getMinAddr(const void *A1, const void *A2) {
|
|
|
|
return A1 < A2 ? A1 : A2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const void *getMaxAddr(const void *A1, const void *A2) {
|
|
|
|
return A1 > A2 ? A1 : A2;
|
|
|
|
}
|
|
|
|
|
2014-03-20 11:23:10 +08:00
|
|
|
/*!
|
|
|
|
* \brief Register an instrumented function.
|
|
|
|
*
|
|
|
|
* Calls to this are emitted by clang with -fprofile-instr-generate. Such
|
|
|
|
* calls are only required (and only emitted) on targets where we haven't
|
|
|
|
* implemented linker magic to find the bounds of the sections.
|
|
|
|
*/
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY
|
2014-03-21 04:00:44 +08:00
|
|
|
void __llvm_profile_register_function(void *Data_) {
|
2014-03-20 11:23:10 +08:00
|
|
|
/* TODO: Only emit this function if we can't use linker magic. */
|
2015-11-23 12:38:17 +08:00
|
|
|
const __llvm_profile_data *Data = (__llvm_profile_data *)Data_;
|
2014-03-20 11:23:10 +08:00
|
|
|
if (!DataFirst) {
|
|
|
|
DataFirst = Data;
|
|
|
|
DataLast = Data + 1;
|
2015-11-09 02:00:13 +08:00
|
|
|
CountersFirst = Data->CounterPtr;
|
2015-12-20 03:16:32 +08:00
|
|
|
CountersLast = (uint64_t *)Data->CounterPtr + Data->NumCounters;
|
2014-03-20 11:23:10 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-09 02:14:02 +08:00
|
|
|
DataFirst = (const __llvm_profile_data *)getMinAddr(DataFirst, Data);
|
|
|
|
CountersFirst = (uint64_t *)getMinAddr(CountersFirst, Data->CounterPtr);
|
2014-03-20 11:23:10 +08:00
|
|
|
|
2016-02-09 02:14:02 +08:00
|
|
|
DataLast = (const __llvm_profile_data *)getMaxAddr(DataLast, Data + 1);
|
|
|
|
CountersLast = (uint64_t *)getMaxAddr(
|
|
|
|
CountersLast, (uint64_t *)Data->CounterPtr + Data->NumCounters);
|
|
|
|
}
|
|
|
|
|
|
|
|
COMPILER_RT_VISIBILITY
|
|
|
|
void __llvm_profile_register_names_function(void *NamesStart,
|
|
|
|
uint64_t NamesSize) {
|
|
|
|
if (!NamesFirst) {
|
|
|
|
NamesFirst = (const char *)NamesStart;
|
|
|
|
NamesLast = (const char *)NamesStart + NamesSize;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
NamesFirst = (const char *)getMinAddr(NamesFirst, NamesStart);
|
2016-02-09 02:27:04 +08:00
|
|
|
NamesLast =
|
|
|
|
(const char *)getMaxAddr(NamesLast, (const char *)NamesStart + NamesSize);
|
2014-03-20 11:23:10 +08:00
|
|
|
}
|
|
|
|
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY
|
2015-11-23 12:38:17 +08:00
|
|
|
const __llvm_profile_data *__llvm_profile_begin_data(void) { return DataFirst; }
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY
|
2015-11-23 12:38:17 +08:00
|
|
|
const __llvm_profile_data *__llvm_profile_end_data(void) { return DataLast; }
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY
|
2014-09-04 23:45:31 +08:00
|
|
|
const char *__llvm_profile_begin_names(void) { return NamesFirst; }
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY
|
2014-09-04 23:45:31 +08:00
|
|
|
const char *__llvm_profile_end_names(void) { return NamesLast; }
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY
|
2014-09-04 23:45:31 +08:00
|
|
|
uint64_t *__llvm_profile_begin_counters(void) { return CountersFirst; }
|
2015-12-16 11:29:15 +08:00
|
|
|
COMPILER_RT_VISIBILITY
|
2014-09-04 23:45:31 +08:00
|
|
|
uint64_t *__llvm_profile_end_counters(void) { return CountersLast; }
|
2016-05-22 06:55:45 +08:00
|
|
|
|
|
|
|
COMPILER_RT_VISIBILITY
|
|
|
|
ValueProfNode *__llvm_profile_begin_vnodes(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
COMPILER_RT_VISIBILITY
|
2016-05-22 07:06:39 +08:00
|
|
|
ValueProfNode *__llvm_profile_end_vnodes(void) { return 0; }
|
2016-05-22 06:55:45 +08:00
|
|
|
|
2016-05-23 00:36:03 +08:00
|
|
|
COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = 0;
|
|
|
|
COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = 0;
|
|
|
|
|
2014-04-23 02:49:32 +08:00
|
|
|
#endif
|