[compiler-rt] [scudo] Use variable instead of recomputing. (PR #106647)

Christopher Ferris via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 29 17:30:24 PDT 2024


https://github.com/cferris1000 created https://github.com/llvm/llvm-project/pull/106647

In the getStats() function, there is already a variable that computes the in use bytes, so use that instead of recomputing it.

>From 7da9d74cde740148e22958f8a124af1e2cf31ad8 Mon Sep 17 00:00:00 2001
From: Christopher Ferris <cferris at google.com>
Date: Thu, 29 Aug 2024 17:21:53 -0700
Subject: [PATCH] [scudo] Use variable instead of recomputing.

In the getStats() function, there is already a variable that
computes the in use bytes, so use that instead of recomputing it.
---
 compiler-rt/lib/scudo/standalone/primary32.h | 2 +-
 compiler-rt/lib/scudo/standalone/primary64.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/lib/scudo/standalone/primary32.h b/compiler-rt/lib/scudo/standalone/primary32.h
index ebfb8dfe0a31f4..87264471be2c1a 100644
--- a/compiler-rt/lib/scudo/standalone/primary32.h
+++ b/compiler-rt/lib/scudo/standalone/primary32.h
@@ -940,7 +940,7 @@ template <typename Config> class SizeClassAllocator32 {
 
     uptr Integral;
     uptr Fractional;
-    computePercentage(BlockSize * InUseBlocks, InUsePages * PageSize, &Integral,
+    computePercentage(BlockSize * InUseBlocks, InUseBytes, &Integral,
                       &Fractional);
     Str->append("  %02zu (%6zu): inuse/total blocks: %6zu/%6zu inuse/total "
                 "pages: %6zu/%6zu inuse bytes: %6zuK util: %3zu.%02zu%%\n",
diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h
index 8436f33c2fdcfc..ffcc22fea0c6ea 100644
--- a/compiler-rt/lib/scudo/standalone/primary64.h
+++ b/compiler-rt/lib/scudo/standalone/primary64.h
@@ -1185,7 +1185,7 @@ template <typename Config> class SizeClassAllocator64 {
 
     uptr Integral;
     uptr Fractional;
-    computePercentage(BlockSize * InUseBlocks, InUsePages * PageSize, &Integral,
+    computePercentage(BlockSize * InUseBlocks, InUseBytes, &Integral,
                       &Fractional);
     Str->append("  %02zu (%6zu): inuse/total blocks: %6zu/%6zu inuse/total "
                 "pages: %6zu/%6zu inuse bytes: %6zuK util: %3zu.%02zu%%\n",



More information about the llvm-commits mailing list