diff options
-rw-r--r-- | lib/profile/InstrProfData.inc | 7 | ||||
-rw-r--r-- | lib/profile/InstrProfilingValue.c | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/profile/InstrProfData.inc b/lib/profile/InstrProfData.inc index 043788b81..6db5caeeb 100644 --- a/lib/profile/InstrProfData.inc +++ b/lib/profile/InstrProfData.inc @@ -531,12 +531,15 @@ void serializeValueProfRecordFrom(ValueProfRecord *This, /*! * Extract value profile data of a function from the \c Closure * and serialize the data into \c DstData if it is not NULL or heap - * memory allocated by the \c Closure's allocator method. + * memory allocated by the \c Closure's allocator method. If \c + * DstData is not null, the caller is expected to set the TotalSize + * in DstData. */ ValueProfData *serializeValueProfDataFrom(ValueProfRecordClosure *Closure, ValueProfData *DstData) { uint32_t Kind; - uint32_t TotalSize = getValueProfDataSize(Closure); + uint32_t TotalSize = + DstData ? DstData->TotalSize : getValueProfDataSize(Closure); ValueProfData *VPD = DstData ? DstData : Closure->AllocValueProfData(TotalSize); diff --git a/lib/profile/InstrProfilingValue.c b/lib/profile/InstrProfilingValue.c index 3fe913e9d..d49914700 100644 --- a/lib/profile/InstrProfilingValue.c +++ b/lib/profile/InstrProfilingValue.c @@ -130,6 +130,7 @@ lprofGatherValueProfData(const __llvm_profile_data *Data) { VD = (ValueProfData *)calloc(VS, sizeof(uint8_t)); if (!VD) PROF_OOM_RETURN("Failed to write value profile data "); + VD->TotalSize = VS; serializeValueProfDataFromRT(&R, VD); } finalizeValueProfRuntimeRecord(&R); |