mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 11:41:06 +01:00
Compute and cache the value representation of a type when it becomes complete. (#3271)
Using the computed value representation, fix lowering of struct and tuple values to use the value representation rather than the object representation. Fixes an issue found in the review of #3257. This currently causes us to compute value representations of all types as they are created, which generates substantially more SemIR to represent types. We can get some of that back by deferring computation of the value representation until the type is required to be complete, but some of the additional cost here will persist with this approach. I also considered making the computation of the value representation type be something that lives entirely within the lowering phase, but I think that's not the right approach in the longer term, because the value representation will be semantically visible and relevant once we start allowing it to be customized. We should consider moving the nodes that exist to compute canonical non-local types, including value representations, out into a separate global block. That will clean up the SemIR representation substantially, and make the SemIR produced for a function not depend on which types we happen to have encountered beforehand. But that's not being done in this PR. --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
co-authored by
Chandler Carruth
parent
1ae5fe0cd5
commit
e4caf7d604
@@ -95,6 +95,8 @@ auto FunctionContext::CopyValue(SemIR::TypeId type_id, SemIR::NodeId source_id,
|
||||
SemIR::NodeId dest_id) -> void {
|
||||
switch (auto rep = SemIR::GetValueRepresentation(semantics_ir(), type_id);
|
||||
rep.kind) {
|
||||
case SemIR::ValueRepresentation::Unknown:
|
||||
CARBON_FATAL() << "Attempt to copy incomplete type";
|
||||
case SemIR::ValueRepresentation::None:
|
||||
break;
|
||||
case SemIR::ValueRepresentation::Copy:
|
||||
|
||||
Reference in New Issue
Block a user