mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 14:51:03 +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
@@ -59,7 +59,7 @@ auto HandleWhileStatement(Context& context, Parse::WhileStatementId parse_node)
|
||||
context.break_continue_stack().pop_back();
|
||||
|
||||
// Add the loop backedge.
|
||||
context.AddInst(SemIR::Branch{parse_node, loop_header_id});
|
||||
context.AddInst({parse_node, SemIR::Branch{loop_header_id}});
|
||||
context.inst_block_stack().Pop();
|
||||
|
||||
// Start emitting the loop exit block.
|
||||
@@ -102,7 +102,7 @@ auto HandleBreakStatementStart(Context& context,
|
||||
"`break` can only be used in a loop.");
|
||||
context.emitter().Emit(parse_node, BreakOutsideLoop);
|
||||
} else {
|
||||
context.AddInst(SemIR::Branch{parse_node, stack.back().break_target});
|
||||
context.AddInst({parse_node, SemIR::Branch{stack.back().break_target}});
|
||||
}
|
||||
|
||||
context.inst_block_stack().Pop();
|
||||
@@ -127,7 +127,7 @@ auto HandleContinueStatementStart(Context& context,
|
||||
"`continue` can only be used in a loop.");
|
||||
context.emitter().Emit(parse_node, ContinueOutsideLoop);
|
||||
} else {
|
||||
context.AddInst(SemIR::Branch{parse_node, stack.back().continue_target});
|
||||
context.AddInst({parse_node, SemIR::Branch{stack.back().continue_target}});
|
||||
}
|
||||
|
||||
context.inst_block_stack().Pop();
|
||||
|
||||
Reference in New Issue
Block a user