[compiler-rt] Fix 16-byte alignment for vec allocators on AIX (PR #184967)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 00:27:15 PST 2026


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 origin/main HEAD --extensions cpp,h -- compiler-rt/test/asan/TestCases/AIX/vec_alloc_align.cpp compiler-rt/lib/asan/asan_allocator.cpp compiler-rt/lib/asan/asan_allocator.h compiler-rt/lib/asan/asan_malloc_linux.cpp compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/compiler-rt/lib/asan/asan_allocator.cpp b/compiler-rt/lib/asan/asan_allocator.cpp
index cce89adb1..b66ad90be 100644
--- a/compiler-rt/lib/asan/asan_allocator.cpp
+++ b/compiler-rt/lib/asan/asan_allocator.cpp
@@ -783,12 +783,12 @@ struct Allocator {
     AsanStats &thread_stats = GetCurrentThreadStats();
     thread_stats.reallocs++;
     thread_stats.realloced += new_size;
-    
+
     // Preserve the original allocation's alignment
     uptr orig_align = ComputeUserAlignment(m->user_requested_alignment_log);
     if (orig_align < 8)
       orig_align = 8;
-    void *new_ptr = Allocate(new_size, orig_align, stack, FROM_MALLOC, true);
+    void* new_ptr = Allocate(new_size, orig_align, stack, FROM_MALLOC, true);
     if (new_ptr) {
       u8 chunk_state = atomic_load(&m->chunk_state, memory_order_acquire);
       if (chunk_state != CHUNK_ALLOCATED)
@@ -1066,7 +1066,8 @@ void* asan_vec_calloc(uptr nmemb, uptr size, BufferedStackTrace* stack) {
 
 void* asan_vec_realloc(void* p, uptr size, BufferedStackTrace* stack) {
   if (!p)
-    return SetErrnoOnNull(instance.Allocate(size, 16, stack, FROM_MALLOC, true));
+    return SetErrnoOnNull(
+        instance.Allocate(size, 16, stack, FROM_MALLOC, true));
   return asan_realloc(p, size, stack);
 }
 #endif
diff --git a/compiler-rt/lib/asan/asan_malloc_linux.cpp b/compiler-rt/lib/asan/asan_malloc_linux.cpp
index 8c5b19dd3..3934c535f 100644
--- a/compiler-rt/lib/asan/asan_malloc_linux.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_linux.cpp
@@ -54,12 +54,12 @@ INTERCEPTOR(void, free, void *ptr) {
 
 #if SANITIZER_INTERCEPT_CFREE
 INTERCEPTOR(void*, __linux_vec_malloc, uptr size) {
-   if (DlsymAlloc::Use())
-     return DlsymAlloc::Allocate(size, 16);
-   AsanInitFromRtl();
-   GET_STACK_TRACE_MALLOC;
-   return asan_vec_malloc(size, &stack);
- }
+  if (DlsymAlloc::Use())
+    return DlsymAlloc::Allocate(size, 16);
+  AsanInitFromRtl();
+  GET_STACK_TRACE_MALLOC;
+  return asan_vec_malloc(size, &stack);
+}
 
 INTERCEPTOR(void*, __linux_vec_calloc, uptr nmemb, uptr size) {
   if (DlsymAlloc::Use())
@@ -114,33 +114,33 @@ INTERCEPTOR(void*, malloc, uptr size) {
   if (DlsymAlloc::Use())
     return DlsymAlloc::Allocate(size, SANITIZER_AIX ? 16 : kWordSize);
   GET_STACK_TRACE_MALLOC;
-#if SANITIZER_AIX
+#  if SANITIZER_AIX
   return asan_vec_malloc(size, &stack);
-#else
+#  else
   return asan_malloc(size, &stack);
-#endif
+#  endif
 }
 
 INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) {
   if (DlsymAlloc::Use())
     return DlsymAlloc::Callocate(nmemb, size, SANITIZER_AIX ? 16 : kWordSize);
   GET_STACK_TRACE_MALLOC;
-#if SANITIZER_AIX
+#  if SANITIZER_AIX
   return asan_vec_calloc(nmemb, size, &stack);
-#else
+#  else
   return asan_calloc(nmemb, size, &stack);
-#endif
+#  endif
 }
 
 INTERCEPTOR(void*, realloc, void *ptr, uptr size) {
   if (DlsymAlloc::Use() || DlsymAlloc::PointerIsMine(ptr))
     return DlsymAlloc::Realloc(ptr, size, SANITIZER_AIX ? 16 : kWordSize);
   GET_STACK_TRACE_MALLOC;
-#if SANITIZER_AIX
+#  if SANITIZER_AIX
   return asan_vec_realloc(ptr, size, &stack);
-#else
+#  else
   return asan_realloc(ptr, size, &stack);
-#endif
+#  endif
 }
 
 #if SANITIZER_INTERCEPT_REALLOCARRAY
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h
index f2d014142..2e8e2b121 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h
@@ -53,7 +53,7 @@ struct DlSymAllocator {
     InternalFree(ptr);
   }
 
-  static void *Realloc(void *ptr, uptr new_size, uptr align = kWordSize){
+  static void* Realloc(void* ptr, uptr new_size, uptr align = kWordSize) {
     if (!ptr)
       return Allocate(new_size, align);
     CHECK(internal_allocator()->FromPrimary(ptr));
@@ -63,7 +63,7 @@ struct DlSymAllocator {
     }
     uptr size = GetSize(ptr);
     uptr memcpy_size = Min(new_size, size);
-    void *new_ptr = Allocate(new_size, align);
+    void* new_ptr = Allocate(new_size, align);
     if (new_ptr)
       internal_memcpy(new_ptr, ptr, memcpy_size);
     Free(ptr);

``````````

</details>


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


More information about the llvm-commits mailing list