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
|
|
|
|
|
|
|
#if !defined(__APPLE__)
|
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
|
|
|
|
|
|
|
/*!
|
|
|
|
* \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.
|
|
|
|
*/
|
2014-05-16 09:30:24 +08:00
|
|
|
__attribute__((visibility("hidden")))
|
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. */
|
2014-03-21 04:00:44 +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;
|
|
|
|
NamesFirst = Data->Name;
|
|
|
|
NamesLast = Data->Name + Data->NameSize;
|
|
|
|
CountersFirst = Data->Counters;
|
|
|
|
CountersLast = Data->Counters + Data->NumCounters;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define UPDATE_FIRST(First, New) \
|
|
|
|
First = New < First ? New : First
|
|
|
|
UPDATE_FIRST(DataFirst, Data);
|
|
|
|
UPDATE_FIRST(NamesFirst, Data->Name);
|
|
|
|
UPDATE_FIRST(CountersFirst, Data->Counters);
|
|
|
|
#undef UPDATE_FIRST
|
|
|
|
|
|
|
|
#define UPDATE_LAST(Last, New) \
|
|
|
|
Last = New > Last ? New : Last
|
|
|
|
UPDATE_LAST(DataLast, Data + 1);
|
|
|
|
UPDATE_LAST(NamesLast, Data->Name + Data->NameSize);
|
|
|
|
UPDATE_LAST(CountersLast, Data->Counters + Data->NumCounters);
|
|
|
|
#undef UPDATE_LAST
|
|
|
|
}
|
|
|
|
|
2014-05-16 09:30:24 +08:00
|
|
|
__attribute__((visibility("hidden")))
|
2014-09-04 23:45:31 +08:00
|
|
|
const __llvm_profile_data *__llvm_profile_begin_data(void) {
|
2014-03-21 04:55:00 +08:00
|
|
|
return DataFirst;
|
|
|
|
}
|
2014-05-16 09:30:24 +08:00
|
|
|
__attribute__((visibility("hidden")))
|
2014-09-04 23:45:31 +08:00
|
|
|
const __llvm_profile_data *__llvm_profile_end_data(void) {
|
2014-03-21 04:55:00 +08:00
|
|
|
return DataLast;
|
|
|
|
}
|
2014-05-16 09:30:24 +08:00
|
|
|
__attribute__((visibility("hidden")))
|
2014-09-04 23:45:31 +08:00
|
|
|
const char *__llvm_profile_begin_names(void) { return NamesFirst; }
|
2014-05-16 09:30:24 +08:00
|
|
|
__attribute__((visibility("hidden")))
|
2014-09-04 23:45:31 +08:00
|
|
|
const char *__llvm_profile_end_names(void) { return NamesLast; }
|
2014-05-16 09:30:24 +08:00
|
|
|
__attribute__((visibility("hidden")))
|
2014-09-04 23:45:31 +08:00
|
|
|
uint64_t *__llvm_profile_begin_counters(void) { return CountersFirst; }
|
2014-05-16 09:30:24 +08:00
|
|
|
__attribute__((visibility("hidden")))
|
2014-09-04 23:45:31 +08:00
|
|
|
uint64_t *__llvm_profile_end_counters(void) { return CountersLast; }
|
2014-04-23 02:49:32 +08:00
|
|
|
#endif
|