InstrProfilingPlatformLinux.c revision 302408
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#include "InstrProfiling.h" 11 12#if defined(__linux__) || defined(__FreeBSD__) 13#include <stdlib.h> 14 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 22/* Declare section start and stop symbols for various sections 23 * generated by compiler instrumentation. 24 */ 25extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY; 26extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY; 27extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY; 28extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY; 29extern char PROF_NAME_START COMPILER_RT_VISIBILITY; 30extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY; 31 32/* Add dummy data to ensure the section is always created. */ 33__llvm_profile_data 34 __prof_data_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_DATA_SECT_NAME_STR); 35uint64_t 36 __prof_cnts_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_CNTS_SECT_NAME_STR); 37char __prof_nms_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_NAME_SECT_NAME_STR); 38 39COMPILER_RT_VISIBILITY const __llvm_profile_data * 40__llvm_profile_begin_data(void) { 41 return &PROF_DATA_START; 42} 43COMPILER_RT_VISIBILITY const __llvm_profile_data * 44__llvm_profile_end_data(void) { 45 return &PROF_DATA_STOP; 46} 47COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) { 48 return &PROF_NAME_START; 49} 50COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) { 51 return &PROF_NAME_STOP; 52} 53COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) { 54 return &PROF_CNTS_START; 55} 56COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_end_counters(void) { 57 return &PROF_CNTS_STOP; 58} 59#endif 60