blob: becfe1fd9f5ad8e3094aa57dadd6d786742c7b40 [file] [log] [blame]
Xinliang David Lif556a7e2015-10-13 18:40:00 +00001/*===- InstrProfilingPlatformLinux.c - Profile data Linux platform ------===*\
2|*
Chandler Carruth2946cd72019-01-19 08:50:56 +00003|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4|* See https://llvm.org/LICENSE.txt for license information.
5|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Xinliang David Lif556a7e2015-10-13 18:40:00 +00006|*
7\*===----------------------------------------------------------------------===*/
8
Petr Hosek47e5fcb2018-07-25 03:01:35 +00009#if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
Kamil Rytarowskiedbe2b32018-12-22 06:56:19 +000010 (defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__)
Vedant Kumar5b0d5b42017-12-14 18:43:14 +000011
Vedant Kumare8e85992017-12-14 18:50:13 +000012#include <stdlib.h>
13
Vedant Kumard7c93362017-12-14 19:01:04 +000014#include "InstrProfiling.h"
15
Reid Kleckner987d3312019-02-08 19:03:50 +000016#define PROF_DATA_START INSTR_PROF_SECT_START(INSTR_PROF_DATA_COMMON)
17#define PROF_DATA_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_DATA_COMMON)
18#define PROF_NAME_START INSTR_PROF_SECT_START(INSTR_PROF_NAME_COMMON)
19#define PROF_NAME_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_NAME_COMMON)
20#define PROF_CNTS_START INSTR_PROF_SECT_START(INSTR_PROF_CNTS_COMMON)
21#define PROF_CNTS_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_CNTS_COMMON)
Manman Rene73ae9a2019-03-08 15:30:56 +000022#define PROF_ORDERFILE_START INSTR_PROF_SECT_START(INSTR_PROF_ORDERFILE_COMMON)
Reid Kleckner987d3312019-02-08 19:03:50 +000023#define PROF_VNODES_START INSTR_PROF_SECT_START(INSTR_PROF_VNODES_COMMON)
24#define PROF_VNODES_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_VNODES_COMMON)
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;
Manman Rene73ae9a2019-03-08 15:30:56 +000033extern uint32_t PROF_ORDERFILE_START COMPILER_RT_VISIBILITY;
Xinliang David Liabfd5532015-12-16 03:29:15 +000034extern char PROF_NAME_START COMPILER_RT_VISIBILITY;
35extern char PROF_NAME_STOP COMPILER_RT_VISIBILITY;
Xinliang David Li4e8754d2016-05-21 22:55:45 +000036extern ValueProfNode PROF_VNODES_START COMPILER_RT_VISIBILITY;
37extern ValueProfNode PROF_VNODES_STOP COMPILER_RT_VISIBILITY;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000038
Xinliang David Lib6c81d22015-11-13 22:33:07 +000039/* Add dummy data to ensure the section is always created. */
Xinliang David Li7c7f1202015-11-23 18:56:03 +000040__llvm_profile_data
Reid Kleckner987d3312019-02-08 19:03:50 +000041 __prof_data_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_DATA_SECT_NAME);
Xinliang David Liabfd5532015-12-16 03:29:15 +000042uint64_t
Reid Kleckner987d3312019-02-08 19:03:50 +000043 __prof_cnts_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_CNTS_SECT_NAME);
Manman Rene73ae9a2019-03-08 15:30:56 +000044uint32_t
45 __prof_orderfile_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_ORDERFILE_SECT_NAME);
Reid Kleckner987d3312019-02-08 19:03:50 +000046char __prof_nms_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_NAME_SECT_NAME);
47ValueProfNode __prof_vnodes_sect_data[0] COMPILER_RT_SECTION(INSTR_PROF_VNODES_SECT_NAME);
Xinliang David Lib6c81d22015-11-13 22:33:07 +000048
Xinliang David Liabfd5532015-12-16 03:29:15 +000049COMPILER_RT_VISIBILITY const __llvm_profile_data *
Xinliang David Lif556a7e2015-10-13 18:40:00 +000050__llvm_profile_begin_data(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000051 return &PROF_DATA_START;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000052}
Xinliang David Liabfd5532015-12-16 03:29:15 +000053COMPILER_RT_VISIBILITY const __llvm_profile_data *
Xinliang David Lif556a7e2015-10-13 18:40:00 +000054__llvm_profile_end_data(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000055 return &PROF_DATA_STOP;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000056}
Xinliang David Liabfd5532015-12-16 03:29:15 +000057COMPILER_RT_VISIBILITY const char *__llvm_profile_begin_names(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000058 return &PROF_NAME_START;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000059}
Xinliang David Liabfd5532015-12-16 03:29:15 +000060COMPILER_RT_VISIBILITY const char *__llvm_profile_end_names(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000061 return &PROF_NAME_STOP;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000062}
Xinliang David Liabfd5532015-12-16 03:29:15 +000063COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_begin_counters(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000064 return &PROF_CNTS_START;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000065}
Xinliang David Liabfd5532015-12-16 03:29:15 +000066COMPILER_RT_VISIBILITY uint64_t *__llvm_profile_end_counters(void) {
Xinliang David Li7c7f1202015-11-23 18:56:03 +000067 return &PROF_CNTS_STOP;
Xinliang David Lif556a7e2015-10-13 18:40:00 +000068}
Manman Rene73ae9a2019-03-08 15:30:56 +000069COMPILER_RT_VISIBILITY uint32_t *__llvm_profile_begin_orderfile(void) {
70 return &PROF_ORDERFILE_START;
71}
Xinliang David Li4e8754d2016-05-21 22:55:45 +000072
73COMPILER_RT_VISIBILITY ValueProfNode *
74__llvm_profile_begin_vnodes(void) {
75 return &PROF_VNODES_START;
76}
Xinliang David Li7b413932016-05-22 16:36:03 +000077COMPILER_RT_VISIBILITY ValueProfNode *__llvm_profile_end_vnodes(void) {
Xinliang David Li4e8754d2016-05-21 22:55:45 +000078 return &PROF_VNODES_STOP;
79}
Xinliang David Li7b413932016-05-22 16:36:03 +000080COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &PROF_VNODES_START;
81COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &PROF_VNODES_STOP;
82
Xinliang David Lif556a7e2015-10-13 18:40:00 +000083#endif