]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
MFV r323678: file 5.32
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / profile / InstrProfilingPlatformLinux.c
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 #define PROF_VNODES_START INSTR_PROF_SECT_START(INSTR_PROF_VNODES_SECT_NAME)
22 #define PROF_VNODES_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_VNODES_SECT_NAME)
23
24 /* Declare section start and stop symbols for various sections
25  * generated by compiler instrumentation.
26  */
27 extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY;
28 extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY;
29 extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY;
30 extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY;
31 extern char PROF_NAME_START COMPILER_RT_VISIBILITY;
32 extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY;
33 extern ValueProfNode PROF_VNODES_START COMPILER_RT_VISIBILITY;
34 extern ValueProfNode PROF_VNODES_STOP COMPILER_RT_VISIBILITY;
35
36 /* Add dummy data to ensure the section is always created. */
37 __llvm_profile_data
38     __prof_data_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_DATA_SECT_NAME_STR);
39 uint64_t
40     __prof_cnts_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_CNTS_SECT_NAME_STR);
41 char __prof_nms_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_NAME_SECT_NAME_STR);
42 ValueProfNode __prof_vnodes_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_VNODES_SECT_NAME_STR);
43
44 COMPILER_RT_VISIBILITY const __llvm_profile_data *
45 __llvm_profile_begin_data(void) {
46   return &PROF_DATA_START;
47 }
48 COMPILER_RT_VISIBILITY const __llvm_profile_data *
49 __llvm_profile_end_data(void) {
50   return &PROF_DATA_STOP;
51 }
52 COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) {
53   return &PROF_NAME_START;
54 }
55 COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) {
56   return &PROF_NAME_STOP;
57 }
58 COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) {
59   return &PROF_CNTS_START;
60 }
61 COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_end_counters(void) {
62   return &PROF_CNTS_STOP;
63 }
64
65 COMPILER_RT_VISIBILITY ValueProfNode *
66 __llvm_profile_begin_vnodes(void) {
67   return &PROF_VNODES_START;
68 }
69 COMPILER_RT_VISIBILITY ValueProfNode *__llvm_profile_end_vnodes(void) {
70   return &PROF_VNODES_STOP;
71 }
72 COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &PROF_VNODES_START;
73 COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &PROF_VNODES_STOP;
74
75 #endif