1 /*===- InstrProfilingPlatformLinux.c - Profile data Linux platform ------===*\ 2 |* 3 |* The LLVM Compiler Infrastructure 4 |* 5 |* This file is distributed under the University of Illinois Open Source 6 |* License. See LICENSE.TXT for details. 7 |* 8 \*===----------------------------------------------------------------------===*/ 9 10 #if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \ 11 (defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) 12 13 #include <stdlib.h> 14 15 #include "InstrProfiling.h" 16 17 #define PROF_DATA_START INSTR_PROF_SECT_START(INSTR_PROF_DATA_SECT_NAME) 18 #define PROF_DATA_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_DATA_SECT_NAME) 19 #define PROF_NAME_START INSTR_PROF_SECT_START(INSTR_PROF_NAME_SECT_NAME) 20 #define PROF_NAME_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_NAME_SECT_NAME) 21 #define PROF_CNTS_START INSTR_PROF_SECT_START(INSTR_PROF_CNTS_SECT_NAME) 22 #define PROF_CNTS_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_CNTS_SECT_NAME) 23 #define PROF_VNODES_START INSTR_PROF_SECT_START(INSTR_PROF_VNODES_SECT_NAME) 24 #define PROF_VNODES_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_VNODES_SECT_NAME) 25 26 /* Declare section start and stop symbols for various sections 27 * generated by compiler instrumentation. 28 */ 29 extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY; 30 extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY; 31 extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY; 32 extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY; 33 extern char PROF_NAME_START COMPILER_RT_VISIBILITY; 34 extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY; 35 extern ValueProfNode PROF_VNODES_START COMPILER_RT_VISIBILITY; 36 extern ValueProfNode PROF_VNODES_STOP COMPILER_RT_VISIBILITY; 37 38 /* Add dummy data to ensure the section is always created. */ 39 __llvm_profile_data 40 __prof_data_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_DATA_SECT_NAME_STR); 41 uint64_t 42 __prof_cnts_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_CNTS_SECT_NAME_STR); 43 char __prof_nms_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_NAME_SECT_NAME_STR); 44 ValueProfNode __prof_vnodes_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_VNODES_SECT_NAME_STR); 45 46 COMPILER_RT_VISIBILITY const __llvm_profile_data * __llvm_profile_begin_data(void)47__llvm_profile_begin_data(void) { 48 return &PROF_DATA_START; 49 } 50 COMPILER_RT_VISIBILITY const __llvm_profile_data * __llvm_profile_end_data(void)51__llvm_profile_end_data(void) { 52 return &PROF_DATA_STOP; 53 } __llvm_profile_begin_names(void)54COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) { 55 return &PROF_NAME_START; 56 } __llvm_profile_end_names(void)57COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) { 58 return &PROF_NAME_STOP; 59 } __llvm_profile_begin_counters(void)60COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) { 61 return &PROF_CNTS_START; 62 } __llvm_profile_end_counters(void)63COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_end_counters(void) { 64 return &PROF_CNTS_STOP; 65 } 66 67 COMPILER_RT_VISIBILITY ValueProfNode * __llvm_profile_begin_vnodes(void)68__llvm_profile_begin_vnodes(void) { 69 return &PROF_VNODES_START; 70 } __llvm_profile_end_vnodes(void)71COMPILER_RT_VISIBILITY ValueProfNode *__llvm_profile_end_vnodes(void) { 72 return &PROF_VNODES_STOP; 73 } 74 COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &PROF_VNODES_START; 75 COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &PROF_VNODES_STOP; 76 77 #endif 78