InstrProfilingMergeFile.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*===- InstrProfilingMergeFile.c - Profile in-process Merging ------------===*\
  2. |*
  3. |* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. |* See https://llvm.org/LICENSE.txt for license information.
  5. |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. |*
  7. |*===----------------------------------------------------------------------===
  8. |* This file defines APIs needed to support in-process merging for profile data
  9. |* stored in files.
  10. \*===----------------------------------------------------------------------===*/
  11. #if !defined(__Fuchsia__)
  12. #include "InstrProfiling.h"
  13. #include "InstrProfilingInternal.h"
  14. #include "InstrProfilingUtil.h"
  15. #define INSTR_PROF_VALUE_PROF_DATA
  16. #include "profile/InstrProfData.inc"
  17. /* Merge value profile data pointed to by SrcValueProfData into
  18. * in-memory profile counters pointed by to DstData. */
  19. COMPILER_RT_VISIBILITY
  20. void lprofMergeValueProfData(ValueProfData *SrcValueProfData,
  21. __llvm_profile_data *DstData) {
  22. unsigned I, S, V, DstIndex = 0;
  23. InstrProfValueData *VData;
  24. ValueProfRecord *VR = getFirstValueProfRecord(SrcValueProfData);
  25. for (I = 0; I < SrcValueProfData->NumValueKinds; I++) {
  26. VData = getValueProfRecordValueData(VR);
  27. unsigned SrcIndex = 0;
  28. for (S = 0; S < VR->NumValueSites; S++) {
  29. uint8_t NV = VR->SiteCountArray[S];
  30. for (V = 0; V < NV; V++) {
  31. __llvm_profile_instrument_target_value(VData[SrcIndex].Value, DstData,
  32. DstIndex, VData[SrcIndex].Count);
  33. ++SrcIndex;
  34. }
  35. ++DstIndex;
  36. }
  37. VR = getValueProfRecordNext(VR);
  38. }
  39. }
  40. #endif