Skip to content

Commit

Permalink
Respond to reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffromer committed Oct 22, 2024
1 parent 2d3cc0a commit 1a7cd0e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions toolchain/check/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<SemIR::TemporaryStorage>(
return_slot_arg_id = context.AddInst<SemIR::TemporaryStorage>(
loc_id, {.type_id = return_info.type_id});
break;
case SemIR::InitRepr::None:
Expand All @@ -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<SemIR::Call>(loc_id, {.type_id = return_info.type_id,
Expand Down
8 changes: 4 additions & 4 deletions toolchain/check/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SemIR::InstId> arg_refs,
SemIR::InstId return_slot_id,
SemIR::InstId return_slot_arg_id,
const CalleeParamsInfo& callee,
SemIR::SpecificId callee_specific_id)
-> SemIR::InstBlockId {
Expand All @@ -1187,7 +1187,7 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
// Start building a block to hold the converted arguments.
llvm::SmallVector<SemIR::InstId> 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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct CalleeParamsInfo {
auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
SemIR::InstId self_id,
llvm::ArrayRef<SemIR::InstId> arg_refs,
SemIR::InstId return_slot_id,
SemIR::InstId return_slot_arg_id,
const CalleeParamsInfo& callee,
SemIR::SpecificId callee_specific_id)
-> SemIR::InstBlockId;
Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/import_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions toolchain/check/pattern_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -256,7 +256,7 @@ auto EmitPatternMatch(Context& context, MatchContext& match,
CARBON_CHECK(match.kind() == MatchKind::Callee);
match.set_return_slot_id(context.AddInst<SemIR::ReturnSlot>(
pattern.loc_id, {.type_id = return_slot_pattern.type_id,
.value_id = entry.scrutinee_id}));
.storage_id = entry.scrutinee_id}));
break;
}
default: {
Expand Down
3 changes: 1 addition & 2 deletions toolchain/sem_ir/inst_namer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
8 changes: 6 additions & 2 deletions toolchain/sem_ir/typed_insts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -892,8 +892,12 @@ struct ReturnSlot {
static constexpr auto Kind =
InstKind::ReturnSlot.Define<Parse::NodeId>({.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
Expand Down

0 comments on commit 1a7cd0e

Please sign in to comment.