Change how Block propagates (error return) trace index

Instead of adding 3 fields to every `Block`, this adds just one. The
function-level information is saved in the `Sema` struct instead,
which is created/copied more rarely.
This commit is contained in:
Cody Tapscott
2022-10-21 12:42:27 -07:00
parent 74b9cbd895
commit c36a2c27a5
2 changed files with 22 additions and 24 deletions

View File

@@ -5635,10 +5635,9 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air {
// Save the error trace as our first action in the function.
// If this is unnecessary after all, Liveness will clean it up for us.
const err_ret_trace_index = try sema.analyzeSaveErrRetIndex(&inner_block);
inner_block.error_return_trace_index = err_ret_trace_index;
inner_block.error_return_trace_index_on_block_entry = err_ret_trace_index;
inner_block.error_return_trace_index_on_function_entry = err_ret_trace_index;
const error_return_trace_index = try sema.analyzeSaveErrRetIndex(&inner_block);
sema.error_return_trace_index_on_fn_entry = error_return_trace_index;
inner_block.error_return_trace_index = error_return_trace_index;
sema.analyzeBody(&inner_block, fn_info.body) catch |err| switch (err) {
// TODO make these unreachable instead of @panic