summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-11-28 05:37:01 +0000
committerXinliang David Li <davidxl@google.com>2015-11-28 05:37:01 +0000
commit4cccee52ce21fc8408e24d5318ecf647c1afa47b (patch)
tree71a35941b7cc5d707b6d396d03beaee27aa89626 /llvm/lib/ProfileData
parentbe969c294232b553d671fcc1974f093b47a6bba1 (diff)
downloadbcm5719-llvm-4cccee52ce21fc8408e24d5318ecf647c1afa47b.tar.gz
bcm5719-llvm-4cccee52ce21fc8408e24d5318ecf647c1afa47b.zip
[PGO] Allow value profile writer interface to allocated target buffer
Raw profile writer needs to write all data of one kind in one continuous block, so the buffer needs to be pre-allocated and passed to the writer method in pieces for function profile data. The change adds the support for raw value data writing. llvm-svn: 254219
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 54c37e30dba..3bbc8249c3d 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -170,10 +170,12 @@ void serializeValueProfRecordFrom(ValueProfRecord *This,
}
}
-ValueProfData *serializeValueProfDataFrom(ValueProfRecordClosure *Closure) {
+ValueProfData *serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
+ ValueProfData *DstData) {
uint32_t TotalSize = getValueProfDataSize(Closure);
- ValueProfData *VPD = Closure->AllocValueProfData(TotalSize);
+ ValueProfData *VPD =
+ DstData ? DstData : Closure->AllocValueProfData(TotalSize);
VPD->TotalSize = TotalSize;
VPD->NumValueKinds = Closure->GetNumValueKinds(Closure->Record);
@@ -259,7 +261,7 @@ ValueProfData::serializeFrom(const InstrProfRecord &Record) {
InstrProfRecordClosure.Record = &Record;
std::unique_ptr<ValueProfData> VPD(
- serializeValueProfDataFrom(&InstrProfRecordClosure));
+ serializeValueProfDataFrom(&InstrProfRecordClosure, 0));
return VPD;
}
@@ -367,16 +369,18 @@ uint32_t getValueProfDataSizeRT(const ValueProfRuntimeRecord *Record) {
}
/* Return a ValueProfData instance that stores the data collected
- from runtime. */
+ * from runtime. If \c DstData is provided by the caller, the value
+ * profile data will be store in *DstData and DstData is returned,
+ * otherwise the method will allocate space for the value data and
+ * return pointer to the newly allocated space.
+ */
ValueProfData *
-serializeValueProfDataFromRT(const ValueProfRuntimeRecord *Record) {
+serializeValueProfDataFromRT(const ValueProfRuntimeRecord *Record,
+ ValueProfData *DstData) {
RTRecordClosure.Record = Record;
- return serializeValueProfDataFrom(&RTRecordClosure);
+ return serializeValueProfDataFrom(&RTRecordClosure, DstData);
}
-
-
-
void ValueProfRecord::deserializeTo(InstrProfRecord &Record,
InstrProfRecord::ValueMapType *VMap) {
Record.reserveSites(Kind, NumValueSites);
OpenPOWER on IntegriCloud