blob: ac5ee9fbedc67d46729e49ae8622af7aae09afbb [file] [log] [blame]
Xinliang David Lidd12e9a2016-03-03 18:54:46 +00001/*===- 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
20void (*VPMergeHook)(ValueProfData *,
Xinliang David Licf1a8d62016-03-06 04:18:13 +000021 __llvm_profile_data *) = &lprofMergeValueProfData;
Xinliang David Lidd12e9a2016-03-03 18:54:46 +000022
23/* Merge value profile data pointed to by SrcValueProfData into
24 * in-memory profile counters pointed by to DstData. */
Xinliang David Licf1a8d62016-03-06 04:18:13 +000025void lprofMergeValueProfData(ValueProfData *SrcValueProfData,
26 __llvm_profile_data *DstData) {
Xinliang David Lidd12e9a2016-03-03 18:54:46 +000027 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}