| 1 | /*===- InstrProfilingPlatformDarwin.c - Profile data on Darwin ------------===*\ |
| 2 | |* |
| 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | |* See https://llvm.org/LICENSE.txt for license information. |
| 5 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | |* |
| 7 | \*===----------------------------------------------------------------------===*/ |
| 8 | |
| 9 | // Note: This is linked into the Darwin kernel, and must remain compatible |
| 10 | // with freestanding compilation. See `darwin_add_builtin_libraries`. |
| 11 | |
| 12 | #include "InstrProfiling.h" |
| 13 | #include "InstrProfilingInternal.h" |
| 14 | |
| 15 | #if defined(__APPLE__) |
| 16 | /* Use linker magic to find the bounds of the Data section. */ |
| 17 | COMPILER_RT_VISIBILITY |
| 18 | extern __llvm_profile_data |
| 19 | DataStart __asm("section$start$__DATA$" INSTR_PROF_DATA_SECT_NAME); |
| 20 | COMPILER_RT_VISIBILITY |
| 21 | extern __llvm_profile_data |
| 22 | DataEnd __asm("section$end$__DATA$" INSTR_PROF_DATA_SECT_NAME); |
| 23 | COMPILER_RT_VISIBILITY |
| 24 | extern char |
| 25 | NamesStart __asm("section$start$__DATA$" INSTR_PROF_NAME_SECT_NAME); |
| 26 | COMPILER_RT_VISIBILITY |
| 27 | extern char NamesEnd __asm("section$end$__DATA$" INSTR_PROF_NAME_SECT_NAME); |
| 28 | COMPILER_RT_VISIBILITY |
| 29 | extern char |
| 30 | CountersStart __asm("section$start$__DATA$" INSTR_PROF_CNTS_SECT_NAME); |
| 31 | COMPILER_RT_VISIBILITY |
| 32 | extern char CountersEnd __asm("section$end$__DATA$" INSTR_PROF_CNTS_SECT_NAME); |
| 33 | COMPILER_RT_VISIBILITY |
| 34 | extern char |
| 35 | BitmapStart __asm("section$start$__DATA$" INSTR_PROF_BITS_SECT_NAME); |
| 36 | COMPILER_RT_VISIBILITY |
| 37 | extern char BitmapEnd __asm("section$end$__DATA$" INSTR_PROF_BITS_SECT_NAME); |
| 38 | COMPILER_RT_VISIBILITY |
| 39 | extern VTableProfData |
| 40 | VTableProfStart __asm("section$start$__DATA$" INSTR_PROF_VTAB_SECT_NAME); |
| 41 | COMPILER_RT_VISIBILITY |
| 42 | extern VTableProfData |
| 43 | VTableProfEnd __asm("section$end$__DATA$" INSTR_PROF_VTAB_SECT_NAME); |
| 44 | COMPILER_RT_VISIBILITY |
| 45 | extern char |
| 46 | VNameStart __asm("section$start$__DATA$" INSTR_PROF_VNAME_SECT_NAME); |
| 47 | COMPILER_RT_VISIBILITY |
| 48 | extern char VNameEnd __asm("section$end$__DATA$" INSTR_PROF_VNAME_SECT_NAME); |
| 49 | COMPILER_RT_VISIBILITY |
| 50 | |
| 51 | COMPILER_RT_VISIBILITY |
| 52 | extern ValueProfNode |
| 53 | VNodesStart __asm("section$start$__DATA$" INSTR_PROF_VNODES_SECT_NAME); |
| 54 | COMPILER_RT_VISIBILITY |
| 55 | extern ValueProfNode |
| 56 | VNodesEnd __asm("section$end$__DATA$" INSTR_PROF_VNODES_SECT_NAME); |
| 57 | |
| 58 | COMPILER_RT_VISIBILITY |
| 59 | const __llvm_profile_data *__llvm_profile_begin_data(void) { |
| 60 | return &DataStart; |
| 61 | } |
| 62 | COMPILER_RT_VISIBILITY |
| 63 | const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; } |
| 64 | COMPILER_RT_VISIBILITY |
| 65 | const char *__llvm_profile_begin_names(void) { return &NamesStart; } |
| 66 | COMPILER_RT_VISIBILITY |
| 67 | const char *__llvm_profile_end_names(void) { return &NamesEnd; } |
| 68 | COMPILER_RT_VISIBILITY |
| 69 | char *__llvm_profile_begin_counters(void) { return &CountersStart; } |
| 70 | COMPILER_RT_VISIBILITY |
| 71 | char *__llvm_profile_end_counters(void) { return &CountersEnd; } |
| 72 | COMPILER_RT_VISIBILITY |
| 73 | char *__llvm_profile_begin_bitmap(void) { return &BitmapStart; } |
| 74 | COMPILER_RT_VISIBILITY |
| 75 | char *__llvm_profile_end_bitmap(void) { return &BitmapEnd; } |
| 76 | COMPILER_RT_VISIBILITY |
| 77 | const VTableProfData *__llvm_profile_begin_vtables(void) { |
| 78 | return &VTableProfStart; |
| 79 | } |
| 80 | COMPILER_RT_VISIBILITY |
| 81 | const VTableProfData *__llvm_profile_end_vtables(void) { |
| 82 | return &VTableProfEnd; |
| 83 | } |
| 84 | COMPILER_RT_VISIBILITY |
| 85 | const char *__llvm_profile_begin_vtabnames(void) { return &VNameStart; } |
| 86 | COMPILER_RT_VISIBILITY |
| 87 | const char *__llvm_profile_end_vtabnames(void) { return &VNameEnd; } |
| 88 | |
| 89 | COMPILER_RT_VISIBILITY |
| 90 | ValueProfNode *__llvm_profile_begin_vnodes(void) { |
| 91 | return &VNodesStart; |
| 92 | } |
| 93 | COMPILER_RT_VISIBILITY |
| 94 | ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; } |
| 95 | |
| 96 | COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &VNodesStart; |
| 97 | COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &VNodesEnd; |
| 98 | |
| 99 | COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) { |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | #endif |
| 104 | |