1 /*===- InstrProfilingPlatformLinux.c - Profile data Linux 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 #include "InstrProfiling.h"
12 #if defined(__linux__) || defined(__FreeBSD__)
15 #define PROF_DATA_START INSTR_PROF_SECT_START(INSTR_PROF_DATA_SECT_NAME)
16 #define PROF_DATA_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_DATA_SECT_NAME)
17 #define PROF_NAME_START INSTR_PROF_SECT_START(INSTR_PROF_NAME_SECT_NAME)
18 #define PROF_NAME_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_NAME_SECT_NAME)
19 #define PROF_CNTS_START INSTR_PROF_SECT_START(INSTR_PROF_CNTS_SECT_NAME)
20 #define PROF_CNTS_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_CNTS_SECT_NAME)
21 #define PROF_VNODES_START INSTR_PROF_SECT_START(INSTR_PROF_VNODES_SECT_NAME)
22 #define PROF_VNODES_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_VNODES_SECT_NAME)
24 /* Declare section start and stop symbols for various sections
25 * generated by compiler instrumentation.
27 extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY;
28 extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY;
29 extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY;
30 extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY;
31 extern char PROF_NAME_START COMPILER_RT_VISIBILITY;
32 extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY;
33 extern ValueProfNode PROF_VNODES_START COMPILER_RT_VISIBILITY;
34 extern ValueProfNode PROF_VNODES_STOP COMPILER_RT_VISIBILITY;
36 /* Add dummy data to ensure the section is always created. */
38 __prof_data_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_DATA_SECT_NAME_STR);
40 __prof_cnts_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_CNTS_SECT_NAME_STR);
41 char __prof_nms_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_NAME_SECT_NAME_STR);
42 ValueProfNode __prof_vnodes_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_VNODES_SECT_NAME_STR);
44 COMPILER_RT_VISIBILITY const __llvm_profile_data *
45 __llvm_profile_begin_data(void) {
46 return &PROF_DATA_START;
48 COMPILER_RT_VISIBILITY const __llvm_profile_data *
49 __llvm_profile_end_data(void) {
50 return &PROF_DATA_STOP;
52 COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) {
53 return &PROF_NAME_START;
55 COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) {
56 return &PROF_NAME_STOP;
58 COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) {
59 return &PROF_CNTS_START;
61 COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_end_counters(void) {
62 return &PROF_CNTS_STOP;
65 COMPILER_RT_VISIBILITY ValueProfNode *
66 __llvm_profile_begin_vnodes(void) {
67 return &PROF_VNODES_START;
69 COMPILER_RT_VISIBILITY ValueProfNode *__llvm_profile_end_vnodes(void) {
70 return &PROF_VNODES_STOP;
72 COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &PROF_VNODES_START;
73 COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &PROF_VNODES_STOP;