xref: /openbsd-src/gnu/llvm/compiler-rt/lib/profile/InstrProfilingPlatformDarwin.c (revision 810390e339a5425391477d5d41c78d7cab2424ac)
13cab2bb3Spatrick /*===- InstrProfilingPlatformDarwin.c - Profile data on Darwin ------------===*\
23cab2bb3Spatrick |*
33cab2bb3Spatrick |* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
43cab2bb3Spatrick |* See https://llvm.org/LICENSE.txt for license information.
53cab2bb3Spatrick |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
63cab2bb3Spatrick |*
73cab2bb3Spatrick \*===----------------------------------------------------------------------===*/
83cab2bb3Spatrick 
9d89ec533Spatrick // Note: This is linked into the Darwin kernel, and must remain compatible
10d89ec533Spatrick // with freestanding compilation. See `darwin_add_builtin_libraries`.
11d89ec533Spatrick 
123cab2bb3Spatrick #include "InstrProfiling.h"
13d89ec533Spatrick #include "InstrProfilingInternal.h"
143cab2bb3Spatrick 
153cab2bb3Spatrick #if defined(__APPLE__)
163cab2bb3Spatrick /* Use linker magic to find the bounds of the Data section. */
173cab2bb3Spatrick COMPILER_RT_VISIBILITY
183cab2bb3Spatrick extern __llvm_profile_data
193cab2bb3Spatrick     DataStart __asm("section$start$__DATA$" INSTR_PROF_DATA_SECT_NAME);
203cab2bb3Spatrick COMPILER_RT_VISIBILITY
213cab2bb3Spatrick extern __llvm_profile_data
223cab2bb3Spatrick     DataEnd __asm("section$end$__DATA$" INSTR_PROF_DATA_SECT_NAME);
233cab2bb3Spatrick COMPILER_RT_VISIBILITY
243cab2bb3Spatrick extern char
253cab2bb3Spatrick     NamesStart __asm("section$start$__DATA$" INSTR_PROF_NAME_SECT_NAME);
263cab2bb3Spatrick COMPILER_RT_VISIBILITY
273cab2bb3Spatrick extern char NamesEnd __asm("section$end$__DATA$" INSTR_PROF_NAME_SECT_NAME);
283cab2bb3Spatrick COMPILER_RT_VISIBILITY
29*810390e3Srobert extern char
303cab2bb3Spatrick     CountersStart __asm("section$start$__DATA$" INSTR_PROF_CNTS_SECT_NAME);
313cab2bb3Spatrick COMPILER_RT_VISIBILITY
32*810390e3Srobert extern char CountersEnd __asm("section$end$__DATA$" INSTR_PROF_CNTS_SECT_NAME);
333cab2bb3Spatrick COMPILER_RT_VISIBILITY
343cab2bb3Spatrick extern uint32_t
353cab2bb3Spatrick     OrderFileStart __asm("section$start$__DATA$" INSTR_PROF_ORDERFILE_SECT_NAME);
363cab2bb3Spatrick 
373cab2bb3Spatrick COMPILER_RT_VISIBILITY
383cab2bb3Spatrick extern ValueProfNode
393cab2bb3Spatrick     VNodesStart __asm("section$start$__DATA$" INSTR_PROF_VNODES_SECT_NAME);
403cab2bb3Spatrick COMPILER_RT_VISIBILITY
413cab2bb3Spatrick extern ValueProfNode
423cab2bb3Spatrick     VNodesEnd __asm("section$end$__DATA$" INSTR_PROF_VNODES_SECT_NAME);
433cab2bb3Spatrick 
443cab2bb3Spatrick COMPILER_RT_VISIBILITY
__llvm_profile_begin_data(void)453cab2bb3Spatrick const __llvm_profile_data *__llvm_profile_begin_data(void) {
463cab2bb3Spatrick   return &DataStart;
473cab2bb3Spatrick }
483cab2bb3Spatrick COMPILER_RT_VISIBILITY
__llvm_profile_end_data(void)493cab2bb3Spatrick const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
503cab2bb3Spatrick COMPILER_RT_VISIBILITY
__llvm_profile_begin_names(void)513cab2bb3Spatrick const char *__llvm_profile_begin_names(void) { return &NamesStart; }
523cab2bb3Spatrick COMPILER_RT_VISIBILITY
__llvm_profile_end_names(void)533cab2bb3Spatrick const char *__llvm_profile_end_names(void) { return &NamesEnd; }
543cab2bb3Spatrick COMPILER_RT_VISIBILITY
__llvm_profile_begin_counters(void)55*810390e3Srobert char *__llvm_profile_begin_counters(void) { return &CountersStart; }
563cab2bb3Spatrick COMPILER_RT_VISIBILITY
__llvm_profile_end_counters(void)57*810390e3Srobert char *__llvm_profile_end_counters(void) { return &CountersEnd; }
583cab2bb3Spatrick COMPILER_RT_VISIBILITY
__llvm_profile_begin_orderfile(void)593cab2bb3Spatrick uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; }
603cab2bb3Spatrick 
613cab2bb3Spatrick COMPILER_RT_VISIBILITY
__llvm_profile_begin_vnodes(void)623cab2bb3Spatrick ValueProfNode *__llvm_profile_begin_vnodes(void) {
633cab2bb3Spatrick   return &VNodesStart;
643cab2bb3Spatrick }
653cab2bb3Spatrick COMPILER_RT_VISIBILITY
__llvm_profile_end_vnodes(void)663cab2bb3Spatrick ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; }
673cab2bb3Spatrick 
683cab2bb3Spatrick COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &VNodesStart;
693cab2bb3Spatrick COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &VNodesEnd;
70d89ec533Spatrick 
__llvm_write_binary_ids(ProfDataWriter * Writer)71d89ec533Spatrick COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
72d89ec533Spatrick   return 0;
73d89ec533Spatrick }
74d89ec533Spatrick 
753cab2bb3Spatrick #endif
76