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