summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin@accesssoftek.com>2019-12-11 17:37:24 +0700
committerIgor Kudrin <ikudrin@accesssoftek.com>2019-12-17 15:03:23 +0700
commita57adc7a0b0dac5484f19f9061eba432d0db19e8 (patch)
tree2f5c99fac06d82fdf17f06eada3720af442597b4 /compiler-rt
parent5279f96577af1457a973c071ec5ee3554c9f6cbe (diff)
downloadbcm5719-llvm-a57adc7a0b0dac5484f19f9061eba432d0db19e8.tar.gz
bcm5719-llvm-a57adc7a0b0dac5484f19f9061eba432d0db19e8.zip
[sanitizer] Construct InternalMmapVector without memory allocation.
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. Differential Revision: https://reviews.llvm.org/D71342
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.h2
-rw-r--r--compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 87b8f02b5b7..3b52172c483 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -552,7 +552,7 @@ bool operator!=(const InternalMmapVectorNoCtor<T> &lhs,
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);
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
index 9c2b88d82d5..212d2f56ff8 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
@@ -131,7 +131,7 @@ TEST(SanitizerCommon, InternalMmapVector) {
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());
}
OpenPOWER on IntegriCloud