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:
@@ -522,8 +522,16 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id,
|
||||
std::vector<llvm::Value*> args;
|
||||
|
||||
auto inst_type = context.GetTypeIdOfInst(inst_id);
|
||||
bool call_has_return_slot =
|
||||
SemIR::ReturnTypeInfo::ForType(context.sem_ir(), inst.type_id)
|
||||
.has_return_slot();
|
||||
if (context.GetReturnTypeInfo(inst_type).info.has_return_slot()) {
|
||||
CARBON_CHECK(call_has_return_slot);
|
||||
args.push_back(context.GetValue(arg_ids.consume_back()));
|
||||
} else if (call_has_return_slot) {
|
||||
// Call instruction has a return slot but this specific callee does not.
|
||||
// Just ignore it.
|
||||
arg_ids.consume_back();
|
||||
}
|
||||
|
||||
for (auto arg_id : arg_ids) {
|
||||
|
||||
Reference in New Issue
Block a user