[PATCH] D34152: [sanitizer] MmapAlignedOrDie changes to reduce fragmentation

Kostya Serebryany via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 10:48:49 PDT 2017


kcc added inline comments.


================
Comment at: lib/sanitizer_common/tests/sanitizer_common_test.cc:130
+        }
+      }
+    }
----------------
alekseyshl wrote:
> Since the structure of the test is the same, maybe we should move #if#else#endinf into the loop?I mean, ifdef'ing only lines 100-103 and 118-129?
> 
> 
>         EXPECT_EQ(0U, res % (alignment * PageSize));
>         internal_memset((void*)res, 1, size * PageSize);
>   #if SANITIZER_WINDOWS
>         // padding_chunk is not supported on Windows.
>         EXPECT_EQ(0U, padding_chunk);
>         UnmapOrDie((void*)res, size * PageSize);
>   #else
>         if (size == 1 && alignment == 1) {
>           // mmap returns PageSize aligned chunks, so this is a specific case
>           // where we can check that padding_chunk will never be 0.
>           EXPECT_NE(0U, padding_chunk);
>         }
>         if (padding_chunk) {
>           EXPECT_EQ(res + size * PageSize, padding_chunk);
>           internal_memset((void*)padding_chunk, 1, alignment * PageSize);
>           UnmapOrDie((void*)padding_chunk, alignment * PageSize);
>         }
>   #endif
Try to avoid #if at all costs, even in tests. 
In this case, I am pretty sure you can do 

   if(SANITIZER_WINDOWS)

instead. 


https://reviews.llvm.org/D34152





More information about the llvm-commits mailing list