]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
New upstream version 1.12.0+dfsg1
[rustc.git] / src / compiler-rt / lib / profile / InstrProfilingPlatformLinux.c
CommitLineData
92a42be0
SL
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
3157f602
XL
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)
5bcae85e
SL
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)
92a42be0 23
3157f602
XL
24/* Declare section start and stop symbols for various sections
25 * generated by compiler instrumentation.
26 */
27extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY;
28extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY;
29extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY;
30extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY;
31extern char PROF_NAME_START COMPILER_RT_VISIBILITY;
32extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY;
5bcae85e
SL
33extern ValueProfNode PROF_VNODES_START COMPILER_RT_VISIBILITY;
34extern ValueProfNode PROF_VNODES_STOP COMPILER_RT_VISIBILITY;
3157f602
XL
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);
39uint64_t
40 __prof_cnts_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_CNTS_SECT_NAME_STR);
41char __prof_nms_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_NAME_SECT_NAME_STR);
5bcae85e 42ValueProfNode __prof_vnodes_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_VNODES_SECT_NAME_STR);
3157f602
XL
43
44COMPILER_RT_VISIBILITY const __llvm_profile_data *
92a42be0 45__llvm_profile_begin_data(void) {
3157f602 46 return &PROF_DATA_START;
92a42be0 47}
3157f602 48COMPILER_RT_VISIBILITY const __llvm_profile_data *
92a42be0 49__llvm_profile_end_data(void) {
3157f602 50 return &PROF_DATA_STOP;
92a42be0 51}
3157f602
XL
52COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) {
53 return &PROF_NAME_START;
92a42be0 54}
3157f602
XL
55COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) {
56 return &PROF_NAME_STOP;
92a42be0 57}
3157f602
XL
58COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) {
59 return &PROF_CNTS_START;
92a42be0 60}
3157f602
XL
61COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_end_counters(void) {
62 return &PROF_CNTS_STOP;
92a42be0 63}
5bcae85e
SL
64
65COMPILER_RT_VISIBILITY ValueProfNode *
66__llvm_profile_begin_vnodes(void) {
67 return &PROF_VNODES_START;
68}
69COMPILER_RT_VISIBILITY ValueProfNode *__llvm_profile_end_vnodes(void) {
70 return &PROF_VNODES_STOP;
71}
72COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &PROF_VNODES_START;
73COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &PROF_VNODES_STOP;
74
92a42be0 75#endif