aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-09-09 18:06:35 -0700
committerGitHub <noreply@github.com>2025-09-09 18:06:35 -0700
commit71a28f3d1e71af2acee9b9c83e012edbcfef159c (patch)
tree88a36ea4c0c78b9b7f3f69f932085b70ddadaa4c /llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
parentee5bc5701bbe9c0deb44dc5ab036c40f2a7bf7e0 (diff)
downloadllvm-71a28f3d1e71af2acee9b9c83e012edbcfef159c.zip
llvm-71a28f3d1e71af2acee9b9c83e012edbcfef159c.tar.gz
llvm-71a28f3d1e71af2acee9b9c83e012edbcfef159c.tar.bz2
[ADT] Simplify DenseMapIterator with std::reverse_iterator (NFC) (#157389)
DenseMapIterator has two tasks: - iterate the buckets in the requested direction - skip the empty and tombstone buckets These tasks are intertwined in the current implementation. This patch cleans up DenseMapIterator by separating the two tasks. Specifically, we introduce a private middleman iterator type called BucketItTy. This is the same as the pointer-based iterator in the forward direction, but it becomes std::reverse_iterator<pointer> otherwise. Now, the user-facing iterator iterates over BucketItTy while skipping the empty and tombstone buckets. This way, AdvancePastEmptyBuckets always calls BucketItTy::operator++. If the reverse iteration is requested, the underlying raw pointer gets decremented, but that logic is hidden behind std::reverse_iterator<pointer>::operator++. As a result, we can remove RetreatPastEmptyBuckets and a couple of calls to shouldReverseIterate. Here is a data point. A couple of months ago, we were calling shouldReverseIterate from 18 places in DenseMap.h. That's down to 5. This patch reduces it further down to 3.
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionSpecialization.cpp')
0 files changed, 0 insertions, 0 deletions