[compiler-rt] Fixed __llvm_profile_write_buffer in presence of ValueProfileData. (PR #97350)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 14:33:38 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 938cbdb4cf428bf08558c24d845aeac9174c7022 51d551ae53985cd3bd2ecc703f9419a7b77c8d00 -- compiler-rt/test/profile/instrprof-write-buffer.c compiler-rt/lib/profile/InstrProfilingBuffer.c compiler-rt/lib/profile/InstrProfilingInternal.h compiler-rt/lib/profile/InstrProfilingWriter.c compiler-rt/test/profile/instrprof-without-libc.c
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/compiler-rt/lib/profile/InstrProfilingBuffer.c b/compiler-rt/lib/profile/InstrProfilingBuffer.c
index b4c3399477..8fb9e9c95e 100644
--- a/compiler-rt/lib/profile/InstrProfilingBuffer.c
+++ b/compiler-rt/lib/profile/InstrProfilingBuffer.c
@@ -249,10 +249,10 @@ COMPILER_RT_VISIBILITY int __llvm_profile_write_buffer(char *Buffer) {
   const __llvm_profile_data *DataBegin = __llvm_profile_begin_data();
   const __llvm_profile_data *DataEnd = __llvm_profile_end_data();
   VPDataReaderType *Reader = lprofGetVPDataReader();
-  if (__llvm_profile_getSizeOfValueProfData(Reader,DataBegin, DataEnd) < 0) {
+  if (__llvm_profile_getSizeOfValueProfData(Reader, DataBegin, DataEnd) < 0) {
     /* Attempt to use lprofGetVPDataReader will result in an error, so
      * do not use it. Generate profile data without VPDataReader.
-    */
+     */
     Reader = 0;
   }
   return lprofWriteData(&BufferWriter, Reader, 0);
diff --git a/compiler-rt/lib/profile/InstrProfilingInternal.h b/compiler-rt/lib/profile/InstrProfilingInternal.h
index 0bf642b54f..0bb7b86c64 100644
--- a/compiler-rt/lib/profile/InstrProfilingInternal.h
+++ b/compiler-rt/lib/profile/InstrProfilingInternal.h
@@ -172,7 +172,8 @@ void lprofMergeValueProfData(struct ValueProfData *SrcValueProfData,
 VPDataReaderType *lprofGetVPDataReader();
 
 /* Compute size of VPData. Return -1 on error (0 is a valid return value). */
-int64_t __llvm_profile_getSizeOfValueProfData(VPDataReaderType *VPDataReader,
+int64_t
+__llvm_profile_getSizeOfValueProfData(VPDataReaderType *VPDataReader,
                                       const __llvm_profile_data *DataBegin,
                                       const __llvm_profile_data *DataEnd);
 
diff --git a/compiler-rt/lib/profile/InstrProfilingWriter.c b/compiler-rt/lib/profile/InstrProfilingWriter.c
index 4cfa2d1e96..bb7a911aec 100644
--- a/compiler-rt/lib/profile/InstrProfilingWriter.c
+++ b/compiler-rt/lib/profile/InstrProfilingWriter.c
@@ -250,8 +250,6 @@ __llvm_profile_getSizeOfValueProfData(VPDataReaderType *VPDataReader,
   return rv;
 }
 
-
-
 static int writeValueProfData(ProfDataWriter *Writer,
                               VPDataReaderType *VPDataReader,
                               const __llvm_profile_data *DataBegin,
diff --git a/compiler-rt/test/profile/instrprof-write-buffer.c b/compiler-rt/test/profile/instrprof-write-buffer.c
index 79fba78394..90dd0e2bb8 100755
--- a/compiler-rt/test/profile/instrprof-write-buffer.c
+++ b/compiler-rt/test/profile/instrprof-write-buffer.c
@@ -12,17 +12,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-void threadFunc(void* callback) // Needed for failure.
+void threadFunc(void *callback) // Needed for failure.
 {
-  typedef void (FuncPtr)();
-  (*(FuncPtr*)callback)();
+  typedef void(FuncPtr)();
+  (*(FuncPtr *)callback)();
 }
 
 uint64_t __llvm_profile_get_size_for_buffer();
-int __llvm_profile_write_buffer(char*);
+int __llvm_profile_write_buffer(char *);
 
-int main(int argc, const char *argv[])
-{
+int main(int argc, const char *argv[]) {
   // Write to a buffer, and write that to a file.
   uint64_t bufsize = __llvm_profile_get_size_for_buffer();
   char *buf = malloc(bufsize);

``````````

</details>


https://github.com/llvm/llvm-project/pull/97350


More information about the llvm-commits mailing list