[compiler-rt] 0332d5d - [NFC][sanitizer] Annotate a few branches in StackDepot
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 7 13:54:22 PDT 2021
Author: Vitaly Buka
Date: 2021-10-07T13:54:02-07:00
New Revision: 0332d5d14d21b8e4dc98f42e196660e263f1d5f1
URL: https://github.com/llvm/llvm-project/commit/0332d5d14d21b8e4dc98f42e196660e263f1d5f1
DIFF: https://github.com/llvm/llvm-project/commit/0332d5d14d21b8e4dc98f42e196660e263f1d5f1.diff
LOG: [NFC][sanitizer] Annotate a few branches in StackDepot
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
index 27e23b5f09f5..7d06dbb12416 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
@@ -53,7 +53,8 @@ inline void *PersistentAllocator::tryAlloc(uptr size) {
inline void *PersistentAllocator::alloc(uptr size) {
// First, try to allocate optimisitically.
void *s = tryAlloc(size);
- if (s) return s;
+ if (LIKELY(s))
+ return s;
return refillAndAlloc(size);
}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
index 97dcb0352510..9f38a29f9912 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
@@ -100,15 +100,18 @@ template <class Node, int kReservedBits, int kTabSizeLog>
typename StackDepotBase<Node, kReservedBits, kTabSizeLog>::handle_type
StackDepotBase<Node, kReservedBits, kTabSizeLog>::Put(args_type args,
bool *inserted) {
- if (inserted) *inserted = false;
- if (!Node::is_valid(args)) return handle_type();
+ if (inserted)
+ *inserted = false;
+ if (!LIKELY(Node::is_valid(args)))
+ return handle_type();
hash_type h = Node::hash(args);
atomic_uintptr_t *p = &tab[h % kTabSize];
uptr v = atomic_load(p, memory_order_consume);
Node *s = (Node *)(v & ~1);
// First, try to find the existing stack.
Node *node = find(s, args, h);
- if (node) return node->get_handle();
+ if (LIKELY(node))
+ return node->get_handle();
// If failed, lock, retry and insert new.
Node *s2 = lock(p);
if (s2 != s) {
More information about the llvm-commits
mailing list