Include spliced inst value in fingerprint while lowering. (#7739)

This prevents different template instantiations from getting
over-eagerly merged. Unfortunately we don't have a good middle-ground
yet, and this effectively disables all merging for templates. We may be
able to find some smart way to fingerprint spliced instructions so that
we can still merge template instantiations, but for now this change is
just fixing the wrong-code bug.
This commit is contained in:
Richard Smith
2026-09-09 17:54:10 +00:00
committed by GitHub
parent a9fee27bbb
commit 49c6f488b6
4 changed files with 529 additions and 0 deletions
+15
View File
@@ -472,6 +472,21 @@ auto FunctionContext::AddTypeToCurrentFingerprint(llvm::Type* type) -> void {
current_fingerprint_.common_fingerprint.update(os.TakeStr());
}
auto FunctionContext::AddInstToCurrentFingerprint(SemIR::InstId inst_id)
-> void {
if (!function_fingerprint_) {
return;
}
// TODO: Add some support for fingerprinting spliced instructions so that at
// least in easy cases we can deduplicate templates.
// TODO: Replace indexes with info that is translation unit independent.
RawStringOstream os;
os << "inst_id" << inst_id.index << "\n";
current_fingerprint_.common_fingerprint.update(os.TakeStr());
}
auto FunctionContext::AddGlobalToCurrentFingerprint(llvm::Value* global)
-> void {
if (!function_fingerprint_ || !global) {