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" 13*fe6060f1SDimitry 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 290b57cec5SDimitry Andric extern uint64_t 300b57cec5SDimitry Andric CountersStart __asm("section$start$__DATA$" INSTR_PROF_CNTS_SECT_NAME); 310b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 320b57cec5SDimitry Andric extern uint64_t 330b57cec5SDimitry Andric CountersEnd __asm("section$end$__DATA$" INSTR_PROF_CNTS_SECT_NAME); 340b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 350b57cec5SDimitry Andric extern uint32_t 360b57cec5SDimitry Andric OrderFileStart __asm("section$start$__DATA$" INSTR_PROF_ORDERFILE_SECT_NAME); 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 390b57cec5SDimitry Andric extern ValueProfNode 400b57cec5SDimitry Andric VNodesStart __asm("section$start$__DATA$" INSTR_PROF_VNODES_SECT_NAME); 410b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 420b57cec5SDimitry Andric extern ValueProfNode 430b57cec5SDimitry Andric VNodesEnd __asm("section$end$__DATA$" INSTR_PROF_VNODES_SECT_NAME); 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 460b57cec5SDimitry Andric const __llvm_profile_data *__llvm_profile_begin_data(void) { 470b57cec5SDimitry Andric return &DataStart; 480b57cec5SDimitry Andric } 490b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 500b57cec5SDimitry Andric const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; } 510b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 520b57cec5SDimitry Andric const char *__llvm_profile_begin_names(void) { return &NamesStart; } 530b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 540b57cec5SDimitry Andric const char *__llvm_profile_end_names(void) { return &NamesEnd; } 550b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 560b57cec5SDimitry Andric uint64_t *__llvm_profile_begin_counters(void) { return &CountersStart; } 570b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 580b57cec5SDimitry Andric uint64_t *__llvm_profile_end_counters(void) { return &CountersEnd; } 590b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 600b57cec5SDimitry Andric uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; } 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 630b57cec5SDimitry Andric ValueProfNode *__llvm_profile_begin_vnodes(void) { 640b57cec5SDimitry Andric return &VNodesStart; 650b57cec5SDimitry Andric } 660b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 670b57cec5SDimitry Andric ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; } 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &VNodesStart; 700b57cec5SDimitry Andric COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &VNodesEnd; 71*fe6060f1SDimitry Andric 72*fe6060f1SDimitry Andric COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) { 73*fe6060f1SDimitry Andric return 0; 74*fe6060f1SDimitry Andric } 75*fe6060f1SDimitry Andric 760b57cec5SDimitry Andric #endif 77