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 2904eeddc0SDimitry Andric extern char 300b57cec5SDimitry Andric CountersStart __asm("section$start$__DATA$" INSTR_PROF_CNTS_SECT_NAME); 310b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 3204eeddc0SDimitry Andric extern char CountersEnd __asm("section$end$__DATA$" INSTR_PROF_CNTS_SECT_NAME); 330b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 34*5f757f3fSDimitry Andric extern char 35*5f757f3fSDimitry Andric BitmapStart __asm("section$start$__DATA$" INSTR_PROF_BITS_SECT_NAME); 36*5f757f3fSDimitry Andric COMPILER_RT_VISIBILITY 37*5f757f3fSDimitry Andric extern char BitmapEnd __asm("section$end$__DATA$" INSTR_PROF_BITS_SECT_NAME); 38*5f757f3fSDimitry Andric COMPILER_RT_VISIBILITY 390b57cec5SDimitry Andric extern uint32_t 400b57cec5SDimitry Andric OrderFileStart __asm("section$start$__DATA$" INSTR_PROF_ORDERFILE_SECT_NAME); 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 430b57cec5SDimitry Andric extern ValueProfNode 440b57cec5SDimitry Andric VNodesStart __asm("section$start$__DATA$" INSTR_PROF_VNODES_SECT_NAME); 450b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 460b57cec5SDimitry Andric extern ValueProfNode 470b57cec5SDimitry Andric VNodesEnd __asm("section$end$__DATA$" INSTR_PROF_VNODES_SECT_NAME); 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 500b57cec5SDimitry Andric const __llvm_profile_data *__llvm_profile_begin_data(void) { 510b57cec5SDimitry Andric return &DataStart; 520b57cec5SDimitry Andric } 530b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 540b57cec5SDimitry Andric const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; } 550b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 560b57cec5SDimitry Andric const char *__llvm_profile_begin_names(void) { return &NamesStart; } 570b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 580b57cec5SDimitry Andric const char *__llvm_profile_end_names(void) { return &NamesEnd; } 590b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 6004eeddc0SDimitry Andric char *__llvm_profile_begin_counters(void) { return &CountersStart; } 610b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 6204eeddc0SDimitry Andric char *__llvm_profile_end_counters(void) { return &CountersEnd; } 630b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 64*5f757f3fSDimitry Andric char *__llvm_profile_begin_bitmap(void) { return &BitmapStart; } 65*5f757f3fSDimitry Andric COMPILER_RT_VISIBILITY 66*5f757f3fSDimitry Andric char *__llvm_profile_end_bitmap(void) { return &BitmapEnd; } 67*5f757f3fSDimitry Andric COMPILER_RT_VISIBILITY 680b57cec5SDimitry Andric uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; } 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 710b57cec5SDimitry Andric ValueProfNode *__llvm_profile_begin_vnodes(void) { 720b57cec5SDimitry Andric return &VNodesStart; 730b57cec5SDimitry Andric } 740b57cec5SDimitry Andric COMPILER_RT_VISIBILITY 750b57cec5SDimitry Andric ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; } 760b57cec5SDimitry Andric 770b57cec5SDimitry Andric COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &VNodesStart; 780b57cec5SDimitry Andric COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &VNodesEnd; 79fe6060f1SDimitry Andric 80fe6060f1SDimitry Andric COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) { 81fe6060f1SDimitry Andric return 0; 82fe6060f1SDimitry Andric } 83fe6060f1SDimitry Andric 840b57cec5SDimitry Andric #endif 85