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
41const char COMPILER_RT_SECTION(".lprfn$A") NamesStart = '\0';
42const char COMPILER_RT_SECTION(".lprfn$Z") NamesEnd = '\0';
43
44char COMPILER_RT_SECTION(".lprfc$A") CountersStart;
45char COMPILER_RT_SECTION(".lprfc$Z") CountersEnd;
46uint32_t COMPILER_RT_SECTION(".lorderfile$A") OrderFileStart;
47
48ValueProfNode COMPILER_RT_SECTION(".lprfnd$A") VNodesStart;
49ValueProfNode COMPILER_RT_SECTION(".lprfnd$Z") VNodesEnd;
50
51const __llvm_profile_data *__llvm_profile_begin_data(void) {
52  return &DataStart + 1;
53}
54const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
55
56const char *__llvm_profile_begin_names(void) { return &NamesStart + 1; }
57const char *__llvm_profile_end_names(void) { return &NamesEnd; }
58
59char *__llvm_profile_begin_counters(void) { return &CountersStart + 1; }
60char *__llvm_profile_end_counters(void) { return &CountersEnd; }
61uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; }
62
63ValueProfNode *__llvm_profile_begin_vnodes(void) { return &VNodesStart + 1; }
64ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; }
65
66ValueProfNode *CurrentVNode = &VNodesStart + 1;
67ValueProfNode *EndVNode = &VNodesEnd;
68
69COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
70  return 0;
71}
72
73#endif
74