summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/profile/InstrProfilingMergeFile.c
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-03-03 18:54:46 +0000
committerXinliang David Li <davidxl@google.com>2016-03-03 18:54:46 +0000
commitdd12e9a8c04eb1cc5b43df4d249273678c5fec6b (patch)
treef2b96fe86fb9cbfea7d542b3748baab39d73ea6c /compiler-rt/lib/profile/InstrProfilingMergeFile.c
parentfd6557e36805ad40e2bcea51e18d47c2fd76b554 (diff)
downloadbcm5719-llvm-dd12e9a8c04eb1cc5b43df4d249273678c5fec6b.tar.gz
bcm5719-llvm-dd12e9a8c04eb1cc5b43df4d249273678c5fec6b.zip
[PGO] Add API for profile merge from buffer
Differential Revision: http://reviews.llvm.org/D17831 llvm-svn: 262644
Diffstat (limited to 'compiler-rt/lib/profile/InstrProfilingMergeFile.c')
-rw-r--r--compiler-rt/lib/profile/InstrProfilingMergeFile.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingMergeFile.c b/compiler-rt/lib/profile/InstrProfilingMergeFile.c
new file mode 100644
index 00000000000..bfcca8fc9cb
--- /dev/null
+++ b/compiler-rt/lib/profile/InstrProfilingMergeFile.c
@@ -0,0 +1,41 @@
+/*===- InstrProfilingMergeFile.c - Profile in-process Merging ------------===*\
+|*
+|* The LLVM Compiler Infrastructure
+|*
+|* This file is distributed under the University of Illinois Open Source
+|* License. See LICENSE.TXT for details.
+|*
+|*===----------------------------------------------------------------------===
+|* This file defines APIs needed to support in-process merging for profile data
+|* stored in files.
+\*===----------------------------------------------------------------------===*/
+
+#include "InstrProfiling.h"
+#include "InstrProfilingInternal.h"
+#include "InstrProfilingUtil.h"
+
+#define INSTR_PROF_VALUE_PROF_DATA
+#include "InstrProfData.inc"
+
+void (*VPMergeHook)(ValueProfData *,
+ __llvm_profile_data *) = &mergeValueProfData;
+
+/* Merge value profile data pointed to by SrcValueProfData into
+ * in-memory profile counters pointed by to DstData. */
+void mergeValueProfData(ValueProfData *SrcValueProfData,
+ __llvm_profile_data *DstData) {
+ unsigned I, S, V, C;
+ InstrProfValueData *VData;
+ ValueProfRecord *VR = getFirstValueProfRecord(SrcValueProfData);
+ for (I = 0; I < SrcValueProfData->NumValueKinds; I++) {
+ VData = getValueProfRecordValueData(VR);
+ for (S = 0; S < VR->NumValueSites; S++) {
+ uint8_t NV = VR->SiteCountArray[S];
+ for (V = 0; V < NV; V++) {
+ for (C = 0; C < VData[V].Count; C++)
+ __llvm_profile_instrument_target(VData[V].Value, DstData, S);
+ }
+ }
+ VR = getValueProfRecordNext(VR);
+ }
+}
OpenPOWER on IntegriCloud