10b57cec5SDimitry Andric /*===- InstrProfilingMergeFile.c - Profile in-process Merging ------------===*\ 20b57cec5SDimitry Andric |* 30b57cec5SDimitry Andric |* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric |* See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric |* 70b57cec5SDimitry Andric |*===----------------------------------------------------------------------=== 80b57cec5SDimitry Andric |* This file defines APIs needed to support in-process merging for profile data 90b57cec5SDimitry Andric |* stored in files. 100b57cec5SDimitry Andric \*===----------------------------------------------------------------------===*/ 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #if !defined(__Fuchsia__) 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #include "InstrProfiling.h" 150b57cec5SDimitry Andric #include "InstrProfilingInternal.h" 160b57cec5SDimitry Andric #include "InstrProfilingUtil.h" 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric #define INSTR_PROF_VALUE_PROF_DATA 19*480093f4SDimitry Andric #include "profile/InstrProfData.inc" 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric /* Merge value profile data pointed to by SrcValueProfData into 220b57cec5SDimitry Andric * in-memory profile counters pointed by to DstData. */ 230b57cec5SDimitry Andric COMPILER_RT_VISIBILITY lprofMergeValueProfData(ValueProfData * SrcValueProfData,__llvm_profile_data * DstData)240b57cec5SDimitry Andricvoid lprofMergeValueProfData(ValueProfData *SrcValueProfData, 250b57cec5SDimitry Andric __llvm_profile_data *DstData) { 260b57cec5SDimitry Andric unsigned I, S, V, DstIndex = 0; 270b57cec5SDimitry Andric InstrProfValueData *VData; 280b57cec5SDimitry Andric ValueProfRecord *VR = getFirstValueProfRecord(SrcValueProfData); 290b57cec5SDimitry Andric for (I = 0; I < SrcValueProfData->NumValueKinds; I++) { 300b57cec5SDimitry Andric VData = getValueProfRecordValueData(VR); 310b57cec5SDimitry Andric unsigned SrcIndex = 0; 320b57cec5SDimitry Andric for (S = 0; S < VR->NumValueSites; S++) { 330b57cec5SDimitry Andric uint8_t NV = VR->SiteCountArray[S]; 340b57cec5SDimitry Andric for (V = 0; V < NV; V++) { 350b57cec5SDimitry Andric __llvm_profile_instrument_target_value(VData[SrcIndex].Value, DstData, 360b57cec5SDimitry Andric DstIndex, VData[SrcIndex].Count); 370b57cec5SDimitry Andric ++SrcIndex; 380b57cec5SDimitry Andric } 390b57cec5SDimitry Andric ++DstIndex; 400b57cec5SDimitry Andric } 410b57cec5SDimitry Andric VR = getValueProfRecordNext(VR); 420b57cec5SDimitry Andric } 430b57cec5SDimitry Andric } 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric #endif 46