Replace FoldingSet with DenseMap for instruction canonicalization. (#3979)

Switch from recursing into non-canonical instruction fields to
separately canonicalizing those fields. This means we now form canonical
`InstBlockId`s, `TypeBlockId`s, `IntId`s, `FloatId`s, and `BindNameId`s
at least in the cases when they're referenced by a constant instruction.

This reduces the overall runtime for @chandlerc's 10MLoC example by
27.5% on my machine.
This commit is contained in:
Richard Smith
2024-05-23 00:48:49 +00:00
committed by GitHub
parent 7b4b7abc6e
commit 5c8fa6ad5c
35 changed files with 479 additions and 505 deletions
+2 -4
View File
@@ -1076,10 +1076,8 @@ auto Context::GetStructType(SemIR::InstBlockId refs_id) -> SemIR::TypeId {
auto Context::GetTupleType(llvm::ArrayRef<SemIR::TypeId> type_ids)
-> SemIR::TypeId {
// TODO: Deduplicate the type block here. Currently requesting the same tuple
// type more than once will create multiple type blocks, all but one of which
// is unused.
return GetTypeImpl<SemIR::TupleType>(*this, type_blocks().Add(type_ids));
return GetTypeImpl<SemIR::TupleType>(*this,
type_blocks().AddCanonical(type_ids));
}
auto Context::GetAssociatedEntityType(SemIR::InterfaceId interface_id,