[compiler-rt] [MemProf][NFC] Compute SHADOW_ENTRY_SIZE from MEM_GRANULARITY and SHA… (PR #80589)

via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 3 23:29:45 PST 2024


https://github.com/Enna1 created https://github.com/llvm/llvm-project/pull/80589

…DOW_SCALE

As MEM_GRANULARITY represents the size of memory block mapped to a single shadow entry, and SHADOW_SCALE represents the scale of shadow mapping, so the single shadow entry size can be computed as (MEM_GRANULARITY >> SHADOW_SCALE).

This patch replaces the hardcoded SHADOW_ENTRY_SIZE with (MEM_GRANULARITY >> SHADOW_SCALE).

>From f1b7d0b2f4b001904dd08ade2425db1943505a1f Mon Sep 17 00:00:00 2001
From: "xumingjie.enna1" <xumingjie.enna1 at bytedance.com>
Date: Sun, 4 Feb 2024 15:05:38 +0800
Subject: [PATCH] [MemProf][NFC] Compute SHADOW_ENTRY_SIZE from MEM_GRANULARITY
 and SHADOW_SCALE

As MEM_GRANULARITY represents the size of memory block mapped to a single shadow entry,
and SHADOW_SCALE represents the scale of shadow mapping,
so the single shadow entry size can be computed as (MEM_GRANULARITY >> SHADOW_SCALE).

This patch replaces the hardcoded SHADOW_ENTRY_SIZE with (MEM_GRANULARITY >> SHADOW_SCALE).
---
 compiler-rt/lib/memprof/memprof_mapping.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/lib/memprof/memprof_mapping.h b/compiler-rt/lib/memprof/memprof_mapping.h
index ba05b88db3070..1cc0836834cdf 100644
--- a/compiler-rt/lib/memprof/memprof_mapping.h
+++ b/compiler-rt/lib/memprof/memprof_mapping.h
@@ -29,8 +29,6 @@ extern uptr kHighMemEnd; // Initialized in __memprof_init.
 
 } // namespace __memprof
 
-#define SHADOW_ENTRY_SIZE 8
-
 // Size of memory block mapped to a single shadow location
 #define MEM_GRANULARITY 64ULL
 
@@ -39,6 +37,8 @@ extern uptr kHighMemEnd; // Initialized in __memprof_init.
 #define MEM_TO_SHADOW(mem)                                                     \
   ((((mem) & SHADOW_MASK) >> SHADOW_SCALE) + (SHADOW_OFFSET))
 
+#define SHADOW_ENTRY_SIZE (MEM_GRANULARITY >> SHADOW_SCALE)
+
 #define kLowMemBeg 0
 #define kLowMemEnd (SHADOW_OFFSET ? SHADOW_OFFSET - 1 : 0)
 



More information about the llvm-commits mailing list