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