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