[PATCH] D40627: [asan] Use linker initialization for the allocator

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 29 16:00:26 PST 2017


kubamracek created this revision.
kubamracek added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

This saves ~2 MB of dirty memory footprint. Can be a big deal on mobile devices especially when running multiple processes with ASan.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D40627

Files:
  lib/asan/asan_allocator.cc


Index: lib/asan/asan_allocator.cc
===================================================================
--- lib/asan/asan_allocator.cc
+++ lib/asan/asan_allocator.cc
@@ -274,9 +274,12 @@
     atomic_store(&max_redzone, options.max_redzone, memory_order_release);
   }
 
-  void Initialize(const AllocatorOptions &options) {
+  void Initialize(const AllocatorOptions &options, bool linker_initialized) {
     SetAllocatorMayReturnNull(options.may_return_null);
-    allocator.Init(options.release_to_os_interval_ms);
+    if (linker_initialized)
+      allocator.InitLinkerInitialized(options.release_to_os_interval_ms);
+    else
+      allocator.Init(options.release_to_os_interval_ms);
     SharedInitCode(options);
   }
 
@@ -817,7 +820,7 @@
 }
 
 void InitializeAllocator(const AllocatorOptions &options) {
-  instance.Initialize(options);
+  instance.Initialize(options, /*linker_initialized*/ false);
 }
 
 void ReInitializeAllocator(const AllocatorOptions &options) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40627.124844.patch
Type: text/x-patch
Size: 973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/44925a37/attachment.bin>


More information about the llvm-commits mailing list