[compiler-rt] r269351 - Minor code refactoring /NFC

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 14:18:41 PDT 2016


Author: davidxl
Date: Thu May 12 16:18:41 2016
New Revision: 269351

URL: http://llvm.org/viewvc/llvm-project?rev=269351&view=rev
Log:
Minor code refactoring /NFC

Modified:
    compiler-rt/trunk/lib/profile/InstrProfilingWriter.c

Modified: compiler-rt/trunk/lib/profile/InstrProfilingWriter.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingWriter.c?rev=269351&r1=269350&r2=269351&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfilingWriter.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfilingWriter.c Thu May 12 16:18:41 2016
@@ -92,6 +92,20 @@ COMPILER_RT_VISIBILITY int lprofBufferIO
 }
 
 #define VP_BUFFER_SIZE 8 * 1024
+
+static int writeOneValueProfData(ProfBufferIO *BufferIO,
+                                 VPGatherHookType VPDataGatherer,
+                                 const __llvm_profile_data *Data) {
+  ValueProfData *CurVData = VPDataGatherer(Data);
+  if (!CurVData)
+    return 0;
+  if (lprofBufferIOWrite(BufferIO, (const uint8_t *)CurVData,
+                         CurVData->TotalSize) != 0)
+    return -1;
+  FreeHook(CurVData);
+  return 0;
+}
+
 static int writeValueProfData(WriterCallback Writer, void *WriterCtx,
                               VPGatherHookType VPDataGatherer,
                               const __llvm_profile_data *DataBegin,
@@ -107,13 +121,8 @@ static int writeValueProfData(WriterCall
   BufferIO = lprofCreateBufferIO(Writer, WriterCtx, BufferSz);
 
   for (DI = DataBegin; DI < DataEnd; DI++) {
-    ValueProfData *CurVData = VPDataGatherer(DI);
-    if (!CurVData)
-      continue;
-    if (lprofBufferIOWrite(BufferIO, (const uint8_t *)CurVData,
-                           CurVData->TotalSize) != 0)
+    if (writeOneValueProfData(BufferIO, VPDataGatherer, DI))
       return -1;
-    FreeHook(CurVData);
   }
 
   if (lprofBufferIOFlush(BufferIO) != 0)




More information about the llvm-commits mailing list