• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*===- InstrProfilingPlatformDarwin.c - Profile data on Darwin ------------===*\
2 |*
3 |*                     The LLVM Compiler Infrastructure
4 |*
5 |* This file is distributed under the University of Illinois Open Source
6 |* License. See LICENSE.TXT for details.
7 |*
8 \*===----------------------------------------------------------------------===*/
9 
10 #include "InstrProfiling.h"
11 
12 #if defined(__APPLE__)
13 /* Use linker magic to find the bounds of the Data section. */
14 COMPILER_RT_VISIBILITY
15 extern __llvm_profile_data
16     DataStart __asm("section$start$__DATA$" INSTR_PROF_DATA_SECT_NAME_STR);
17 COMPILER_RT_VISIBILITY
18 extern __llvm_profile_data
19     DataEnd __asm("section$end$__DATA$" INSTR_PROF_DATA_SECT_NAME_STR);
20 COMPILER_RT_VISIBILITY
21 extern char
22     NamesStart __asm("section$start$__DATA$" INSTR_PROF_NAME_SECT_NAME_STR);
23 COMPILER_RT_VISIBILITY
24 extern char NamesEnd __asm("section$end$__DATA$" INSTR_PROF_NAME_SECT_NAME_STR);
25 COMPILER_RT_VISIBILITY
26 extern uint64_t
27     CountersStart __asm("section$start$__DATA$" INSTR_PROF_CNTS_SECT_NAME_STR);
28 COMPILER_RT_VISIBILITY
29 extern uint64_t
30     CountersEnd __asm("section$end$__DATA$" INSTR_PROF_CNTS_SECT_NAME_STR);
31 
32 COMPILER_RT_VISIBILITY
33 extern ValueProfNode
34     VNodesStart __asm("section$start$__DATA$" INSTR_PROF_VNODES_SECT_NAME_STR);
35 COMPILER_RT_VISIBILITY
36 extern ValueProfNode
37     VNodesEnd __asm("section$end$__DATA$" INSTR_PROF_VNODES_SECT_NAME_STR);
38 
39 COMPILER_RT_VISIBILITY
__llvm_profile_begin_data(void)40 const __llvm_profile_data *__llvm_profile_begin_data(void) {
41   return &DataStart;
42 }
43 COMPILER_RT_VISIBILITY
__llvm_profile_end_data(void)44 const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
45 COMPILER_RT_VISIBILITY
__llvm_profile_begin_names(void)46 const char *__llvm_profile_begin_names(void) { return &NamesStart; }
47 COMPILER_RT_VISIBILITY
__llvm_profile_end_names(void)48 const char *__llvm_profile_end_names(void) { return &NamesEnd; }
49 COMPILER_RT_VISIBILITY
__llvm_profile_begin_counters(void)50 uint64_t *__llvm_profile_begin_counters(void) { return &CountersStart; }
51 COMPILER_RT_VISIBILITY
__llvm_profile_end_counters(void)52 uint64_t *__llvm_profile_end_counters(void) { return &CountersEnd; }
53 
54 COMPILER_RT_VISIBILITY
__llvm_profile_begin_vnodes(void)55 ValueProfNode *__llvm_profile_begin_vnodes(void) {
56   return &VNodesStart;
57 }
58 COMPILER_RT_VISIBILITY
__llvm_profile_end_vnodes(void)59 ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; }
60 
61 COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &VNodesStart;
62 COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &VNodesEnd;
63 #endif
64