mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:21:19 +01:00
Split parse nodes out from instructions because they're rarely used. (#3590)
The parse nodes are still tracked as part of the same value store interface in order to ensure parity, but they're split out from Inst itself in order to reduce the size of Inst -- the expectation is that they don't need to be passed around quite as much. This change doesn't actually reduce the passing very much, although there are hints of it: AddInstAndPush doesn't typically need a separate parse node from the one on the Inst itself, for example. In a couple spots I changed code to rely a little more on the InstId until the ParseNode is needed, but it's very low hanging fruit where done. I think convert could do more to not eagerly fetch the parse node before its use, but more cleanup felt it would be easier to handle separately. I'm currently viewing this as making such cleanup _possible_ rather than executing on it up-front. But also, I want to make sure there's a consensus to head in this direction before pulling the trigger. We speculated that this would result in the parse node being passed around less, and I do think that's the case, although it's a bit fuzzy in the change. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
a3154356f0
commit
f197219c10
@@ -81,18 +81,21 @@ auto HandleCallExpr(Context& context, Parse::CallExprId parse_node) -> bool {
|
||||
if (callable.return_slot_id.is_valid()) {
|
||||
// Tentatively put storage for a temporary in the function's return slot.
|
||||
// This will be replaced if necessary when we perform initialization.
|
||||
return_storage_id = context.AddInst(
|
||||
SemIR::TemporaryStorage{call_expr_parse_node, callable.return_type_id});
|
||||
return_storage_id =
|
||||
context.AddInst({call_expr_parse_node,
|
||||
SemIR::TemporaryStorage{callable.return_type_id}});
|
||||
}
|
||||
|
||||
// Convert the arguments to match the parameters.
|
||||
auto converted_args_id =
|
||||
ConvertCallArgs(context, call_expr_parse_node, self_id,
|
||||
context.params_or_args_stack().PeekCurrentBlockContents(),
|
||||
return_storage_id, function_decl->parse_node,
|
||||
return_storage_id,
|
||||
context.insts().GetParseNode(function_decl_id.inst_id()),
|
||||
callable.implicit_param_refs_id, callable.param_refs_id);
|
||||
auto call_inst_id = context.AddInst(
|
||||
SemIR::Call{call_expr_parse_node, type_id, callee_id, converted_args_id});
|
||||
auto call_inst_id =
|
||||
context.AddInst({call_expr_parse_node,
|
||||
SemIR::Call{type_id, callee_id, converted_args_id}});
|
||||
|
||||
context.node_stack().Push(parse_node, call_inst_id);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user