InstrProfilingPlatformWindows.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*===- InstrProfilingPlatformWindows.c - Profile data on Windows ----------===*\
  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. #include "InstrProfiling.h"
  9. #include "InstrProfilingInternal.h"
  10. #if defined(_WIN32)
  11. #if defined(_MSC_VER)
  12. /* Merge read-write sections into .data. */
  13. #pragma comment(linker, "/MERGE:.lprfc=.data")
  14. #pragma comment(linker, "/MERGE:.lprfd=.data")
  15. #pragma comment(linker, "/MERGE:.lprfv=.data")
  16. #pragma comment(linker, "/MERGE:.lprfnd=.data")
  17. /* Do *NOT* merge .lprfn and .lcovmap into .rdata. llvm-cov must be able to find
  18. * after the fact.
  19. */
  20. /* Allocate read-only section bounds. */
  21. #pragma section(".lprfn$A", read)
  22. #pragma section(".lprfn$Z", read)
  23. /* Allocate read-write section bounds. */
  24. #pragma section(".lprfd$A", read, write)
  25. #pragma section(".lprfd$Z", read, write)
  26. #pragma section(".lprfc$A", read, write)
  27. #pragma section(".lprfc$Z", read, write)
  28. #pragma section(".lorderfile$A", read, write)
  29. #pragma section(".lprfnd$A", read, write)
  30. #pragma section(".lprfnd$Z", read, write)
  31. #endif
  32. __llvm_profile_data COMPILER_RT_SECTION(".lprfd$A") DataStart = {0};
  33. __llvm_profile_data COMPILER_RT_SECTION(".lprfd$Z") DataEnd = {0};
  34. const char COMPILER_RT_SECTION(".lprfn$A") NamesStart = '\0';
  35. const char COMPILER_RT_SECTION(".lprfn$Z") NamesEnd = '\0';
  36. char COMPILER_RT_SECTION(".lprfc$A") CountersStart;
  37. char COMPILER_RT_SECTION(".lprfc$Z") CountersEnd;
  38. uint32_t COMPILER_RT_SECTION(".lorderfile$A") OrderFileStart;
  39. ValueProfNode COMPILER_RT_SECTION(".lprfnd$A") VNodesStart;
  40. ValueProfNode COMPILER_RT_SECTION(".lprfnd$Z") VNodesEnd;
  41. const __llvm_profile_data *__llvm_profile_begin_data(void) {
  42. return &DataStart + 1;
  43. }
  44. const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
  45. const char *__llvm_profile_begin_names(void) { return &NamesStart + 1; }
  46. const char *__llvm_profile_end_names(void) { return &NamesEnd; }
  47. char *__llvm_profile_begin_counters(void) { return &CountersStart + 1; }
  48. char *__llvm_profile_end_counters(void) { return &CountersEnd; }
  49. uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; }
  50. ValueProfNode *__llvm_profile_begin_vnodes(void) { return &VNodesStart + 1; }
  51. ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; }
  52. ValueProfNode *CurrentVNode = &VNodesStart + 1;
  53. ValueProfNode *EndVNode = &VNodesEnd;
  54. COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
  55. return 0;
  56. }
  57. #endif