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 /* Merge value profile data pointed to by SrcValueProfData into 21 * in-memory profile counters pointed by to DstData. */ 22 void lprofMergeValueProfData(ValueProfData *SrcValueProfData, 23 __llvm_profile_data *DstData) { 24 unsigned I, S, V, DstIndex = 0; 25 InstrProfValueData *VData; 26 ValueProfRecord *VR = getFirstValueProfRecord(SrcValueProfData); 27 for (I = 0; I < SrcValueProfData->NumValueKinds; I++) { 28 VData = getValueProfRecordValueData(VR); 29 unsigned SrcIndex = 0; 30 for (S = 0; S < VR->NumValueSites; S++) { 31 uint8_t NV = VR->SiteCountArray[S]; 32 for (V = 0; V < NV; V++) { 33 __llvm_profile_instrument_target_value(VData[SrcIndex].Value, DstData, 34 DstIndex, VData[SrcIndex].Count); 35 ++SrcIndex; 36 } 37 ++DstIndex; 38 } 39 VR = getValueProfRecordNext(VR); 40 } 41 } 42