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