[compiler-rt] 2aef605 - [NFC][sanitizer] Micro optimize push_back()
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Sun May 28 17:54:07 PDT 2023
Author: Vitaly Buka
Date: 2023-05-28T17:53:54-07:00
New Revision: 2aef60532f04b879297a72e55a0975854ba38227
URL: https://github.com/llvm/llvm-project/commit/2aef60532f04b879297a72e55a0975854ba38227
DIFF: https://github.com/llvm/llvm-project/commit/2aef60532f04b879297a72e55a0975854ba38227.diff
LOG: [NFC][sanitizer] Micro optimize push_back()
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_common.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 61d44020ed998..afd1a786d5d33 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -519,8 +519,8 @@ class InternalMmapVectorNoCtor {
return data_[i];
}
void push_back(const T &element) {
- CHECK_LE(size_, capacity());
- if (size_ == capacity()) {
+ if (UNLIKELY(size_ >= capacity())) {
+ CHECK_EQ(size_, capacity());
uptr new_capacity = RoundUpToPowerOfTwo(size_ + 1);
Realloc(new_capacity);
}
@@ -580,7 +580,7 @@ class InternalMmapVectorNoCtor {
}
private:
- void Realloc(uptr new_capacity) {
+ NOINLINE void Realloc(uptr new_capacity) {
CHECK_GT(new_capacity, 0);
CHECK_LE(size_, new_capacity);
uptr new_capacity_bytes =
More information about the llvm-commits
mailing list