[PATCH] D71342: [sanitizer] Construct InternalMmapVector without memory allocation.
Igor Kudrin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 11 03:14:13 PST 2019
ikudrin created this revision.
ikudrin added reviewers: kcc, samsonov, eugenis, vitalybuka, earthdok.
ikudrin added projects: Sanitizers, LLVM.
Construction of `InternalMmapVector` is often followed by a call to `reserve()`, which may result in immediate reallocation of the memory for the internal storage. This patch delays that allocation until it is really needed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71342
Files:
compiler-rt/lib/sanitizer_common/sanitizer_common.h
compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
Index: compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
+++ compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
@@ -131,7 +131,7 @@
EXPECT_EQ((uptr)i, vector.size());
}
InternalMmapVector<uptr> empty_vector;
- CHECK_GT(empty_vector.capacity(), 0U);
+ CHECK_EQ(empty_vector.capacity(), 0U);
CHECK_EQ(0U, empty_vector.size());
}
Index: compiler-rt/lib/sanitizer_common/sanitizer_common.h
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -552,7 +552,7 @@
template<typename T>
class InternalMmapVector : public InternalMmapVectorNoCtor<T> {
public:
- InternalMmapVector() { InternalMmapVectorNoCtor<T>::Initialize(1); }
+ InternalMmapVector() { InternalMmapVectorNoCtor<T>::Initialize(0); }
explicit InternalMmapVector(uptr cnt) {
InternalMmapVectorNoCtor<T>::Initialize(cnt);
this->resize(cnt);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71342.233304.patch
Type: text/x-patch
Size: 1130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191211/231f5b6d/attachment.bin>
More information about the llvm-commits
mailing list