blob: 89f1ab4cfedab3c2a2074431b8e7aad6bcceb94e [file] [log] [blame]
Xinliang David Lif556a7e2015-10-13 18:40:00 +00001/*===- 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
Vedant Kumard7c93362017-12-14 19:01:04 +000010#if defined(__linux__) || defined(__FreeBSD__) || \
11 (defined(__sun__) && defined(__svr4__))
Vedant Kumar5b0d5b42017-12-14 18:43:14 +000012
Vedant Kumare8e85992017-12-14 18:50:13 +000013#include <stdlib.h>
14
Vedant Kumard7c93362017-12-14 19:01:04 +000015#include "InstrProfiling.h"
16
Xinliang David Li7c7f1202015-11-23 18:56:03 +000017#define PROF_DATA_START INSTR_PROF_SECT_START(INSTR_PROF_DATA_SECT_NAME)
18#define PROF_DATA_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_DATA_SECT_NAME)
19#define PROF_NAME_START INSTR_PROF_SECT_START(INSTR_PROF_NAME_SECT_NAME)
20#define PROF_NAME_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_NAME_SECT_NAME)
21#define PROF_CNTS_START INSTR_PROF_SECT_START(INSTR_PROF_CNTS_SECT_NAME)
22#define PROF_CNTS_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_CNTS_SECT_NAME)
Xinliang David Li4e8754d2016-05-21 22:55:45 +000023#define PROF_VNODES_START INSTR_PROF_SECT_START(INSTR_PROF_VNODES_SECT_NAME)
24#define PROF_VNODES_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_VNODES_SECT_NAME)
Xinliang David Li7c7f1202015-11-23 18:56:03 +000025
26/* Declare section start and stop symbols for various sections
27 * generated by compiler instrumentation.
28 */
Xinliang David Liabfd5532015-12-16 03:29:15 +000029extern __llvm_profile_data PROF_DATA_START COMPILER_RT_VISIBILITY;
30extern __llvm_profile_data PROF_DATA_STOP COMPILER_RT_VISIBILITY;
31extern uint64_t PROF_CNTS_START COMPILER_RT_VISIBILITY;
32extern uint64_t PROF_CNTS_STOP COMPILER_RT_VISIBILITY;
33extern char PROF_NAME_START COMPILER_RT_VISIBILITY;
34extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY;
Xinliang David Li4e8754d2016-05-21 22:55:45 +000035extern ValueProfNode PROF_VNODES_START COMPILER_RT_VISIBILITY;
36extern ValueProfNode PROF_VNODES_STOP COMPILER_RT_VISIBILITY;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000037
Xinliang David Lib6c81d22015-11-13 22:33:07 +000038/* Add dummy data to ensure the section is always created. */
Xinliang David Li7c7f1202015-11-23 18:56:03 +000039__llvm_profile_data
Xinliang David Liabfd5532015-12-16 03:29:15 +000040 __prof_data_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_DATA_SECT_NAME_STR);
41uint64_t
42 __prof_cnts_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_CNTS_SECT_NAME_STR);
43char __prof_nms_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_NAME_SECT_NAME_STR);
Xinliang David Li4e8754d2016-05-21 22:55:45 +000044ValueProfNode __prof_vnodes_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_VNODES_SECT_NAME_STR);
Xinliang David Lib6c81d22015-11-13 22:33:07 +000045
Xinliang David Liabfd5532015-12-16 03:29:15 +000046COMPILER_RT_VISIBILITY const __llvm_profile_data *
Xinliang David Lif556a7e2015-10-13 18:40:00 +000047__llvm_profile_begin_data(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000048 return &PROF_DATA_START;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000049}
Xinliang David Liabfd5532015-12-16 03:29:15 +000050COMPILER_RT_VISIBILITY const __llvm_profile_data *
Xinliang David Lif556a7e2015-10-13 18:40:00 +000051__llvm_profile_end_data(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000052 return &PROF_DATA_STOP;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000053}
Xinliang David Liabfd5532015-12-16 03:29:15 +000054COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000055 return &PROF_NAME_START;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000056}
Xinliang David Liabfd5532015-12-16 03:29:15 +000057COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000058 return &PROF_NAME_STOP;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000059}
Xinliang David Liabfd5532015-12-16 03:29:15 +000060COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000061 return &PROF_CNTS_START;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000062}
Xinliang David Liabfd5532015-12-16 03:29:15 +000063COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_end_counters(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000064 return &PROF_CNTS_STOP;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000065}
Xinliang David Li4e8754d2016-05-21 22:55:45 +000066
67COMPILER_RT_VISIBILITY ValueProfNode *
68__llvm_profile_begin_vnodes(void) {
69 return &PROF_VNODES_START;
70}
Xinliang David Li7b413932016-05-22 16:36:03 +000071COMPILER_RT_VISIBILITY ValueProfNode *__llvm_profile_end_vnodes(void) {
Xinliang David Li4e8754d2016-05-21 22:55:45 +000072 return &PROF_VNODES_STOP;
73}
Xinliang David Li7b413932016-05-22 16:36:03 +000074COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &PROF_VNODES_START;
75COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &PROF_VNODES_STOP;
76
Xinliang David Lif556a7e2015-10-13 18:40:00 +000077#endif