[PGO] internal API name cleanups (for better consistency)
authorXinliang David Li <davidxl@google.com>
Sun, 6 Mar 2016 04:18:13 +0000 (04:18 +0000)
committerXinliang David Li <davidxl@google.com>
Sun, 6 Mar 2016 04:18:13 +0000 (04:18 +0000)
llvm-svn: 262788

compiler-rt/lib/profile/InstrProfilingBuffer.c
compiler-rt/lib/profile/InstrProfilingFile.c
compiler-rt/lib/profile/InstrProfilingInternal.h
compiler-rt/lib/profile/InstrProfilingMergeFile.c
compiler-rt/lib/profile/InstrProfilingPort.h
compiler-rt/lib/profile/InstrProfilingUtil.c
compiler-rt/lib/profile/InstrProfilingWriter.c
compiler-rt/test/profile/Linux/instrprof-merge-vp.c
compiler-rt/test/profile/instrprof-bufferio.c

index 1d95534e09e30d7d38f94d4919de5679029576ee..dcb6929cb0a33d00042ae891164ac95d0c9dab73 100644 (file)
@@ -46,14 +46,14 @@ uint64_t __llvm_profile_get_size_for_buffer_internal(
 }
 
 COMPILER_RT_VISIBILITY int __llvm_profile_write_buffer(char *Buffer) {
-  return llvmWriteProfData(llvmBufferWriter, Buffer, 0, 0);
+  return lprofWriteData(lprofBufferWriter, Buffer, 0, 0);
 }
 
 COMPILER_RT_VISIBILITY int __llvm_profile_write_buffer_internal(
     char *Buffer, const __llvm_profile_data *DataBegin,
     const __llvm_profile_data *DataEnd, const uint64_t *CountersBegin,
     const uint64_t *CountersEnd, const char *NamesBegin, const char *NamesEnd) {
-  return llvmWriteProfDataImpl(llvmBufferWriter, Buffer, DataBegin, DataEnd,
-                               CountersBegin, CountersEnd, 0, 0, NamesBegin,
-                               NamesEnd);
+  return lprofWriteDataImpl(lprofBufferWriter, Buffer, DataBegin, DataEnd,
+                            CountersBegin, CountersEnd, 0, 0, NamesBegin,
+                            NamesEnd);
 }
index ad8c3a08a9f57dfbe504ce913dec2397591a9f31..327f4a2bc6f4c99c4a78c8e7ba2bf26479627446 100644 (file)
 #define UNCONST(ptr) ((void *)(uintptr_t)(ptr))
 
 #ifdef COMPILER_RT_HAS_UNAME
-int GetHostName(char *Name, int Len) {
-    struct utsname N;
-    int R;
-    if (!(R = uname(&N)))
-      strncpy(Name, N.nodename, Len);
-    return R;
+int lprofGetHostName(char *Name, int Len) {
+  struct utsname N;
+  int R;
+  if (!(R = uname(&N)))
+    strncpy(Name, N.nodename, Len);
+  return R;
 }
 #endif
 
@@ -44,10 +44,10 @@ static uint32_t fileWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
 }
 
 COMPILER_RT_VISIBILITY ProfBufferIO *
-llvmCreateBufferIOInternal(void *File, uint32_t BufferSz) {
+lprofCreateBufferIOInternal(void *File, uint32_t BufferSz) {
   CallocHook = calloc;
   FreeHook = free;
-  return llvmCreateBufferIO(fileWriter, File, BufferSz);
+  return lprofCreateBufferIO(fileWriter, File, BufferSz);
 }
 
 static int writeFile(FILE *File) {
@@ -60,7 +60,7 @@ static int writeFile(FILE *File) {
   BufferSzStr = getenv("LLVM_VP_BUFFER_SIZE");
   if (BufferSzStr && BufferSzStr[0])
     VPBufferSize = atoi(BufferSzStr);
-  return llvmWriteProfData(fileWriter, File, ValueDataArray, ValueDataSize);
+  return lprofWriteData(fileWriter, File, ValueDataArray, ValueDataSize);
 }
 
 static int writeFileWithName(const char *OutputName) {
index cd081ae3e0c76c4ea2cf315a9fe11e2dd4cd5b90..2645858fc09002e108f09f07a608588afad40ef0 100644 (file)
@@ -68,51 +68,51 @@ typedef struct ProfBufferIO {
 } ProfBufferIO;
 
 /* The creator interface used by testing.  */
-ProfBufferIO *llvmCreateBufferIOInternal(void *File, uint32_t DefaultBufferSz);
+ProfBufferIO *lprofCreateBufferIOInternal(void *File, uint32_t DefaultBufferSz);
 /*!
  * This is the interface to create a handle for buffered IO.
  */
-ProfBufferIO *llvmCreateBufferIO(WriterCallback FileWriter, void *File,
-                                 uint32_t DefaultBufferSz);
+ProfBufferIO *lprofCreateBufferIO(WriterCallback FileWriter, void *File,
+                                  uint32_t DefaultBufferSz);
 /*!
  * The interface to destroy the bufferIO handle and reclaim
  * the memory.
  */
-void llvmDeleteBufferIO(ProfBufferIO *BufferIO);
+void lprofDeleteBufferIO(ProfBufferIO *BufferIO);
 
 /*!
  * This is the interface to write \c Data of \c Size bytes through
  * \c BufferIO. Returns 0 if successful, otherwise return -1.
  */
-int llvmBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data,
-                      uint32_t Size);
+int lprofBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data,
+                       uint32_t Size);
 /*!
  * The interface to flush the remaining data in the buffer.
  * through the low level writer callback.
  */
-int llvmBufferIOFlush(ProfBufferIO *BufferIO);
+int lprofBufferIOFlush(ProfBufferIO *BufferIO);
 
 /* The low level interface to write data into a buffer. It is used as the
  * callback by other high level writer methods such as buffered IO writer
  * and profile data writer.  */
-uint32_t llvmBufferWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
-                          void **WriterCtx);
+uint32_t lprofBufferWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
+                           void **WriterCtx);
 
-int llvmWriteProfData(WriterCallback Writer, void *WriterCtx,
-                      struct ValueProfData **ValueDataArray,
-                      const uint64_t ValueDataSize);
-int llvmWriteProfDataImpl(WriterCallback Writer, void *WriterCtx,
-                          const __llvm_profile_data *DataBegin,
-                          const __llvm_profile_data *DataEnd,
-                          const uint64_t *CountersBegin,
-                          const uint64_t *CountersEnd,
-                          struct ValueProfData **ValueDataBeginArray,
-                          const uint64_t ValueDataSize, const char *NamesBegin,
-                          const char *NamesEnd);
+int lprofWriteData(WriterCallback Writer, void *WriterCtx,
+                   struct ValueProfData **ValueDataArray,
+                   const uint64_t ValueDataSize);
+int lprofWriteDataImpl(WriterCallback Writer, void *WriterCtx,
+                       const __llvm_profile_data *DataBegin,
+                       const __llvm_profile_data *DataEnd,
+                       const uint64_t *CountersBegin,
+                       const uint64_t *CountersEnd,
+                       struct ValueProfData **ValueDataBeginArray,
+                       const uint64_t ValueDataSize, const char *NamesBegin,
+                       const char *NamesEnd);
 /* Merge value profile data pointed to by SrcValueProfData into
  * in-memory profile counters pointed by to DstData.  */
-void mergeValueProfData(struct ValueProfData *SrcValueProfData,
-                        __llvm_profile_data *DstData);
+void lprofMergeValueProfData(struct ValueProfData *SrcValueProfData,
+                             __llvm_profile_data *DstData);
 
 extern char *(*GetEnvHook)(const char *);
 extern void (*FreeHook)(void *);
index bfcca8fc9cbde74f82283d14b8f85f531b460603..ac5ee9fbedc67d46729e49ae8622af7aae09afbb 100644 (file)
 #include "InstrProfData.inc"
 
 void (*VPMergeHook)(ValueProfData *,
-                    __llvm_profile_data *) = &mergeValueProfData;
+                    __llvm_profile_data *) = &lprofMergeValueProfData;
 
 /* Merge value profile data pointed to by SrcValueProfData into
  * in-memory profile counters pointed by to DstData.  */
-void mergeValueProfData(ValueProfData *SrcValueProfData,
-                        __llvm_profile_data *DstData) {
+void lprofMergeValueProfData(ValueProfData *SrcValueProfData,
+                             __llvm_profile_data *DstData) {
   unsigned I, S, V, C;
   InstrProfValueData *VData;
   ValueProfRecord *VR = getFirstValueProfRecord(SrcValueProfData);
index d6e063e57fec0631642dcb035db1286287dcd625..58e085e90e026873e5aaa072dd6f31fca33816c8 100644 (file)
@@ -28,7 +28,7 @@
 #elif defined(__PS4__)
 #define COMPILER_RT_GETHOSTNAME(Name, Len) (-1)
 #else
-#define COMPILER_RT_GETHOSTNAME(Name, Len) GetHostName(Name, Len)
+#define COMPILER_RT_GETHOSTNAME(Name, Len) lprofGetHostName(Name, Len)
 #define COMPILER_RT_HAS_UNAME 1
 #endif
 
@@ -53,7 +53,7 @@
 #endif
 #else /* COMPILER_RT_HAS_ATOMICS != 1 */
 #define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV)                              \
-  BoolCmpXchg((void **)Ptr, OldV, NewV)
+  lprofBoolCmpXchg((void **)Ptr, OldV, NewV)
 #endif
 
 #define PROF_ERR(Format, ...)                                                  \
index b7892d841f15ee7c523aa7a6abfd6eff52f5c67d..59b17511ca3fb878e7369736a5f7668c4dc54a5d 100644 (file)
@@ -37,7 +37,7 @@ void __llvm_profile_recursive_mkdir(char *path) {
 
 #if COMPILER_RT_HAS_ATOMICS != 1
 COMPILER_RT_VISIBILITY
-uint32_t BoolCmpXchg(void **Ptr, void *OldV, void *NewV) {
+uint32_t lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV) {
   void *R = *Ptr;
   if (R == OldV) {
     *Ptr = NewV;
index 93879bbc8c1237c9d4a553feaafa16879684d9ee..18b3f34640bd7fdefece2519b4627dd93cc91497 100644 (file)
@@ -20,9 +20,9 @@ uint32_t VPBufferSize = 0;
 /* The buffer writer is reponsponsible in keeping writer state
  * across the call.
  */
-COMPILER_RT_VISIBILITY uint32_t llvmBufferWriter(ProfDataIOVec *IOVecs,
-                                                 uint32_t NumIOVecs,
-                                                 void **WriterCtx) {
+COMPILER_RT_VISIBILITY uint32_t lprofBufferWriter(ProfDataIOVec *IOVecs,
+                                                  uint32_t NumIOVecs,
+                                                  void **WriterCtx) {
   uint32_t I;
   char **Buffer = (char **)WriterCtx;
   for (I = 0; I < NumIOVecs; I++) {
@@ -43,7 +43,7 @@ static void llvmInitBufferIO(ProfBufferIO *BufferIO, WriterCallback FileWriter,
 }
 
 COMPILER_RT_VISIBILITY ProfBufferIO *
-llvmCreateBufferIO(WriterCallback FileWriter, void *File, uint32_t BufferSz) {
+lprofCreateBufferIO(WriterCallback FileWriter, void *File, uint32_t BufferSz) {
   ProfBufferIO *BufferIO = (ProfBufferIO *)CallocHook(1, sizeof(ProfBufferIO));
   uint8_t *Buffer = (uint8_t *)CallocHook(1, BufferSz);
   if (!Buffer) {
@@ -54,17 +54,17 @@ llvmCreateBufferIO(WriterCallback FileWriter, void *File, uint32_t BufferSz) {
   return BufferIO;
 }
 
-COMPILER_RT_VISIBILITY void llvmDeleteBufferIO(ProfBufferIO *BufferIO) {
+COMPILER_RT_VISIBILITY void lprofDeleteBufferIO(ProfBufferIO *BufferIO) {
   FreeHook(BufferIO->BufferStart);
   FreeHook(BufferIO);
 }
 
 COMPILER_RT_VISIBILITY int
-llvmBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data, uint32_t Size) {
+lprofBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data, uint32_t Size) {
   /* Buffer is not large enough, it is time to flush.  */
   if (Size + BufferIO->CurOffset > BufferIO->BufferSz) {
-     if (llvmBufferIOFlush(BufferIO) != 0)
-       return -1;
+    if (lprofBufferIOFlush(BufferIO) != 0)
+      return -1;
   }
   /* Special case, bypass the buffer completely. */
   ProfDataIOVec IO[] = {{Data, sizeof(uint8_t), Size}};
@@ -74,13 +74,13 @@ llvmBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data, uint32_t Size) {
   } else {
     /* Write the data to buffer */
     uint8_t *Buffer = BufferIO->BufferStart + BufferIO->CurOffset;
-    llvmBufferWriter(IO, 1, (void **)&Buffer);
+    lprofBufferWriter(IO, 1, (void **)&Buffer);
     BufferIO->CurOffset = Buffer - BufferIO->BufferStart;
   }
   return 0;
 }
 
-COMPILER_RT_VISIBILITY int llvmBufferIOFlush(ProfBufferIO *BufferIO) {
+COMPILER_RT_VISIBILITY int lprofBufferIOFlush(ProfBufferIO *BufferIO) {
   if (BufferIO->CurOffset) {
     ProfDataIOVec IO[] = {
         {BufferIO->BufferStart, sizeof(uint8_t), BufferIO->CurOffset}};
@@ -91,10 +91,10 @@ COMPILER_RT_VISIBILITY int llvmBufferIOFlush(ProfBufferIO *BufferIO) {
   return 0;
 }
 
-COMPILER_RT_VISIBILITY int llvmWriteProfData(WriterCallback Writer,
-                                             void *WriterCtx,
-                                             ValueProfData **ValueDataArray,
-                                             const uint64_t ValueDataSize) {
+COMPILER_RT_VISIBILITY int lprofWriteData(WriterCallback Writer,
+                                          void *WriterCtx,
+                                          ValueProfData **ValueDataArray,
+                                          const uint64_t ValueDataSize) {
   /* Match logic in __llvm_profile_write_buffer(). */
   const __llvm_profile_data *DataBegin = __llvm_profile_begin_data();
   const __llvm_profile_data *DataEnd = __llvm_profile_end_data();
@@ -102,9 +102,9 @@ COMPILER_RT_VISIBILITY int llvmWriteProfData(WriterCallback Writer,
   const uint64_t *CountersEnd = __llvm_profile_end_counters();
   const char *NamesBegin = __llvm_profile_begin_names();
   const char *NamesEnd = __llvm_profile_end_names();
-  return llvmWriteProfDataImpl(Writer, WriterCtx, DataBegin, DataEnd,
-                               CountersBegin, CountersEnd, ValueDataArray,
-                               ValueDataSize, NamesBegin, NamesEnd);
+  return lprofWriteDataImpl(Writer, WriterCtx, DataBegin, DataEnd,
+                            CountersBegin, CountersEnd, ValueDataArray,
+                            ValueDataSize, NamesBegin, NamesEnd);
 }
 
 #define VP_BUFFER_SIZE 8 * 1024
@@ -118,30 +118,31 @@ static int writeValueProfData(WriterCallback Writer, void *WriterCtx,
     return 0;
 
   BufferSz = VPBufferSize ? VPBufferSize : VP_BUFFER_SIZE;
-  BufferIO = llvmCreateBufferIO(Writer, WriterCtx, BufferSz);
+  BufferIO = lprofCreateBufferIO(Writer, WriterCtx, BufferSz);
 
   for (I = 0; I < NumVData; I++) {
     ValueProfData *CurVData = ValueDataBegin[I];
     if (!CurVData)
       continue;
-    if (llvmBufferIOWrite(BufferIO, (const uint8_t *)CurVData,
-                          CurVData->TotalSize) != 0)
+    if (lprofBufferIOWrite(BufferIO, (const uint8_t *)CurVData,
+                           CurVData->TotalSize) != 0)
       return -1;
   }
 
-  if (llvmBufferIOFlush(BufferIO) != 0)
+  if (lprofBufferIOFlush(BufferIO) != 0)
     return -1;
-  llvmDeleteBufferIO(BufferIO);
+  lprofDeleteBufferIO(BufferIO);
 
   return 0;
 }
 
-COMPILER_RT_VISIBILITY int llvmWriteProfDataImpl(
-    WriterCallback Writer, void *WriterCtx,
-    const __llvm_profile_data *DataBegin, const __llvm_profile_data *DataEnd,
-    const uint64_t *CountersBegin, const uint64_t *CountersEnd,
-    ValueProfData **ValueDataBegin, const uint64_t ValueDataSize,
-    const char *NamesBegin, const char *NamesEnd) {
+COMPILER_RT_VISIBILITY int
+lprofWriteDataImpl(WriterCallback Writer, void *WriterCtx,
+                   const __llvm_profile_data *DataBegin,
+                   const __llvm_profile_data *DataEnd,
+                   const uint64_t *CountersBegin, const uint64_t *CountersEnd,
+                   ValueProfData **ValueDataBegin, const uint64_t ValueDataSize,
+                   const char *NamesBegin, const char *NamesEnd) {
 
   /* Calculate size of sections. */
   const uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);
index 0c2a64fd1f4d79e45f28291c8c516722738052b4..aac716f6d64f733a0525643e257680edb7f1a7cd 100644 (file)
@@ -16,9 +16,9 @@ void __llvm_profile_merge_from_buffer(const char *, uint64_t);
 void __llvm_profile_set_filename(const char *);
 struct __llvm_profile_data;
 struct ValueProfData;
-void mergeValueProfData(struct ValueProfData *, struct __llvm_profile_data *);
+void lprofMergeValueProfData(struct ValueProfData *, struct __llvm_profile_data *);
 /* Force the vp merger module to be linked in.  */
-void *Dummy = &mergeValueProfData;
+void *Dummy = &lprofMergeValueProfData;
 
 void callee1() {}
 void callee2() {}
index eed548fd0da27ddbb6b02c68804a10f40249fdd6..a55c8ab719a8825a1f8c988fb0225a1f0e1aa005 100644 (file)
 
 typedef struct ProfBufferIO ProfBufferIO;
 ProfBufferIO *llvmCreateBufferIOInternal(FILE *File, uint32_t DefaultBufferSz);
-void llvmDeleteBufferIO(ProfBufferIO *BufferIO);
+void lprofDeleteBufferIO(ProfBufferIO *BufferIO);
 
-int llvmBufferIOWrite(ProfBufferIO *BufferIO, const char *Data, uint32_t Size);
-int llvmBufferIOFlush(ProfBufferIO *BufferIO);
+int lprofBufferIOWrite(ProfBufferIO *BufferIO, const char *Data, uint32_t Size);
+int lprofBufferIOFlush(ProfBufferIO *BufferIO);
 
 int __llvm_profile_runtime = 0;
 
@@ -42,34 +42,34 @@ int main(int argc, const char *argv[]) {
     if (!File[J])
       return 1;
 
-    BufferIO = llvmCreateBufferIOInternal(File[J], IOBufferSize[J]);
+    BufferIO = lprofCreateBufferIOInternal(File[J], IOBufferSize[J]);
 
-    llvmBufferIOWrite(BufferIO, "Short Strings:\n", strlen("Short Strings:\n"));
+    lprofBufferIOWrite(BufferIO, "Short Strings:\n", strlen("Short Strings:\n"));
     for (I = 0; I < 1024; I++) {
-      llvmBufferIOWrite(BufferIO, SmallData, strlen(SmallData));
+      lprofBufferIOWrite(BufferIO, SmallData, strlen(SmallData));
     }
-    llvmBufferIOWrite(BufferIO, "Long Strings:\n", strlen("Long Strings:\n"));
+    lprofBufferIOWrite(BufferIO, "Long Strings:\n", strlen("Long Strings:\n"));
     for (I = 0; I < 1024; I++) {
-      llvmBufferIOWrite(BufferIO, MediumData, strlen(MediumData));
+      lprofBufferIOWrite(BufferIO, MediumData, strlen(MediumData));
     }
-    llvmBufferIOWrite(BufferIO, "Extra Long Strings:\n",
+    lprofBufferIOWrite(BufferIO, "Extra Long Strings:\n",
                       strlen("Extra Long Strings:\n"));
     for (I = 0; I < 10; I++) {
-      llvmBufferIOWrite(BufferIO, LargeData, strlen(LargeData));
+      lprofBufferIOWrite(BufferIO, LargeData, strlen(LargeData));
     }
-    llvmBufferIOWrite(BufferIO, "Mixed Strings:\n", strlen("Mixed Strings:\n"));
+    lprofBufferIOWrite(BufferIO, "Mixed Strings:\n", strlen("Mixed Strings:\n"));
     for (I = 0; I < 1024; I++) {
-      llvmBufferIOWrite(BufferIO, MediumData, strlen(MediumData));
-      llvmBufferIOWrite(BufferIO, SmallData, strlen(SmallData));
+      lprofBufferIOWrite(BufferIO, MediumData, strlen(MediumData));
+      lprofBufferIOWrite(BufferIO, SmallData, strlen(SmallData));
     }
-    llvmBufferIOWrite(BufferIO, "Endings:\n", strlen("Endings:\n"));
-    llvmBufferIOWrite(BufferIO, "END\n", strlen("END\n"));
-    llvmBufferIOWrite(BufferIO, "ENDEND\n", strlen("ENDEND\n"));
-    llvmBufferIOWrite(BufferIO, "ENDENDEND\n", strlen("ENDENDEND\n"));
-    llvmBufferIOWrite(BufferIO, "ENDENDENDEND\n", strlen("ENDENDENDEND\n"));
-    llvmBufferIOFlush(BufferIO);
+    lprofBufferIOWrite(BufferIO, "Endings:\n", strlen("Endings:\n"));
+    lprofBufferIOWrite(BufferIO, "END\n", strlen("END\n"));
+    lprofBufferIOWrite(BufferIO, "ENDEND\n", strlen("ENDEND\n"));
+    lprofBufferIOWrite(BufferIO, "ENDENDEND\n", strlen("ENDENDEND\n"));
+    lprofBufferIOWrite(BufferIO, "ENDENDENDEND\n", strlen("ENDENDENDEND\n"));
+    lprofBufferIOFlush(BufferIO);
 
-    llvmDeleteBufferIO(BufferIO);
+    lprofDeleteBufferIO(BufferIO);
 
     fclose(File[J]);
   }