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(".lprfnd$A", read, write)
33 #pragma section(".lprfnd$Z", read, write)
34 #endif
35 
36 __llvm_profile_data COMPILER_RT_SECTION(".lprfd$A") DataStart = {0};
37 __llvm_profile_data COMPILER_RT_SECTION(".lprfd$Z") DataEnd = {0};
38 
39 const char COMPILER_RT_SECTION(".lprfn$A") NamesStart = '\0';
40 const char COMPILER_RT_SECTION(".lprfn$Z") NamesEnd = '\0';
41 
42 uint64_t COMPILER_RT_SECTION(".lprfc$A") CountersStart;
43 uint64_t COMPILER_RT_SECTION(".lprfc$Z") CountersEnd;
44 
45 ValueProfNode COMPILER_RT_SECTION(".lprfnd$A") VNodesStart;
46 ValueProfNode COMPILER_RT_SECTION(".lprfnd$Z") VNodesEnd;
47 
48 const __llvm_profile_data *__llvm_profile_begin_data(void) {
49   return &DataStart + 1;
50 }
51 const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
52 
53 const char *__llvm_profile_begin_names(void) { return &NamesStart + 1; }
54 const char *__llvm_profile_end_names(void) { return &NamesEnd; }
55 
56 uint64_t *__llvm_profile_begin_counters(void) { return &CountersStart + 1; }
57 uint64_t *__llvm_profile_end_counters(void) { return &CountersEnd; }
58 
59 ValueProfNode *__llvm_profile_begin_vnodes(void) { return &VNodesStart + 1; }
60 ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; }
61 
62 ValueProfNode *CurrentVNode = &VNodesStart + 1;
63 ValueProfNode *EndVNode = &VNodesEnd;
64 
65 #endif
66