mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 06:11:05 +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:
@@ -15,6 +15,9 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id,
|
||||
case SemIR::ValueRepr::Unknown:
|
||||
CARBON_FATAL(
|
||||
"Value binding for type with incomplete value representation");
|
||||
case SemIR::ValueRepr::Dependent:
|
||||
CARBON_FATAL(
|
||||
"Value binding for type with dependent value representation");
|
||||
case SemIR::ValueRepr::None:
|
||||
// Nothing should use this value, but StubRef needs a value to
|
||||
// propagate.
|
||||
@@ -51,6 +54,8 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id,
|
||||
switch (context.GetValueRepr(type).repr.kind) {
|
||||
case SemIR::ValueRepr::Unknown:
|
||||
CARBON_FATAL("Unexpected incomplete type");
|
||||
case SemIR::ValueRepr::Dependent:
|
||||
CARBON_FATAL("Unexpected dependent type");
|
||||
case SemIR::ValueRepr::None:
|
||||
case SemIR::ValueRepr::Pointer:
|
||||
break;
|
||||
@@ -64,6 +69,8 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id,
|
||||
break;
|
||||
case SemIR::InitRepr::Incomplete:
|
||||
CARBON_FATAL("Unexpected incomplete type");
|
||||
case SemIR::InitRepr::Dependent:
|
||||
CARBON_FATAL("Unexpected dependent type");
|
||||
}
|
||||
|
||||
context.SetLocal(inst_id, value);
|
||||
|
||||
Reference in New Issue
Block a user