Skip to content

[MemProf][NFC] Compute SHADOW_ENTRY_SIZE from MEM_GRANULARITY and SHA… #80589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

Enna1
Copy link
Contributor

@Enna1 Enna1 commented Feb 4, 2024

…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).

…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).
@llvmbot llvmbot added compiler-rt PGO Profile Guided Optimizations labels Feb 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 4, 2024

@llvm/pr-subscribers-pgo

Author: Enna1 (Enna1)

Changes

…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).


Full diff: https://github.com/llvm/llvm-project/pull/80589.diff

1 Files Affected:

  • (modified) compiler-rt/lib/memprof/memprof_mapping.h (+2-2)
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)
 

@Enna1 Enna1 merged commit 397e91f into main Feb 6, 2024
@Enna1 Enna1 deleted the users/Enna1/memprof-compute-shadow-entry-size branch February 6, 2024 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants