1 /*===- InstrProfilingPlatformWindows.c - Profile data on Windows ----------===*\
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
7 \*===----------------------------------------------------------------------===*/
9 #include "InstrProfiling.h"
10 #include "InstrProfilingInternal.h"
15 /* Merge read-write sections into .data. */
16 #pragma comment(linker, "/MERGE:.lprfc=.data")
17 #pragma comment(linker, "/MERGE:.lprfb=.data")
18 #pragma comment(linker, "/MERGE:.lprfd=.data")
19 #pragma comment(linker, "/MERGE:.lprfv=.data")
20 #pragma comment(linker, "/MERGE:.lprfnd=.data")
21 /* Do *NOT* merge .lprfn and .lcovmap into .rdata. llvm-cov must be able to find
25 /* Allocate read-only section bounds. */
26 #pragma section(".lprfn$A", read)
27 #pragma section(".lprfn$Z", read)
29 /* Allocate read-write section bounds. */
30 #pragma section(".lprfd$A", read, write)
31 #pragma section(".lprfd$Z", read, write)
32 #pragma section(".lprfc$A", read, write)
33 #pragma section(".lprfc$Z", read, write)
34 #pragma section(".lprfb$A", read, write)
35 #pragma section(".lprfb$Z", read, write)
36 #pragma section(".lorderfile$A", read, write)
37 #pragma section(".lprfnd$A", read, write)
38 #pragma section(".lprfnd$Z", read, write)
41 __llvm_profile_data
COMPILER_RT_SECTION(".lprfd$A") DataStart
= {0};
42 __llvm_profile_data
COMPILER_RT_SECTION(".lprfd$Z") DataEnd
= {0};
44 const char COMPILER_RT_SECTION(".lprfn$A") NamesStart
= '\0';
45 const char COMPILER_RT_SECTION(".lprfn$Z") NamesEnd
= '\0';
47 char COMPILER_RT_SECTION(".lprfc$A") CountersStart
;
48 char COMPILER_RT_SECTION(".lprfc$Z") CountersEnd
;
49 char COMPILER_RT_SECTION(".lprfb$A") BitmapStart
;
50 char COMPILER_RT_SECTION(".lprfb$Z") BitmapEnd
;
51 uint32_t COMPILER_RT_SECTION(".lorderfile$A") OrderFileStart
;
53 ValueProfNode
COMPILER_RT_SECTION(".lprfnd$A") VNodesStart
;
54 ValueProfNode
COMPILER_RT_SECTION(".lprfnd$Z") VNodesEnd
;
56 const __llvm_profile_data
*__llvm_profile_begin_data(void) {
57 return &DataStart
+ 1;
59 const __llvm_profile_data
*__llvm_profile_end_data(void) { return &DataEnd
; }
61 const char *__llvm_profile_begin_names(void) { return &NamesStart
+ 1; }
62 const char *__llvm_profile_end_names(void) { return &NamesEnd
; }
64 char *__llvm_profile_begin_counters(void) { return &CountersStart
+ 1; }
65 char *__llvm_profile_end_counters(void) { return &CountersEnd
; }
66 char *__llvm_profile_begin_bitmap(void) { return &BitmapStart
+ 1; }
67 char *__llvm_profile_end_bitmap(void) { return &BitmapEnd
; }
68 uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart
; }
70 ValueProfNode
*__llvm_profile_begin_vnodes(void) { return &VNodesStart
+ 1; }
71 ValueProfNode
*__llvm_profile_end_vnodes(void) { return &VNodesEnd
; }
73 ValueProfNode
*CurrentVNode
= &VNodesStart
+ 1;
74 ValueProfNode
*EndVNode
= &VNodesEnd
;
76 COMPILER_RT_VISIBILITY
int __llvm_write_binary_ids(ProfDataWriter
*Writer
) {