[llvm-commits] [compiler-rt] r151526 - in /compiler-rt/trunk/lib/asan: asan_allocator.cc asan_internal.h asan_rtl.cc tests/asan_test.cc
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Mon Feb 27 05:07:29 PST 2012
Author: eugenis
Date: Mon Feb 27 07:07:29 2012
New Revision: 151526
URL: http://llvm.org/viewvc/llvm-project?rev=151526&view=rev
Log:
Replace some #ifdef(s) with plain if(s).
Modified:
compiler-rt/trunk/lib/asan/asan_allocator.cc
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/tests/asan_test.cc
Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=151526&r1=151525&r2=151526&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Mon Feb 27 07:07:29 2012
@@ -46,24 +46,17 @@
static const uint64_t kMaxAvailableRam = 128ULL << 30; // 128G
static const size_t kMaxThreadLocalQuarantine = 1 << 20; // 1M
-#if ASAN_LOW_MEMORY == 1
-static const size_t kMinMmapSize = 4UL << 17; // 128K
- static const size_t kMaxSizeForThreadLocalFreeList = 1 << 15; // 32K
-#else
-static const size_t kMinMmapSize = 4UL << 20; // 4M
- static const size_t kMaxSizeForThreadLocalFreeList = 1 << 17; // 128K
-#endif
+static const size_t kMinMmapSize = (ASAN_LOW_MEMORY) ? 4UL << 17 : 4UL << 20;
+static const size_t kMaxSizeForThreadLocalFreeList =
+ (ASAN_LOW_MEMORY) ? 1 << 15 : 1 << 17;
// Size classes less than kMallocSizeClassStep are powers of two.
// All other size classes are multiples of kMallocSizeClassStep.
static const size_t kMallocSizeClassStepLog = 26;
static const size_t kMallocSizeClassStep = 1UL << kMallocSizeClassStepLog;
-#if __WORDSIZE == 32
-static const size_t kMaxAllowedMallocSize = 3UL << 30; // 3G
-#else
-static const size_t kMaxAllowedMallocSize = 8UL << 30; // 8G
-#endif
+static const size_t kMaxAllowedMallocSize =
+ (__WORDSIZE == 32) ? 3UL << 30 : 8UL << 30;
static inline bool IsAligned(uintptr_t a, uintptr_t alignment) {
return (a & (alignment - 1)) == 0;
Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151526&r1=151525&r2=151526&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Mon Feb 27 07:07:29 2012
@@ -129,6 +129,12 @@
# define ASAN_FLEXIBLE_MAPPING_AND_OFFSET 0
#endif
+// If set, values like allocator chunk size, as well as defaults for some flags
+// will be changed towards less memory overhead.
+#ifndef ASAN_LOW_MEMORY
+# define ASAN_LOW_MEMORY 0
+#endif
+
// All internal functions in asan reside inside the __asan namespace
// to avoid namespace collisions with the user programs.
// Seperate namespace also makes it simpler to distinguish the asan run-time
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=151526&r1=151525&r2=151526&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Mon Feb 27 07:07:29 2012
@@ -410,15 +410,8 @@
FLAG_v = IntFlagValue(options, "verbosity=", 0);
-#if ASAN_LOW_MEMORY == 1
- FLAG_quarantine_size =
- IntFlagValue(options, "quarantine_size=", 1UL << 24); // 16M
- FLAG_redzone = IntFlagValue(options, "redzone=", 64);
-#else
- FLAG_quarantine_size =
- IntFlagValue(options, "quarantine_size=", 1UL << 28); // 256M
- FLAG_redzone = IntFlagValue(options, "redzone=", 128);
-#endif
+ FLAG_redzone = IntFlagValue(options, "redzone=",
+ (ASAN_LOW_MEMORY) ? 64 : 128);
CHECK(FLAG_redzone >= 32);
CHECK((FLAG_redzone & (FLAG_redzone - 1)) == 0);
@@ -443,6 +436,9 @@
Atexit(asan_atexit);
}
+ FLAG_quarantine_size = IntFlagValue(options, "quarantine_size=",
+ (ASAN_LOW_MEMORY) ? 1UL << 24 : 1UL << 28);
+
// interceptors
InitializeAsanInterceptors();
Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=151526&r1=151525&r2=151526&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Mon Feb 27 07:07:29 2012
@@ -453,11 +453,7 @@
}
TEST(AddressSanitizer, MallocStressTest) {
-#if ASAN_LOW_MEMORY == 1
- MallocStress(20000);
-#else
- MallocStress(200000);
-#endif
+ MallocStress((ASAN_LOW_MEMORY) ? 20000 : 200000);
}
static void TestLargeMalloc(size_t size) {
@@ -489,13 +485,11 @@
TEST(AddressSanitizer, ThreadedMallocStressTest) {
const int kNumThreads = 4;
+ const int kNumIterations = (ASAN_LOW_MEMORY) ? 10000 : 100000;
pthread_t t[kNumThreads];
for (int i = 0; i < kNumThreads; i++) {
-#if ASAN_LOW_MEMORY == 1
- pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)10000);
-#else
- pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)100000);
-#endif
+ pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress,
+ (void*)kNumIterations);
}
for (int i = 0; i < kNumThreads; i++) {
pthread_join(t[i], 0);
More information about the llvm-commits
mailing list