authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-24 17:47:32+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-27 01:31:18+03:00
log9dcfc829e650bc9c0a89e9f7778744c774120c09
tree15fc28d037eb1064dcc1c5f52da930780a0a7cc3
parent4ac8ec4c5c80f6eca0ac7d7955c5486ef55ce042

Sema: fix some edge cases with error return traces and typeof blocks

Closes #13293

1 files changed, 7 insertions(+), 5 deletions(-)

src/Sema.zig+7-5
...@@ -5031,6 +5031,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -5031,6 +5031,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro
5031 .label = &label,5031 .label = &label,
5032 .inlining = parent_block.inlining,5032 .inlining = parent_block.inlining,
5033 .is_comptime = parent_block.is_comptime,5033 .is_comptime = parent_block.is_comptime,
5034 .is_typeof = parent_block.is_typeof,
5034 .want_safety = parent_block.want_safety,5035 .want_safety = parent_block.want_safety,
5035 .float_mode = parent_block.float_mode,5036 .float_mode = parent_block.float_mode,
5036 .runtime_cond = parent_block.runtime_cond,5037 .runtime_cond = parent_block.runtime_cond,
...@@ -5923,7 +5924,7 @@ fn zirCall(...@@ -5923,7 +5924,7 @@ fn zirCall(
59235924
5924 const backend_supports_error_return_tracing = sema.mod.comp.bin_file.options.use_llvm;5925 const backend_supports_error_return_tracing = sema.mod.comp.bin_file.options.use_llvm;
5925 if (backend_supports_error_return_tracing and sema.mod.comp.bin_file.options.error_return_tracing and5926 if (backend_supports_error_return_tracing and sema.mod.comp.bin_file.options.error_return_tracing and
5926 !block.is_comptime and (input_is_error or pop_error_return_trace))5927 !block.is_comptime and !block.is_typeof and (input_is_error or pop_error_return_trace))
5927 {5928 {
5928 const call_inst: Air.Inst.Ref = if (modifier == .always_tail) undefined else b: {5929 const call_inst: Air.Inst.Ref = if (modifier == .always_tail) undefined else b: {
5929 break :b try sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src);5930 break :b try sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src);
...@@ -6403,7 +6404,7 @@ fn analyzeCall(...@@ -6403,7 +6404,7 @@ fn analyzeCall(
6403 }6404 }
64046405
6405 const new_func_resolved_ty = try Type.Tag.function.create(sema.arena, new_fn_info);6406 const new_func_resolved_ty = try Type.Tag.function.create(sema.arena, new_fn_info);
6406 if (!is_comptime_call) {6407 if (!is_comptime_call and !block.is_typeof) {
6407 try sema.emitDbgInline(block, parent_func.?, module_fn, new_func_resolved_ty, .dbg_inline_begin);6408 try sema.emitDbgInline(block, parent_func.?, module_fn, new_func_resolved_ty, .dbg_inline_begin);
64086409
6409 const zir_tags = sema.code.instructions.items(.tag);6410 const zir_tags = sema.code.instructions.items(.tag);
...@@ -6441,7 +6442,7 @@ fn analyzeCall(...@@ -6441,7 +6442,7 @@ fn analyzeCall(
6441 break :result try sema.analyzeBlockBody(block, call_src, &child_block, merges);6442 break :result try sema.analyzeBlockBody(block, call_src, &child_block, merges);
6442 };6443 };
64436444
6444 if (!is_comptime_call and sema.typeOf(result).zigTypeTag() != .NoReturn) {6445 if (!is_comptime_call and !block.is_typeof and sema.typeOf(result).zigTypeTag() != .NoReturn) {
6445 try sema.emitDbgInline(6446 try sema.emitDbgInline(
6446 block,6447 block,
6447 module_fn,6448 module_fn,
...@@ -10210,6 +10211,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10210,6 +10211,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10210 .label = &label,10211 .label = &label,
10211 .inlining = block.inlining,10212 .inlining = block.inlining,
10212 .is_comptime = block.is_comptime,10213 .is_comptime = block.is_comptime,
10214 .is_typeof = block.is_typeof,
10213 .switch_else_err_ty = else_error_ty,10215 .switch_else_err_ty = else_error_ty,
10214 .runtime_cond = block.runtime_cond,10216 .runtime_cond = block.runtime_cond,
10215 .runtime_loop = block.runtime_loop,10217 .runtime_loop = block.runtime_loop,
...@@ -16401,7 +16403,7 @@ fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -16401,7 +16403,7 @@ fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
16401 if (!ok) return;16403 if (!ok) return;
1640216404
16403 // This is only relevant at runtime.16405 // This is only relevant at runtime.
16404 if (block.is_comptime) return;16406 if (block.is_comptime or block.is_typeof) return;
1640516407
16406 // This is only relevant within functions.16408 // This is only relevant within functions.
16407 if (sema.func == null) return;16409 if (sema.func == null) return;
...@@ -16421,7 +16423,7 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index)...@@ -16421,7 +16423,7 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index)
16421 const src = sema.src; // TODO16423 const src = sema.src; // TODO
1642216424
16423 // This is only relevant at runtime.16425 // This is only relevant at runtime.
16424 if (start_block.is_comptime) return;16426 if (start_block.is_comptime or start_block.is_typeof) return;
1642516427
16426 const backend_supports_error_return_tracing = sema.mod.comp.bin_file.options.use_llvm;16428 const backend_supports_error_return_tracing = sema.mod.comp.bin_file.options.use_llvm;
16427 const ok = sema.owner_func.?.calls_or_awaits_errorable_fn and16429 const ok = sema.owner_func.?.calls_or_awaits_errorable_fn and