1/*===- InstrProfilingPlatformDarwin.c - Profile data on Darwin ------------===*\
2|*
3|* 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
6|*
7\*===----------------------------------------------------------------------===*/
8
9// Note: This is linked into the Darwin kernel, and must remain compatible
10// with freestanding compilation. See `darwin_add_builtin_libraries`.
11
12#include "InstrProfiling.h"
13#include "InstrProfilingInternal.h"
14
15#if defined(__APPLE__)
16/* Use linker magic to find the bounds of the Data section. */
17COMPILER_RT_VISIBILITY
18extern __llvm_profile_data
19 DataStart __asm("section$start$__DATA$" INSTR_PROF_DATA_SECT_NAME);
20COMPILER_RT_VISIBILITY
21extern __llvm_profile_data
22 DataEnd __asm("section$end$__DATA$" INSTR_PROF_DATA_SECT_NAME);
23COMPILER_RT_VISIBILITY
24extern char
25 NamesStart __asm("section$start$__DATA$" INSTR_PROF_NAME_SECT_NAME);
26COMPILER_RT_VISIBILITY
27extern char NamesEnd __asm("section$end$__DATA$" INSTR_PROF_NAME_SECT_NAME);
28COMPILER_RT_VISIBILITY
29extern char
30 CountersStart __asm("section$start$__DATA$" INSTR_PROF_CNTS_SECT_NAME);
31COMPILER_RT_VISIBILITY
32extern char CountersEnd __asm("section$end$__DATA$" INSTR_PROF_CNTS_SECT_NAME);
33COMPILER_RT_VISIBILITY
34extern char
35 BitmapStart __asm("section$start$__DATA$" INSTR_PROF_BITS_SECT_NAME);
36COMPILER_RT_VISIBILITY
37extern char BitmapEnd __asm("section$end$__DATA$" INSTR_PROF_BITS_SECT_NAME);
38COMPILER_RT_VISIBILITY
39extern VTableProfData
40 VTableProfStart __asm("section$start$__DATA$" INSTR_PROF_VTAB_SECT_NAME);
41COMPILER_RT_VISIBILITY
42extern VTableProfData
43 VTableProfEnd __asm("section$end$__DATA$" INSTR_PROF_VTAB_SECT_NAME);
44COMPILER_RT_VISIBILITY
45extern char
46 VNameStart __asm("section$start$__DATA$" INSTR_PROF_VNAME_SECT_NAME);
47COMPILER_RT_VISIBILITY
48extern char VNameEnd __asm("section$end$__DATA$" INSTR_PROF_VNAME_SECT_NAME);
49COMPILER_RT_VISIBILITY
50extern uint32_t
51 OrderFileStart __asm("section$start$__DATA$" INSTR_PROF_ORDERFILE_SECT_NAME);
52
53COMPILER_RT_VISIBILITY
54extern ValueProfNode
55 VNodesStart __asm("section$start$__DATA$" INSTR_PROF_VNODES_SECT_NAME);
56COMPILER_RT_VISIBILITY
57extern ValueProfNode
58 VNodesEnd __asm("section$end$__DATA$" INSTR_PROF_VNODES_SECT_NAME);
59
60COMPILER_RT_VISIBILITY
61const __llvm_profile_data *__llvm_profile_begin_data(void) {
62 return &DataStart;
63}
64COMPILER_RT_VISIBILITY
65const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
66COMPILER_RT_VISIBILITY
67const char *__llvm_profile_begin_names(void) { return &NamesStart; }
68COMPILER_RT_VISIBILITY
69const char *__llvm_profile_end_names(void) { return &NamesEnd; }
70COMPILER_RT_VISIBILITY
71char *__llvm_profile_begin_counters(void) { return &CountersStart; }
72COMPILER_RT_VISIBILITY
73char *__llvm_profile_end_counters(void) { return &CountersEnd; }
74COMPILER_RT_VISIBILITY
75char *__llvm_profile_begin_bitmap(void) { return &BitmapStart; }
76COMPILER_RT_VISIBILITY
77char *__llvm_profile_end_bitmap(void) { return &BitmapEnd; }
78COMPILER_RT_VISIBILITY
79const VTableProfData *__llvm_profile_begin_vtables(void) {
80 return &VTableProfStart;
81}
82COMPILER_RT_VISIBILITY
83const VTableProfData *__llvm_profile_end_vtables(void) {
84 return &VTableProfEnd;
85}
86COMPILER_RT_VISIBILITY
87const char *__llvm_profile_begin_vtabnames(void) { return &VNameStart; }
88COMPILER_RT_VISIBILITY
89const char *__llvm_profile_end_vtabnames(void) { return &VNameEnd; }
90COMPILER_RT_VISIBILITY
91uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; }
92
93COMPILER_RT_VISIBILITY
94ValueProfNode *__llvm_profile_begin_vnodes(void) {
95 return &VNodesStart;
96}
97COMPILER_RT_VISIBILITY
98ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; }
99
100COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &VNodesStart;
101COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &VNodesEnd;
102
103COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
104 return 0;
105}
106
107#endif
108

source code of compiler-rt/lib/profile/InstrProfilingPlatformDarwin.c