diff --git a/toolchain/check/call.cpp b/toolchain/check/call.cpp index deb3c83e882bf..645ed1ce88d1a 100644 --- a/toolchain/check/call.cpp +++ b/toolchain/check/call.cpp @@ -175,7 +175,7 @@ auto PerformCall(Context& context, SemIR::LocId loc_id, SemIR::InstId callee_id, } // If there is a return slot, build storage for the result. - SemIR::InstId return_slot_id = SemIR::InstId::Invalid; + SemIR::InstId return_slot_arg_id = SemIR::InstId::Invalid; SemIR::ReturnTypeInfo return_info = [&] { DiagnosticAnnotationScope annotate_diagnostics( &context.emitter(), [&](auto& builder) { @@ -190,7 +190,7 @@ auto PerformCall(Context& context, SemIR::LocId loc_id, SemIR::InstId callee_id, case SemIR::InitRepr::InPlace: // Tentatively put storage for a temporary in the function's return slot. // This will be replaced if necessary when we perform initialization. - return_slot_id = context.AddInst( + return_slot_arg_id = context.AddInst( loc_id, {.type_id = return_info.type_id}); break; case SemIR::InitRepr::None: @@ -211,7 +211,7 @@ auto PerformCall(Context& context, SemIR::LocId loc_id, SemIR::InstId callee_id, // Convert the arguments to match the parameters. auto converted_args_id = ConvertCallArgs( - context, loc_id, callee_function.self_id, arg_ids, return_slot_id, + context, loc_id, callee_function.self_id, arg_ids, return_slot_arg_id, CalleeParamsInfo(callable), *callee_specific_id); auto call_inst_id = context.AddInst(loc_id, {.type_id = return_info.type_id, diff --git a/toolchain/check/convert.cpp b/toolchain/check/convert.cpp index 8618501e55254..58f30515af08a 100644 --- a/toolchain/check/convert.cpp +++ b/toolchain/check/convert.cpp @@ -1172,7 +1172,7 @@ static auto ConvertSelf(Context& context, SemIR::LocId call_loc_id, auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id, SemIR::InstId self_id, llvm::ArrayRef arg_refs, - SemIR::InstId return_slot_id, + SemIR::InstId return_slot_arg_id, const CalleeParamsInfo& callee, SemIR::SpecificId callee_specific_id) -> SemIR::InstBlockId { @@ -1187,7 +1187,7 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id, // Start building a block to hold the converted arguments. llvm::SmallVector args; args.reserve(implicit_param_patterns.size() + param_patterns.size() + - return_slot_id.is_valid()); + return_slot_arg_id.is_valid()); // Check implicit parameters. for (auto implicit_param_id : implicit_param_patterns) { @@ -1241,8 +1241,8 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id, } // Track the return storage, if present. - if (return_slot_id.is_valid()) { - args.push_back(return_slot_id); + if (return_slot_arg_id.is_valid()) { + args.push_back(return_slot_arg_id); } return context.inst_blocks().AddOrEmpty(args); diff --git a/toolchain/check/convert.h b/toolchain/check/convert.h index c8ca900cc1360..129d9029a2d6c 100644 --- a/toolchain/check/convert.h +++ b/toolchain/check/convert.h @@ -117,7 +117,7 @@ struct CalleeParamsInfo { auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id, SemIR::InstId self_id, llvm::ArrayRef arg_refs, - SemIR::InstId return_slot_id, + SemIR::InstId return_slot_arg_id, const CalleeParamsInfo& callee, SemIR::SpecificId callee_specific_id) -> SemIR::InstBlockId; diff --git a/toolchain/check/import_ref.cpp b/toolchain/check/import_ref.cpp index 5ee88a41f5a29..e9a3c00a7736d 100644 --- a/toolchain/check/import_ref.cpp +++ b/toolchain/check/import_ref.cpp @@ -764,7 +764,7 @@ class ImportRefResolver { AddImportIRInst(param_id), {.type_id = type_id, .runtime_index = param_inst.runtime_index, - .pretty_name = GetLocalNameId(param_inst.pretty_name)}); + .pretty_name_id = GetLocalNameId(param_inst.pretty_name_id)}); switch (bind_inst.kind) { case SemIR::BindName::Kind: { auto entity_name_id = context_.entity_names().Add( diff --git a/toolchain/check/pattern_match.cpp b/toolchain/check/pattern_match.cpp index e8e5f88c7a338..34d337d80f2a4 100644 --- a/toolchain/check/pattern_match.cpp +++ b/toolchain/check/pattern_match.cpp @@ -247,7 +247,7 @@ auto EmitPatternMatch(Context& context, MatchContext& match, pattern.loc_id, {.type_id = param_pattern.type_id, .runtime_index = param_pattern.runtime_index, - .pretty_name = GetPrettyName(context, param_pattern)})}); + .pretty_name_id = GetPrettyName(context, param_pattern)})}); } break; } break; @@ -256,7 +256,7 @@ auto EmitPatternMatch(Context& context, MatchContext& match, CARBON_CHECK(match.kind() == MatchKind::Callee); match.set_return_slot_id(context.AddInst( pattern.loc_id, {.type_id = return_slot_pattern.type_id, - .value_id = entry.scrutinee_id})); + .storage_id = entry.scrutinee_id})); break; } default: { diff --git a/toolchain/sem_ir/inst_namer.cpp b/toolchain/sem_ir/inst_namer.cpp index 334e2dd64b504..4206b4f17b7f8 100644 --- a/toolchain/sem_ir/inst_namer.cpp +++ b/toolchain/sem_ir/inst_namer.cpp @@ -531,8 +531,7 @@ auto InstNamer::CollectNamesInBlock(ScopeId scope_id, continue; } case CARBON_KIND(Param inst): { - // TODO: Find a way to use the name of the enclosing bind inst here. - add_inst_name_id(inst.pretty_name, ".param"); + add_inst_name_id(inst.pretty_name_id, ".param"); continue; } case InstKind::ParamPattern: { diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index 75bb93d49f9dc..9dd851ecc4a6a 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -836,7 +836,7 @@ struct Param { // A name to associate with this Param in pretty-printed IR. This is not // necessarily unique, or even valid, and has no semantic significance. - NameId pretty_name; + NameId pretty_name_id; }; // A pattern that represents a parameter. It matches the same values as @@ -892,8 +892,12 @@ struct ReturnSlot { static constexpr auto Kind = InstKind::ReturnSlot.Define({.ir_name = "return_slot"}); + // The type of the value that will be stored in this slot (i.e. the return + // type of the function). TypeId type_id; - InstId value_id; + + // The storage that will be initialized by the function. + InstId storage_id; }; // The return slot of a function declaration, as exposed to the function's