[compiler-rt] 9343fc7 - [scudo] Use cast on calls to __builtin_umul_overflow/__builtin_umull_overflow

Dominic Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 28 16:36:41 PDT 2022


Author: Dominic Chen
Date: 2022-03-28T16:36:30-07:00
New Revision: 9343fc76133bfdd0e4003e58403a79b140ec1b25

URL: https://github.com/llvm/llvm-project/commit/9343fc76133bfdd0e4003e58403a79b140ec1b25
DIFF: https://github.com/llvm/llvm-project/commit/9343fc76133bfdd0e4003e58403a79b140ec1b25.diff

LOG: [scudo] Use cast on calls to __builtin_umul_overflow/__builtin_umull_overflow

Platforms may define uintptr_t differently, so perform an explicit cast

Differential Revision: https://reviews.llvm.org/D121852

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/wrappers_c_checks.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/wrappers_c_checks.h b/compiler-rt/lib/scudo/standalone/wrappers_c_checks.h
index ec9c1a104e83c..815d40023b6a2 100644
--- a/compiler-rt/lib/scudo/standalone/wrappers_c_checks.h
+++ b/compiler-rt/lib/scudo/standalone/wrappers_c_checks.h
@@ -47,9 +47,12 @@ inline bool checkPosixMemalignAlignment(uptr Alignment) {
 // costly division.
 inline bool checkForCallocOverflow(uptr Size, uptr N, uptr *Product) {
 #if __has_builtin(__builtin_umull_overflow) && (SCUDO_WORDSIZE == 64U)
-  return __builtin_umull_overflow(Size, N, Product);
+  return __builtin_umull_overflow(Size, N,
+                                  reinterpret_cast<unsigned long *>(Product));
 #elif __has_builtin(__builtin_umul_overflow) && (SCUDO_WORDSIZE == 32U)
-  return __builtin_umul_overflow(Size, N, Product);
+  // On, e.g. armv7, uptr/uintptr_t may be defined as unsigned long
+  return __builtin_umul_overflow(Size, N,
+                                 reinterpret_cast<unsigned int *>(Product));
 #else
   *Product = Size * N;
   if (!Size)


        


More information about the llvm-commits mailing list