[compiler-rt] [win/asan] Search both higher and lower in AllocateTrampolineRegion (PR #114212)
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 09:51:03 PDT 2024
================
@@ -340,32 +347,66 @@ struct TrampolineMemoryRegion {
uptr max_size;
};
-UNUSED static const uptr kTrampolineScanLimitRange = 1ull << 31; // 2 gig
+UNUSED static const uptr kTrampolineRangeLimit = 1ull << 31; // 2 gig
static const int kMaxTrampolineRegion = 1024;
static TrampolineMemoryRegion TrampolineRegions[kMaxTrampolineRegion];
-static void *AllocateTrampolineRegion(uptr image_address, size_t granularity) {
-#if SANITIZER_WINDOWS64
- uptr address = image_address;
- uptr scanned = 0;
- while (scanned < kTrampolineScanLimitRange) {
+static void *AllocateTrampolineRegion(uptr min_addr, uptr max_addr,
+ uptr func_addr, size_t granularity) {
+# if SANITIZER_WINDOWS64
+ // Clamp {min,max}_addr to the accessible address space.
+ SYSTEM_INFO system_info;
+ ::GetSystemInfo(&system_info);
----------------
rnk wrote:
The call site here calls `GetMmapGranularity`, which also calls `GetSystemInfo`. Can we do `GetSystemInfo` once outside the loop, and store this information about the address space (mmap_granularity, addrspace_start, addrspace_end) in global variables? The performance gain is marginal, it's mostly to have fewer parameters and locals in this function.
https://github.com/llvm/llvm-project/pull/114212
More information about the llvm-commits
mailing list