[llvm] [SSAUpdater] Don't use large SmallSets for IDFcalc (PR #97823)
Jeremy Morse via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 30 07:35:17 PDT 2024
================
@@ -408,3 +408,49 @@ TEST(SmallPtrSetTest, RemoveIf) {
Removed = Set.remove_if([](int *Ptr) { return false; });
EXPECT_FALSE(Removed);
}
+
+TEST(SmallPtrSetTest, Reserve) {
+ // Check that we don't do anything silly when using reserve().
+ SmallPtrSet<int *, 4> Set;
+ int Vals[8] = {0, 1, 2, 3, 4, 5, 6, 7};
+
+ Set.insert(&Vals[0]);
+
+ // We shouldn't reallocate when this happens.
+ Set.reserve(4);
+
+ Set.insert(&Vals[1]);
+ Set.insert(&Vals[2]);
+ Set.insert(&Vals[3]);
+
+ // We shouldn't reallocate this time either.
+ Set.reserve(4);
+ EXPECT_EQ(Set.size(), 4u);
+ EXPECT_TRUE(Set.contains(&Vals[0]));
+ EXPECT_TRUE(Set.contains(&Vals[1]));
+ EXPECT_TRUE(Set.contains(&Vals[2]));
+ EXPECT_TRUE(Set.contains(&Vals[3]));
----------------
jmorse wrote:
Updated, thanks for the tip
https://github.com/llvm/llvm-project/pull/97823
More information about the llvm-commits
mailing list