[all-commits] [llvm/llvm-project] 42c3ed: [SmallPtrSet] Don't leave tombstones in small mode...
Nikita Popov via All-commits
all-commits at lists.llvm.org
Thu Jun 27 08:00:44 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 42c3edb4819ff2e9608f645fb5793dcb33b47f9c
https://github.com/llvm/llvm-project/commit/42c3edb4819ff2e9608f645fb5793dcb33b47f9c
Author: Nikita Popov <npopov at redhat.com>
Date: 2024-06-27 (Thu, 27 Jun 2024)
Changed paths:
M llvm/docs/ProgrammersManual.rst
M llvm/include/llvm/ADT/SmallPtrSet.h
M llvm/unittests/ADT/SmallPtrSetTest.cpp
Log Message:
-----------
[SmallPtrSet] Don't leave tombstones in small mode (#96762)
When erasing elements in small mode, we currently leave behind
tombstones. This means that insertion into the SmallPtrSet also has to
check for these, making the operation more expensive than it really
should be.
We don't really need the tombstones in small mode, because we can just
replace with the last element in the set instead. This changes the
order, but SmallPtrSet order is fundamentally unstable anyway.
However, not leaving tombstones means that the erase() operation now
invalidates iterators. This means that consumers that want to remove
elements while iterating over the set have to use remove_if() instead.
If they fail to do so, there will be an assertion failure thanks to
debug epochs, so any such cases are easy to detect (and I have already
fixed all cases inside llvm at least).
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list