xref: /aosp_15_r20/external/compiler-rt/lib/profile/InstrProfilingMergeFile.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot /*===- InstrProfilingMergeFile.c - Profile in-process Merging  ------------===*\
2*7c3d14c8STreehugger Robot |*
3*7c3d14c8STreehugger Robot |*                     The LLVM Compiler Infrastructure
4*7c3d14c8STreehugger Robot |*
5*7c3d14c8STreehugger Robot |* This file is distributed under the University of Illinois Open Source
6*7c3d14c8STreehugger Robot |* License. See LICENSE.TXT for details.
7*7c3d14c8STreehugger Robot |*
8*7c3d14c8STreehugger Robot |*===----------------------------------------------------------------------===
9*7c3d14c8STreehugger Robot |* This file defines APIs needed to support in-process merging for profile data
10*7c3d14c8STreehugger Robot |* stored in files.
11*7c3d14c8STreehugger Robot \*===----------------------------------------------------------------------===*/
12*7c3d14c8STreehugger Robot 
13*7c3d14c8STreehugger Robot #include "InstrProfiling.h"
14*7c3d14c8STreehugger Robot #include "InstrProfilingInternal.h"
15*7c3d14c8STreehugger Robot #include "InstrProfilingUtil.h"
16*7c3d14c8STreehugger Robot 
17*7c3d14c8STreehugger Robot #define INSTR_PROF_VALUE_PROF_DATA
18*7c3d14c8STreehugger Robot #include "InstrProfData.inc"
19*7c3d14c8STreehugger Robot 
20*7c3d14c8STreehugger Robot void (*VPMergeHook)(ValueProfData *,
21*7c3d14c8STreehugger Robot                     __llvm_profile_data *) = &lprofMergeValueProfData;
22*7c3d14c8STreehugger Robot 
23*7c3d14c8STreehugger Robot /* Merge value profile data pointed to by SrcValueProfData into
24*7c3d14c8STreehugger Robot  * in-memory profile counters pointed by to DstData.  */
lprofMergeValueProfData(ValueProfData * SrcValueProfData,__llvm_profile_data * DstData)25*7c3d14c8STreehugger Robot void lprofMergeValueProfData(ValueProfData *SrcValueProfData,
26*7c3d14c8STreehugger Robot                              __llvm_profile_data *DstData) {
27*7c3d14c8STreehugger Robot   unsigned I, S, V, C;
28*7c3d14c8STreehugger Robot   InstrProfValueData *VData;
29*7c3d14c8STreehugger Robot   ValueProfRecord *VR = getFirstValueProfRecord(SrcValueProfData);
30*7c3d14c8STreehugger Robot   for (I = 0; I < SrcValueProfData->NumValueKinds; I++) {
31*7c3d14c8STreehugger Robot     VData = getValueProfRecordValueData(VR);
32*7c3d14c8STreehugger Robot     for (S = 0; S < VR->NumValueSites; S++) {
33*7c3d14c8STreehugger Robot       uint8_t NV = VR->SiteCountArray[S];
34*7c3d14c8STreehugger Robot       for (V = 0; V < NV; V++) {
35*7c3d14c8STreehugger Robot         for (C = 0; C < VData[V].Count; C++)
36*7c3d14c8STreehugger Robot           __llvm_profile_instrument_target(VData[V].Value, DstData, S);
37*7c3d14c8STreehugger Robot       }
38*7c3d14c8STreehugger Robot     }
39*7c3d14c8STreehugger Robot     VR = getValueProfRecordNext(VR);
40*7c3d14c8STreehugger Robot   }
41*7c3d14c8STreehugger Robot }
42