10b57cec5SDimitry Andric /*===- InstrProfilingPlatformDarwin.c - Profile data on Darwin ------------===*\ 20b57cec5SDimitry Andric |* 30b57cec5SDimitry Andric |* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric |* See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric |* 70b57cec5SDimitry Andric \*===----------------------------------------------------------------------===*/ 80b57cec5SDimitry Andric 9e8d8bef9SDimitry Andric // Note: This is linked into the Darwin kernel, and must remain compatible 10e8d8bef9SDimitry Andric // with freestanding compilation. See `darwin_add_builtin_libraries`. 11e8d8bef9SDimitry Andric 120b57cec5SDimitry Andric #include "InstrProfiling.h" 13fe6060f1SDimitry Andric #include "InstrProfilingInternal.h" 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric #if defined(__APPLE__) 160b57cec5SDimitry Andric /* Use linker magic to find the bounds of the Data section. */ 170b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 180b57cec5SDimitry Andric extern __llvm_profile_data 190b57cec5SDimitry Andric DataStart __asm("section$start$__DATA$" INSTR_PROF_DATA_SECT_NAME); 200b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 210b57cec5SDimitry Andric extern __llvm_profile_data 220b57cec5SDimitry Andric DataEnd __asm("section$end$__DATA$" INSTR_PROF_DATA_SECT_NAME); 230b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 240b57cec5SDimitry Andric extern char 250b57cec5SDimitry Andric NamesStart __asm("section$start$__DATA$" INSTR_PROF_NAME_SECT_NAME); 260b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 270b57cec5SDimitry Andric extern char NamesEnd __asm("section$end$__DATA$" INSTR_PROF_NAME_SECT_NAME); 280b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 29*04eeddc0SDimitry Andric extern char 300b57cec5SDimitry Andric CountersStart __asm("section$start$__DATA$" INSTR_PROF_CNTS_SECT_NAME); 310b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 32*04eeddc0SDimitry Andric extern char CountersEnd __asm("section$end$__DATA$" INSTR_PROF_CNTS_SECT_NAME); 330b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 340b57cec5SDimitry Andric extern uint32_t 350b57cec5SDimitry Andric OrderFileStart __asm("section$start$__DATA$" INSTR_PROF_ORDERFILE_SECT_NAME); 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 380b57cec5SDimitry Andric extern ValueProfNode 390b57cec5SDimitry Andric VNodesStart __asm("section$start$__DATA$" INSTR_PROF_VNODES_SECT_NAME); 400b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 410b57cec5SDimitry Andric extern ValueProfNode 420b57cec5SDimitry Andric VNodesEnd __asm("section$end$__DATA$" INSTR_PROF_VNODES_SECT_NAME); 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 450b57cec5SDimitry Andric const __llvm_profile_data *__llvm_profile_begin_data(void) { 460b57cec5SDimitry Andric return &DataStart; 470b57cec5SDimitry Andric } 480b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 490b57cec5SDimitry Andric const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; } 500b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 510b57cec5SDimitry Andric const char *__llvm_profile_begin_names(void) { return &NamesStart; } 520b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 530b57cec5SDimitry Andric const char *__llvm_profile_end_names(void) { return &NamesEnd; } 540b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 55*04eeddc0SDimitry Andric char *__llvm_profile_begin_counters(void) { return &CountersStart; } 560b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 57*04eeddc0SDimitry Andric char *__llvm_profile_end_counters(void) { return &CountersEnd; } 580b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 590b57cec5SDimitry Andric uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; } 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 620b57cec5SDimitry Andric ValueProfNode *__llvm_profile_begin_vnodes(void) { 630b57cec5SDimitry Andric return &VNodesStart; 640b57cec5SDimitry Andric } 650b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 660b57cec5SDimitry Andric ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; } 670b57cec5SDimitry Andric 680b57cec5SDimitry Andric COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &VNodesStart; 690b57cec5SDimitry Andric COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &VNodesEnd; 70fe6060f1SDimitry Andric 71fe6060f1SDimitry Andric COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) { 72fe6060f1SDimitry Andric return 0; 73fe6060f1SDimitry Andric } 74fe6060f1SDimitry Andric 750b57cec5SDimitry Andric #endif 76