summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_common.h
diff options
context:
space:
mode:
authorFrancis Ricci <francisjricci@gmail.com>2017-07-25 18:16:58 +0000
committerFrancis Ricci <francisjricci@gmail.com>2017-07-25 18:16:58 +0000
commit5764cd92b929fefc1fef703c32e59516a0468d0b (patch)
treef1f546ea1cebc734f320dd558c24415e2cf4b974 /lib/sanitizer_common/sanitizer_common.h
parent416f1839fc4ccdc0fcdeb5a5b3da1f9b421ecb41 (diff)
Only scan global sections containing data in LSan on darwin
Summary: __DATA segments on Darwin contain a large number of separate sections, many of which cannot actually contain pointers, and contain const values or objc metadata. Not scanning sections which cannot contain pointers significantly improves performance. On a medium-sized (~4000 files) internal project, I saw a speedup of about 30% in standalone LSan's execution time (30% improvement in the time spent running LSan, not the total program time). Reviewers: kcc, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35432 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308999 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_common.h')
-rw-r--r--lib/sanitizer_common/sanitizer_common.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/sanitizer_common/sanitizer_common.h b/lib/sanitizer_common/sanitizer_common.h
index 9c801f151..9e65639b9 100644
--- a/lib/sanitizer_common/sanitizer_common.h
+++ b/lib/sanitizer_common/sanitizer_common.h
@@ -624,6 +624,7 @@ inline const char *ModuleArchToString(ModuleArch arch) {
}
const uptr kModuleUUIDSize = 16;
+const uptr kMaxSegName = 16;
// Represents a binary loaded into virtual memory (e.g. this can be an
// executable or a shared object).
@@ -642,7 +643,8 @@ class LoadedModule {
void set(const char *module_name, uptr base_address, ModuleArch arch,
u8 uuid[kModuleUUIDSize], bool instrumented);
void clear();
- void addAddressRange(uptr beg, uptr end, bool executable, bool writable);
+ void addAddressRange(uptr beg, uptr end, bool executable, bool writable,
+ const char *name = nullptr);
bool containsAddress(uptr address) const;
const char *full_name() const { return full_name_; }
@@ -658,13 +660,17 @@ class LoadedModule {
uptr end;
bool executable;
bool writable;
+ char name[kMaxSegName];
- AddressRange(uptr beg, uptr end, bool executable, bool writable)
+ AddressRange(uptr beg, uptr end, bool executable, bool writable,
+ const char *name)
: next(nullptr),
beg(beg),
end(end),
executable(executable),
- writable(writable) {}
+ writable(writable) {
+ internal_strncpy(this->name, (name ? name : ""), ARRAY_SIZE(this->name));
+ }
};
const IntrusiveList<AddressRange> &ranges() const { return ranges_; }