1/*===- InstrProfilingMergeFile.c - Profile in-process Merging ------------===*\
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|* This file defines APIs needed to support in-process merging for profile data
9|* stored in files.
10\*===----------------------------------------------------------------------===*/
11
12#if !defined(__Fuchsia__)
13
14#include "InstrProfiling.h"
15#include "InstrProfilingInternal.h"
16
17#define INSTR_PROF_VALUE_PROF_DATA
18#include "profile/InstrProfData.inc"
19
20/* Merge value profile data pointed to by SrcValueProfData into
21 * in-memory profile counters pointed by to DstData. */
22COMPILER_RT_VISIBILITY
23void lprofMergeValueProfData(ValueProfData *SrcValueProfData,
24 __llvm_profile_data *DstData) {
25 unsigned I, S, V, DstIndex = 0;
26 InstrProfValueData *VData;
27 ValueProfRecord *VR = getFirstValueProfRecord(VPD: SrcValueProfData);
28 for (I = 0; I < SrcValueProfData->NumValueKinds; I++) {
29 VData = getValueProfRecordValueData(VPR: VR);
30 unsigned SrcIndex = 0;
31 for (S = 0; S < VR->NumValueSites; S++) {
32 uint8_t NV = VR->SiteCountArray[S];
33 for (V = 0; V < NV; V++) {
34 __llvm_profile_instrument_target_value(TargetValue: VData[SrcIndex].Value, Data: DstData,
35 CounterIndex: DstIndex, CounterValue: VData[SrcIndex].Count);
36 ++SrcIndex;
37 }
38 ++DstIndex;
39 }
40 VR = getValueProfRecordNext(VPR: VR);
41 }
42}
43
44#endif
45