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