Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flow] Improve DeduplicateExecutables bucketing #19601

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ static int deduplicateObjects(Operation *scopeOp,
// 5 was randomly chosen to be small enough to not increase overhead much,
// but giving at least enough of a sample that there is some bucketing. This
// was not empirically determined.
constexpr int kMaxHashedOps = 5;
llvm::MapVector<uint32_t, SmallVector<SymbolOpInterface>> objectMap;
for (auto objectOp : allObjectOps) {
int count = 0;
llvm::hash_code hash(1);
objectOp->walk([&](Operation *it) {
hash = llvm::hash_combine(hash, it->getName());
return (++count >= 5) ? WalkResult::interrupt() : WalkResult::advance();
hash = llvm::hash_combine(hash, it->getResultTypes());
return (++count >= kMaxHashedOps) ? WalkResult::interrupt()
: WalkResult::advance();
});
objectMap[hash_value(hash)].push_back(cast<SymbolOpInterface>(objectOp));
}
Expand Down
Loading