InstrProfilingPlatformDarwin.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // Note: This is linked into the Darwin kernel, and must remain compatible
  9. // with freestanding compilation. See `darwin_add_builtin_libraries`.
  10. #include "InstrProfiling.h"
  11. #include "InstrProfilingInternal.h"
  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);
  17. COMPILER_RT_VISIBILITY
  18. extern __llvm_profile_data
  19. DataEnd __asm("section$end$__DATA$" INSTR_PROF_DATA_SECT_NAME);
  20. COMPILER_RT_VISIBILITY
  21. extern char
  22. NamesStart __asm("section$start$__DATA$" INSTR_PROF_NAME_SECT_NAME);
  23. COMPILER_RT_VISIBILITY
  24. extern char NamesEnd __asm("section$end$__DATA$" INSTR_PROF_NAME_SECT_NAME);
  25. COMPILER_RT_VISIBILITY
  26. extern char
  27. CountersStart __asm("section$start$__DATA$" INSTR_PROF_CNTS_SECT_NAME);
  28. COMPILER_RT_VISIBILITY
  29. extern char CountersEnd __asm("section$end$__DATA$" INSTR_PROF_CNTS_SECT_NAME);
  30. COMPILER_RT_VISIBILITY
  31. extern uint32_t
  32. OrderFileStart __asm("section$start$__DATA$" INSTR_PROF_ORDERFILE_SECT_NAME);
  33. COMPILER_RT_VISIBILITY
  34. extern ValueProfNode
  35. VNodesStart __asm("section$start$__DATA$" INSTR_PROF_VNODES_SECT_NAME);
  36. COMPILER_RT_VISIBILITY
  37. extern ValueProfNode
  38. VNodesEnd __asm("section$end$__DATA$" INSTR_PROF_VNODES_SECT_NAME);
  39. COMPILER_RT_VISIBILITY
  40. const __llvm_profile_data *__llvm_profile_begin_data(void) {
  41. return &DataStart;
  42. }
  43. COMPILER_RT_VISIBILITY
  44. const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
  45. COMPILER_RT_VISIBILITY
  46. const char *__llvm_profile_begin_names(void) { return &NamesStart; }
  47. COMPILER_RT_VISIBILITY
  48. const char *__llvm_profile_end_names(void) { return &NamesEnd; }
  49. COMPILER_RT_VISIBILITY
  50. char *__llvm_profile_begin_counters(void) { return &CountersStart; }
  51. COMPILER_RT_VISIBILITY
  52. char *__llvm_profile_end_counters(void) { return &CountersEnd; }
  53. COMPILER_RT_VISIBILITY
  54. uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; }
  55. COMPILER_RT_VISIBILITY
  56. ValueProfNode *__llvm_profile_begin_vnodes(void) {
  57. return &VNodesStart;
  58. }
  59. COMPILER_RT_VISIBILITY
  60. ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; }
  61. COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &VNodesStart;
  62. COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &VNodesEnd;
  63. COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
  64. return 0;
  65. }
  66. #endif