1*0b57cec5SDimitry Andric /*===- InstrProfilingPlatformDarwin.c - Profile data on Darwin ------------===*\ 2*0b57cec5SDimitry Andric |* 3*0b57cec5SDimitry Andric |* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric |* See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric |* 7*0b57cec5SDimitry Andric \*===----------------------------------------------------------------------===*/ 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "InstrProfiling.h" 10*0b57cec5SDimitry Andric 11*0b57cec5SDimitry Andric #if defined(__APPLE__) 12*0b57cec5SDimitry Andric /* Use linker magic to find the bounds of the Data section. */ 13*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 14*0b57cec5SDimitry Andric extern __llvm_profile_data 15*0b57cec5SDimitry Andric DataStart __asm("section$start$__DATA$" INSTR_PROF_DATA_SECT_NAME); 16*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 17*0b57cec5SDimitry Andric extern __llvm_profile_data 18*0b57cec5SDimitry Andric DataEnd __asm("section$end$__DATA$" INSTR_PROF_DATA_SECT_NAME); 19*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 20*0b57cec5SDimitry Andric extern char 21*0b57cec5SDimitry Andric NamesStart __asm("section$start$__DATA$" INSTR_PROF_NAME_SECT_NAME); 22*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 23*0b57cec5SDimitry Andric extern char NamesEnd __asm("section$end$__DATA$" INSTR_PROF_NAME_SECT_NAME); 24*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 25*0b57cec5SDimitry Andric extern uint64_t 26*0b57cec5SDimitry Andric CountersStart __asm("section$start$__DATA$" INSTR_PROF_CNTS_SECT_NAME); 27*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 28*0b57cec5SDimitry Andric extern uint64_t 29*0b57cec5SDimitry Andric CountersEnd __asm("section$end$__DATA$" INSTR_PROF_CNTS_SECT_NAME); 30*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 31*0b57cec5SDimitry Andric extern uint32_t 32*0b57cec5SDimitry Andric OrderFileStart __asm("section$start$__DATA$" INSTR_PROF_ORDERFILE_SECT_NAME); 33*0b57cec5SDimitry Andric 34*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 35*0b57cec5SDimitry Andric extern ValueProfNode 36*0b57cec5SDimitry Andric VNodesStart __asm("section$start$__DATA$" INSTR_PROF_VNODES_SECT_NAME); 37*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 38*0b57cec5SDimitry Andric extern ValueProfNode 39*0b57cec5SDimitry Andric VNodesEnd __asm("section$end$__DATA$" INSTR_PROF_VNODES_SECT_NAME); 40*0b57cec5SDimitry Andric 41*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 42*0b57cec5SDimitry Andric const __llvm_profile_data *__llvm_profile_begin_data(void) { 43*0b57cec5SDimitry Andric return &DataStart; 44*0b57cec5SDimitry Andric } 45*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 46*0b57cec5SDimitry Andric const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; } 47*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 48*0b57cec5SDimitry Andric const char *__llvm_profile_begin_names(void) { return &NamesStart; } 49*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 50*0b57cec5SDimitry Andric const char *__llvm_profile_end_names(void) { return &NamesEnd; } 51*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 52*0b57cec5SDimitry Andric uint64_t *__llvm_profile_begin_counters(void) { return &CountersStart; } 53*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 54*0b57cec5SDimitry Andric uint64_t *__llvm_profile_end_counters(void) { return &CountersEnd; } 55*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 56*0b57cec5SDimitry Andric uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; } 57*0b57cec5SDimitry Andric 58*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 59*0b57cec5SDimitry Andric ValueProfNode *__llvm_profile_begin_vnodes(void) { 60*0b57cec5SDimitry Andric return &VNodesStart; 61*0b57cec5SDimitry Andric } 62*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 63*0b57cec5SDimitry Andric ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; } 64*0b57cec5SDimitry Andric 65*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &VNodesStart; 66*0b57cec5SDimitry Andric COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &VNodesEnd; 67*0b57cec5SDimitry Andric #endif 68