[llvm] 89b7391 - llvm-reduce: Use DenseSet
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 11 14:35:46 PST 2022
Author: Matt Arsenault
Date: 2022-11-11T14:33:17-08:00
New Revision: 89b739163226b78b638fd82fb099ffc2dd7c683b
URL: https://github.com/llvm/llvm-project/commit/89b739163226b78b638fd82fb099ffc2dd7c683b
DIFF: https://github.com/llvm/llvm-project/commit/89b739163226b78b638fd82fb099ffc2dd7c683b.diff
LOG: llvm-reduce: Use DenseSet
Added:
Modified:
llvm/tools/llvm-reduce/deltas/Delta.cpp
llvm/tools/llvm-reduce/deltas/Delta.h
Removed:
################################################################################
diff --git a/llvm/tools/llvm-reduce/deltas/Delta.cpp b/llvm/tools/llvm-reduce/deltas/Delta.cpp
index 0071cd0402db..932d7198e979 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Delta.cpp
@@ -136,7 +136,7 @@ static std::unique_ptr<ReducerWorkItem>
CheckChunk(Chunk &ChunkToCheckForUninterestingness,
std::unique_ptr<ReducerWorkItem> Clone, TestRunner &Test,
ReductionFunc ExtractChunksFromModule,
- std::set<Chunk> &UninterestingChunks,
+ DenseSet<Chunk> &UninterestingChunks,
std::vector<Chunk> &ChunksStillConsideredInteresting) {
// Take all of ChunksStillConsideredInteresting chunks, except those we've
// already deemed uninteresting (UninterestingChunks) but didn't remove
@@ -188,7 +188,7 @@ CheckChunk(Chunk &ChunkToCheckForUninterestingness,
static SmallString<0> ProcessChunkFromSerializedBitcode(
Chunk &ChunkToCheckForUninterestingness, TestRunner &Test,
- ReductionFunc ExtractChunksFromModule, std::set<Chunk> &UninterestingChunks,
+ ReductionFunc ExtractChunksFromModule, DenseSet<Chunk> &UninterestingChunks,
std::vector<Chunk> &ChunksStillConsideredInteresting,
SmallString<0> &OriginalBC, std::atomic<bool> &AnyReduced) {
LLVMContext Ctx;
@@ -270,7 +270,7 @@ void llvm::runDeltaPass(TestRunner &Test, ReductionFunc ExtractChunksFromModule,
do {
FoundAtLeastOneNewUninterestingChunkWithCurrentGranularity = false;
- std::set<Chunk> UninterestingChunks;
+ DenseSet<Chunk> UninterestingChunks;
// When running with more than one thread, serialize the original bitcode
// to OriginalBC.
diff --git a/llvm/tools/llvm-reduce/deltas/Delta.h b/llvm/tools/llvm-reduce/deltas/Delta.h
index e89cb72f10db..6b595e796ef1 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.h
+++ b/llvm/tools/llvm-reduce/deltas/Delta.h
@@ -42,12 +42,39 @@ struct Chunk {
return C1.Begin != C2.Begin || C1.End != C2.End;
}
+ friend bool operator==(const Chunk &C1, const Chunk &C2) {
+ return C1.Begin == C2.Begin && C1.End == C2.End;
+ }
+
/// Operator used for sets
friend bool operator<(const Chunk &C1, const Chunk &C2) {
return std::tie(C1.Begin, C1.End) < std::tie(C2.Begin, C2.End);
}
};
+template<>
+struct DenseMapInfo<Chunk> {
+ static inline Chunk getEmptyKey() {
+ return {DenseMapInfo<int>::getEmptyKey(),
+ DenseMapInfo<int>::getEmptyKey()};
+ }
+
+ static inline Chunk getTombstoneKey() {
+ return {DenseMapInfo<int>::getTombstoneKey(),
+ DenseMapInfo<int>::getTombstoneKey()};
+ }
+
+ static unsigned getHashValue(const Chunk Val) {
+ std::pair<int, int> PairVal = std::make_pair(Val.Begin, Val.End);
+ return DenseMapInfo<std::pair<int, int>>::getHashValue(PairVal);
+ }
+
+ static bool isEqual(const Chunk LHS, const Chunk RHS) {
+ return LHS == RHS;
+ }
+};
+
+
/// Provides opaque interface for querying into ChunksToKeep without having to
/// actually understand what is going on.
class Oracle {
More information about the llvm-commits
mailing list