13cab2bb3Spatrick /*===- InstrProfilingPlatformWindows.c - Profile data on Windows ----------===*\
23cab2bb3Spatrick |*
33cab2bb3Spatrick |* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
43cab2bb3Spatrick |* See https://llvm.org/LICENSE.txt for license information.
53cab2bb3Spatrick |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
63cab2bb3Spatrick |*
73cab2bb3Spatrick \*===----------------------------------------------------------------------===*/
83cab2bb3Spatrick
93cab2bb3Spatrick #include "InstrProfiling.h"
10d89ec533Spatrick #include "InstrProfilingInternal.h"
113cab2bb3Spatrick
123cab2bb3Spatrick #if defined(_WIN32)
133cab2bb3Spatrick
143cab2bb3Spatrick #if defined(_MSC_VER)
153cab2bb3Spatrick /* Merge read-write sections into .data. */
163cab2bb3Spatrick #pragma comment(linker, "/MERGE:.lprfc=.data")
173cab2bb3Spatrick #pragma comment(linker, "/MERGE:.lprfd=.data")
183cab2bb3Spatrick #pragma comment(linker, "/MERGE:.lprfv=.data")
193cab2bb3Spatrick #pragma comment(linker, "/MERGE:.lprfnd=.data")
203cab2bb3Spatrick /* Do *NOT* merge .lprfn and .lcovmap into .rdata. llvm-cov must be able to find
213cab2bb3Spatrick * after the fact.
223cab2bb3Spatrick */
233cab2bb3Spatrick
243cab2bb3Spatrick /* Allocate read-only section bounds. */
253cab2bb3Spatrick #pragma section(".lprfn$A", read)
263cab2bb3Spatrick #pragma section(".lprfn$Z", read)
273cab2bb3Spatrick
283cab2bb3Spatrick /* Allocate read-write section bounds. */
293cab2bb3Spatrick #pragma section(".lprfd$A", read, write)
303cab2bb3Spatrick #pragma section(".lprfd$Z", read, write)
313cab2bb3Spatrick #pragma section(".lprfc$A", read, write)
323cab2bb3Spatrick #pragma section(".lprfc$Z", read, write)
333cab2bb3Spatrick #pragma section(".lorderfile$A", read, write)
343cab2bb3Spatrick #pragma section(".lprfnd$A", read, write)
353cab2bb3Spatrick #pragma section(".lprfnd$Z", read, write)
363cab2bb3Spatrick #endif
373cab2bb3Spatrick
383cab2bb3Spatrick __llvm_profile_data COMPILER_RT_SECTION(".lprfd$A") DataStart = {0};
393cab2bb3Spatrick __llvm_profile_data COMPILER_RT_SECTION(".lprfd$Z") DataEnd = {0};
403cab2bb3Spatrick
413cab2bb3Spatrick const char COMPILER_RT_SECTION(".lprfn$A") NamesStart = '\0';
423cab2bb3Spatrick const char COMPILER_RT_SECTION(".lprfn$Z") NamesEnd = '\0';
433cab2bb3Spatrick
44*810390e3Srobert char COMPILER_RT_SECTION(".lprfc$A") CountersStart;
45*810390e3Srobert char COMPILER_RT_SECTION(".lprfc$Z") CountersEnd;
463cab2bb3Spatrick uint32_t COMPILER_RT_SECTION(".lorderfile$A") OrderFileStart;
473cab2bb3Spatrick
483cab2bb3Spatrick ValueProfNode COMPILER_RT_SECTION(".lprfnd$A") VNodesStart;
493cab2bb3Spatrick ValueProfNode COMPILER_RT_SECTION(".lprfnd$Z") VNodesEnd;
503cab2bb3Spatrick
__llvm_profile_begin_data(void)513cab2bb3Spatrick const __llvm_profile_data *__llvm_profile_begin_data(void) {
523cab2bb3Spatrick return &DataStart + 1;
533cab2bb3Spatrick }
__llvm_profile_end_data(void)543cab2bb3Spatrick const __llvm_profile_data *__llvm_profile_end_data(void) { return &DataEnd; }
553cab2bb3Spatrick
__llvm_profile_begin_names(void)563cab2bb3Spatrick const char *__llvm_profile_begin_names(void) { return &NamesStart + 1; }
__llvm_profile_end_names(void)573cab2bb3Spatrick const char *__llvm_profile_end_names(void) { return &NamesEnd; }
583cab2bb3Spatrick
__llvm_profile_begin_counters(void)59*810390e3Srobert char *__llvm_profile_begin_counters(void) { return &CountersStart + 1; }
__llvm_profile_end_counters(void)60*810390e3Srobert char *__llvm_profile_end_counters(void) { return &CountersEnd; }
__llvm_profile_begin_orderfile(void)613cab2bb3Spatrick uint32_t *__llvm_profile_begin_orderfile(void) { return &OrderFileStart; }
623cab2bb3Spatrick
__llvm_profile_begin_vnodes(void)633cab2bb3Spatrick ValueProfNode *__llvm_profile_begin_vnodes(void) { return &VNodesStart + 1; }
__llvm_profile_end_vnodes(void)643cab2bb3Spatrick ValueProfNode *__llvm_profile_end_vnodes(void) { return &VNodesEnd; }
653cab2bb3Spatrick
663cab2bb3Spatrick ValueProfNode *CurrentVNode = &VNodesStart + 1;
673cab2bb3Spatrick ValueProfNode *EndVNode = &VNodesEnd;
683cab2bb3Spatrick
__llvm_write_binary_ids(ProfDataWriter * Writer)69d89ec533Spatrick COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
70d89ec533Spatrick return 0;
71d89ec533Spatrick }
72d89ec533Spatrick
733cab2bb3Spatrick #endif
74