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