mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user