Assume control and insert-slot pointers are non-null in raw_hash_set. LLVM cannot generally prove that control pointers loaded from CommonFields or slot pointers returned across out-of-line helpers are non-null, leaving redundant null checks and dead branches in hot iteration and insert paths. Add ABSL_ASSUME non-null hints at two sites in raw_hash_set.h: | Site | Pointer | | :--------------------------------- | :-------- | | CommonFields::control | ctrl | | find_or_prepare_insert (!is_small) | res.first | PiperOrigin-RevId: 1000126641
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index a59d09b..d352964 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h
@@ -1384,7 +1384,9 @@ ctrl_t* control() const { ABSL_SWISSTABLE_ASSERT(capacity() > 0); - ABSL_SWISSTABLE_IGNORE_UNINITIALIZED_RETURN(heap_or_soo_.control().get()); + ctrl_t* ctrl = heap_or_soo_.control().get(); + ABSL_SWISSTABLE_IGNORE_UNINITIALIZED(ABSL_ASSUME(ctrl != nullptr)); + ABSL_SWISSTABLE_IGNORE_UNINITIALIZED_RETURN(ctrl); } void set_control(ctrl_t* c) { heap_or_soo_.control().set(c); } @@ -4390,8 +4392,10 @@ absl::type_identity_t<K> key) { static_assert(std::is_same_v<K, KeyParam<K>>); AssertOnFind<K>(key); - return is_small() ? find_or_prepare_insert_small<K>(key) - : find_or_prepare_insert_large<FindLargeKey<K>>(key); + if (is_small()) return find_or_prepare_insert_small<K>(key); + auto res = find_or_prepare_insert_large<FindLargeKey<K>>(key); + ABSL_ASSUME(res.first != nullptr); + return res; } // Constructs the value in the space pointed by the iterator. This only works