blob: b41f216c3112e885044d9732ab166b1b5984b49d [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
Xinliang David Lidd12e9a2016-03-03 18:54:46 +000020/* Merge value profile data pointed to by SrcValueProfData into
21 * in-memory profile counters pointed by to DstData. */
Xinliang David Licf1a8d62016-03-06 04:18:13 +000022void lprofMergeValueProfData(ValueProfData *SrcValueProfData,
23 __llvm_profile_data *DstData) {
Rong Xu95ab7582018-04-02 16:57:00 +000024 unsigned I, S, V, DstIndex = 0;
Xinliang David Lidd12e9a2016-03-03 18:54:46 +000025 InstrProfValueData *VData;
26 ValueProfRecord *VR = getFirstValueProfRecord(SrcValueProfData);
27 for (I = 0; I < SrcValueProfData->NumValueKinds; I++) {
28 VData = getValueProfRecordValueData(VR);
Rong Xu95ab7582018-04-02 16:57:00 +000029 unsigned SrcIndex = 0;
Xinliang David Lidd12e9a2016-03-03 18:54:46 +000030 for (S = 0; S < VR->NumValueSites; S++) {
31 uint8_t NV = VR->SiteCountArray[S];
32 for (V = 0; V < NV; V++) {
Rong Xu95ab7582018-04-02 16:57:00 +000033 __llvm_profile_instrument_target_value(VData[SrcIndex].Value, DstData,
34 DstIndex, VData[SrcIndex].Count);
35 ++SrcIndex;
Xinliang David Lidd12e9a2016-03-03 18:54:46 +000036 }
Rong Xu95ab7582018-04-02 16:57:00 +000037 ++DstIndex;
Xinliang David Lidd12e9a2016-03-03 18:54:46 +000038 }
39 VR = getValueProfRecordNext(VR);
40 }
41}