summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-05-11 21:16:11 +0000
committerXinliang David Li <davidxl@google.com>2016-05-11 21:16:11 +0000
commitc15309d40defc39e90229f1f73944f51b8d36b5f (patch)
treedbe9d59e782bfd2ceb13641830484250e1ece5e1 /lib
parent87c6f402863aa7bd7ba16aede1bc479942208aef (diff)
cleanup: Enforce caller to set total size to avoid redundant size compute
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269237 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/profile/InstrProfData.inc7
-rw-r--r--lib/profile/InstrProfilingValue.c1
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);