mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Don't treat dependent types as having a copy value representation. (#6055)
Add `Dependent` value and initializing representations for types whose representations are unknown because they are dependent. When generating SemIR in such cases, use a worst-case initializing representation that both provides a destination address and also propagates a potential result value. Use this to fix incorrect lowering and lowering crashes for specific functions involving generic types that don't use a copy value representation. In lowering, be careful to distinguish between whether the initializing representation for the generic return type uses a return slot (which affects whether the SemIR declaration and call have one) and whether the initializing representation for the specific return type uses a return slot (which affects whether the LLVM IR declaration and call have one).
This commit is contained in:
@@ -79,6 +79,8 @@ static auto GetAggregateElement(FunctionContext& context,
|
||||
switch (value_repr.repr.kind) {
|
||||
case SemIR::ValueRepr::Unknown:
|
||||
CARBON_FATAL("Lowering access to incomplete aggregate type");
|
||||
case SemIR::ValueRepr::Dependent:
|
||||
CARBON_FATAL("Lowering access to dependent aggregate type");
|
||||
case SemIR::ValueRepr::None:
|
||||
return aggr_value;
|
||||
case SemIR::ValueRepr::Copy:
|
||||
@@ -207,6 +209,10 @@ static auto EmitAggregateInitializer(FunctionContext& context,
|
||||
case SemIR::InitRepr::Incomplete:
|
||||
CARBON_FATAL("Lowering aggregate initialization of incomplete type {0}",
|
||||
type.file->types().GetAsInst(type.type_id));
|
||||
|
||||
case SemIR::InitRepr::Dependent:
|
||||
CARBON_FATAL("Lowering aggregate initialization of dependent type {0}",
|
||||
type.file->types().GetAsInst(type.type_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +247,10 @@ static auto EmitAggregateValueRepr(FunctionContext& context,
|
||||
auto value_type = value_repr.type();
|
||||
switch (value_repr.repr.kind) {
|
||||
case SemIR::ValueRepr::Unknown:
|
||||
CARBON_FATAL("Incomplete aggregate type in lowering");
|
||||
CARBON_FATAL("Lowering value of incomplete aggregate type");
|
||||
|
||||
case SemIR::ValueRepr::Dependent:
|
||||
CARBON_FATAL("Lowering value of dependent aggregate type");
|
||||
|
||||
case SemIR::ValueRepr::None:
|
||||
// TODO: Add a helper to get a "no value representation" value.
|
||||
|
||||
Reference in New Issue
Block a user