[compiler-rt] r269237 - cleanup: Enforce caller to set total size to avoid redundant size compute

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 14:16:11 PDT 2016


Author: davidxl
Date: Wed May 11 16:16:11 2016
New Revision: 269237

URL: http://llvm.org/viewvc/llvm-project?rev=269237&view=rev
Log:
cleanup: Enforce caller to set total size to avoid redundant size compute

Modified:
    compiler-rt/trunk/lib/profile/InstrProfData.inc
    compiler-rt/trunk/lib/profile/InstrProfilingValue.c

Modified: compiler-rt/trunk/lib/profile/InstrProfData.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfData.inc?rev=269237&r1=269236&r2=269237&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfData.inc (original)
+++ compiler-rt/trunk/lib/profile/InstrProfData.inc Wed May 11 16:16:11 2016
@@ -531,12 +531,15 @@ void serializeValueProfRecordFrom(ValueP
 /*!
  * 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);

Modified: compiler-rt/trunk/lib/profile/InstrProfilingValue.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingValue.c?rev=269237&r1=269236&r2=269237&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingValue.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingValue.c Wed May 11 16:16:11 2016
@@ -130,6 +130,7 @@ lprofGatherValueProfData(const __llvm_pr
     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);




More information about the llvm-commits mailing list