| Xinliang David Li | dd12e9a | 2016-03-03 18:54:46 +0000 | [diff] [blame] | 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 | |
| Xinliang David Li | dd12e9a | 2016-03-03 18:54:46 +0000 | [diff] [blame] | 20 | /* Merge value profile data pointed to by SrcValueProfData into |
| 21 | * in-memory profile counters pointed by to DstData. */ |
| Xinliang David Li | cf1a8d6 | 2016-03-06 04:18:13 +0000 | [diff] [blame] | 22 | void lprofMergeValueProfData(ValueProfData *SrcValueProfData, |
| 23 | __llvm_profile_data *DstData) { |
| Rong Xu | 95ab758 | 2018-04-02 16:57:00 +0000 | [diff] [blame] | 24 | unsigned I, S, V, DstIndex = 0; |
| Xinliang David Li | dd12e9a | 2016-03-03 18:54:46 +0000 | [diff] [blame] | 25 | InstrProfValueData *VData; |
| 26 | ValueProfRecord *VR = getFirstValueProfRecord(SrcValueProfData); |
| 27 | for (I = 0; I < SrcValueProfData->NumValueKinds; I++) { |
| 28 | VData = getValueProfRecordValueData(VR); |
| Rong Xu | 95ab758 | 2018-04-02 16:57:00 +0000 | [diff] [blame] | 29 | unsigned SrcIndex = 0; |
| Xinliang David Li | dd12e9a | 2016-03-03 18:54:46 +0000 | [diff] [blame] | 30 | for (S = 0; S < VR->NumValueSites; S++) { |
| 31 | uint8_t NV = VR->SiteCountArray[S]; |
| 32 | for (V = 0; V < NV; V++) { |
| Rong Xu | 95ab758 | 2018-04-02 16:57:00 +0000 | [diff] [blame] | 33 | __llvm_profile_instrument_target_value(VData[SrcIndex].Value, DstData, |
| 34 | DstIndex, VData[SrcIndex].Count); |
| 35 | ++SrcIndex; |
| Xinliang David Li | dd12e9a | 2016-03-03 18:54:46 +0000 | [diff] [blame] | 36 | } |
| Rong Xu | 95ab758 | 2018-04-02 16:57:00 +0000 | [diff] [blame] | 37 | ++DstIndex; |
| Xinliang David Li | dd12e9a | 2016-03-03 18:54:46 +0000 | [diff] [blame] | 38 | } |
| 39 | VR = getValueProfRecordNext(VR); |
| 40 | } |
| 41 | } |