[llvm] efbbdd6 - [ADT] Make DenseMap::init() private (NFC) (#134229)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 3 06:14:49 PDT 2025
Author: Nikita Popov
Date: 2025-04-03T15:14:45+02:00
New Revision: efbbdd69c7974d4fe08ccbbc1d8a206f3f317a1a
URL: https://github.com/llvm/llvm-project/commit/efbbdd69c7974d4fe08ccbbc1d8a206f3f317a1a
DIFF: https://github.com/llvm/llvm-project/commit/efbbdd69c7974d4fe08ccbbc1d8a206f3f317a1a.diff
LOG: [ADT] Make DenseMap::init() private (NFC) (#134229)
I believe this method was not supposed to be public, as it has
additional preconditions (it will misbehave when called on a non-empty
DenseMap).
The public API for this is reserve().
Added:
Modified:
llvm/include/llvm/ADT/DenseMap.h
llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index ea9ba6f47ac1a..bb99a41646b08 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -806,16 +806,6 @@ class DenseMap : public DenseMapBase<DenseMap<KeyT, ValueT, KeyInfoT, BucketT>,
}
}
- void init(unsigned InitNumEntries) {
- auto InitBuckets = BaseT::getMinBucketToReserveForEntries(InitNumEntries);
- if (allocateBuckets(InitBuckets)) {
- this->BaseT::initEmpty();
- } else {
- NumEntries = 0;
- NumTombstones = 0;
- }
- }
-
void grow(unsigned AtLeast) {
unsigned OldNumBuckets = NumBuckets;
BucketT *OldBuckets = Buckets;
@@ -878,6 +868,16 @@ class DenseMap : public DenseMapBase<DenseMap<KeyT, ValueT, KeyInfoT, BucketT>,
allocate_buffer(sizeof(BucketT) * NumBuckets, alignof(BucketT)));
return true;
}
+
+ void init(unsigned InitNumEntries) {
+ auto InitBuckets = BaseT::getMinBucketToReserveForEntries(InitNumEntries);
+ if (allocateBuckets(InitBuckets)) {
+ this->BaseT::initEmpty();
+ } else {
+ NumEntries = 0;
+ NumTombstones = 0;
+ }
+ }
};
template <typename KeyT, typename ValueT, unsigned InlineBuckets = 4,
diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
index 272749f5574c6..8eb523e7d24c6 100644
--- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -897,8 +897,8 @@ class MemLocFragmentFill {
Worklist.push(RPONumber);
++RPONumber;
}
- LiveIn.init(RPONumber);
- LiveOut.init(RPONumber);
+ LiveIn.reserve(RPONumber);
+ LiveOut.reserve(RPONumber);
}
// Perform the traversal.
@@ -2318,8 +2318,8 @@ bool AssignmentTrackingLowering::run(FunctionVarLocsBuilder *FnVarLocsBuilder) {
Worklist.push(RPONumber);
++RPONumber;
}
- LiveIn.init(RPONumber);
- LiveOut.init(RPONumber);
+ LiveIn.reserve(RPONumber);
+ LiveOut.reserve(RPONumber);
}
// Perform the traversal.
More information about the llvm-commits
mailing list