Replace shadow space zero-out by madvise at mmap
authorJianzhou Zhao <jianzhouzh@google.com>
Mon, 5 Oct 2020 16:56:50 +0000 (16:56 +0000)
committerJianzhou Zhao <jianzhouzh@google.com>
Tue, 6 Oct 2020 21:29:50 +0000 (21:29 +0000)
commit4d1d8ae7100ec3c7e1709addb7b3ec6f9ad0b44f
treea98e18a2d15ee79d8a81f431474ceef1b3bfc4cb
parent4540d6624838af2b190dfb33802528eb4bfb3fb8
Replace shadow space zero-out by madvise at mmap

After D88686, munmap uses MADV_DONTNEED to ensure zero-out before the
next access. Because the entire shadow space is created by MAP_PRIVATE
and MAP_ANONYMOUS, the first access is also on zero-filled values.

So it is fine to not zero-out data, but use madvise(MADV_DONTNEED) at
mmap. This reduces runtime
overhead.

Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D88755
compiler-rt/lib/dfsan/dfsan_interceptors.cpp
compiler-rt/test/dfsan/munmap_release_shadow.c [deleted file]
compiler-rt/test/dfsan/release_shadow_space.c [new file with mode: 0644]