Home | History | Annotate | Download | only in profile
      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  */
     25 extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY;
     26 extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY;
     27 extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY;
     28 extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY;
     29 extern char PROF_NAME_START COMPILER_RT_VISIBILITY;
     30 extern 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);
     35 uint64_t
     36     __prof_cnts_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_CNTS_SECT_NAME_STR);
     37 char __prof_nms_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_NAME_SECT_NAME_STR);
     38 
     39 COMPILER_RT_VISIBILITY const __llvm_profile_data *
     40 __llvm_profile_begin_data(void) {
     41   return &PROF_DATA_START;
     42 }
     43 COMPILER_RT_VISIBILITY const __llvm_profile_data *
     44 __llvm_profile_end_data(void) {
     45   return &PROF_DATA_STOP;
     46 }
     47 COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) {
     48   return &PROF_NAME_START;
     49 }
     50 COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) {
     51   return &PROF_NAME_STOP;
     52 }
     53 COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) {
     54   return &PROF_CNTS_START;
     55 }
     56 COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_end_counters(void) {
     57   return &PROF_CNTS_STOP;
     58 }
     59 #endif
     60