diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2017-06-14 17:32:26 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2017-06-14 17:32:26 +0000 |
commit | 6cd1865e1d8bc8fd1cb62fe4ef51c8c908385609 (patch) | |
tree | ea136a4ed6ae9d22a95f3ec6ae62593a126beb7a /lib/sanitizer_common/sanitizer_posix.cc | |
parent | fccfd4523bbad39dfaf5e1a9dbf7491abbc80a22 (diff) |
[sanitizer] Reverting D34152
Summary:
This broke thread_local_quarantine_pthread_join.cc on some architectures, due
to the overhead of the stashed regions. Reverting while figuring out the best
way to deal with it.
Reviewers: alekseyshl
Reviewed By: alekseyshl
Subscribers: llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D34213
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@305404 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_posix.cc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_posix.cc | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/sanitizer_common/sanitizer_posix.cc b/lib/sanitizer_common/sanitizer_posix.cc index 3a6b711db..9916f4d38 100644 --- a/lib/sanitizer_common/sanitizer_posix.cc +++ b/lib/sanitizer_common/sanitizer_posix.cc @@ -146,29 +146,22 @@ void UnmapOrDie(void *addr, uptr size) { } // We want to map a chunk of address space aligned to 'alignment'. -// We do it by mapping a bit more and then unmapping redundant pieces. +// We do it by maping a bit more and then unmaping redundant pieces. // We probably can do it with fewer syscalls in some OS-dependent way. -void *MmapAlignedOrDie(uptr size, uptr alignment, const char *mem_type, - uptr* padding_chunk) { +void *MmapAlignedOrDie(uptr size, uptr alignment, const char *mem_type) { CHECK(IsPowerOfTwo(size)); CHECK(IsPowerOfTwo(alignment)); uptr map_size = size + alignment; uptr map_res = (uptr)MmapOrDie(map_size, mem_type); uptr map_end = map_res + map_size; - bool is_aligned = IsAligned(map_res, alignment); - if (is_aligned && padding_chunk && size == alignment) { - *padding_chunk = map_res + size; - return (void *)map_res; - } - if (padding_chunk) - *padding_chunk = 0; uptr res = map_res; - if (!is_aligned) { - res = (map_res + alignment - 1) & ~(alignment - 1); - UnmapOrDie((void*)map_res, res - map_res); - } + if (res & (alignment - 1)) // Not aligned. + res = (map_res + alignment) & ~(alignment - 1); uptr end = res + size; - UnmapOrDie((void*)end, map_end - end); + if (res != map_res) + UnmapOrDie((void*)map_res, res - map_res); + if (end != map_end) + UnmapOrDie((void*)end, map_end - end); return (void*)res; } |