| ... | @@ -6387,14 +6387,18 @@ fn zirCall( | ... | @@ -6387,14 +6387,18 @@ fn zirCall( |
| 6387 | } | 6387 | } |
| 6388 | resolved_args[arg_index] = resolved; | 6388 | resolved_args[arg_index] = resolved; |
| 6389 | } | 6389 | } |
| 6390 | if (sema.owner_func == null or !sema.owner_func.?.calls_or_awaits_errorable_fn) | 6390 | if (sema.owner_func == null or !sema.owner_func.?.calls_or_awaits_errorable_fn) { |
| 6391 | input_is_error = false; // input was an error type, but no errorable fn's were actually called | 6391 | input_is_error = false; // input was an error type, but no errorable fn's were actually called |
| | 6392 | } |
| | 6393 | |
| | 6394 | // AstGen ensures that a call instruction is always preceded by a dbg_stmt instruction. |
| | 6395 | const call_dbg_node = inst - 1; |
| 6392 | | 6396 | |
| 6393 | if (sema.mod.backendSupportsFeature(.error_return_trace) and sema.mod.comp.bin_file.options.error_return_tracing and | 6397 | if (sema.mod.backendSupportsFeature(.error_return_trace) and sema.mod.comp.bin_file.options.error_return_tracing and |
| 6394 | !block.is_comptime and !block.is_typeof and (input_is_error or pop_error_return_trace)) | 6398 | !block.is_comptime and !block.is_typeof and (input_is_error or pop_error_return_trace)) |
| 6395 | { | 6399 | { |
| 6396 | const call_inst: Air.Inst.Ref = if (modifier == .always_tail) undefined else b: { | 6400 | const call_inst: Air.Inst.Ref = if (modifier == .always_tail) undefined else b: { |
| 6397 | break :b try sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src); | 6401 | break :b try sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src, call_dbg_node); |
| 6398 | }; | 6402 | }; |
| 6399 | | 6403 | |
| 6400 | const return_ty = sema.typeOf(call_inst); | 6404 | const return_ty = sema.typeOf(call_inst); |
| ... | @@ -6423,11 +6427,11 @@ fn zirCall( | ... | @@ -6423,11 +6427,11 @@ fn zirCall( |
| 6423 | } | 6427 | } |
| 6424 | | 6428 | |
| 6425 | if (modifier == .always_tail) // Perform the call *after* the restore, so that a tail call is possible. | 6429 | if (modifier == .always_tail) // Perform the call *after* the restore, so that a tail call is possible. |
| 6426 | return sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src); | 6430 | return sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src, call_dbg_node); |
| 6427 | | 6431 | |
| 6428 | return call_inst; | 6432 | return call_inst; |
| 6429 | } else { | 6433 | } else { |
| 6430 | return sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src); | 6434 | return sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src, call_dbg_node); |
| 6431 | } | 6435 | } |
| 6432 | } | 6436 | } |
| 6433 | | 6437 | |
| ... | @@ -6511,6 +6515,7 @@ fn analyzeCall( | ... | @@ -6511,6 +6515,7 @@ fn analyzeCall( |
| 6511 | ensure_result_used: bool, | 6515 | ensure_result_used: bool, |
| 6512 | uncasted_args: []const Air.Inst.Ref, | 6516 | uncasted_args: []const Air.Inst.Ref, |
| 6513 | bound_arg_src: ?LazySrcLoc, | 6517 | bound_arg_src: ?LazySrcLoc, |
| | 6518 | call_dbg_node: ?Zir.Inst.Index, |
| 6514 | ) CompileError!Air.Inst.Ref { | 6519 | ) CompileError!Air.Inst.Ref { |
| 6515 | const mod = sema.mod; | 6520 | const mod = sema.mod; |
| 6516 | | 6521 | |
| ... | @@ -6628,6 +6633,7 @@ fn analyzeCall( | ... | @@ -6628,6 +6633,7 @@ fn analyzeCall( |
| 6628 | uncasted_args, | 6633 | uncasted_args, |
| 6629 | call_tag, | 6634 | call_tag, |
| 6630 | bound_arg_src, | 6635 | bound_arg_src, |
| | 6636 | call_dbg_node, |
| 6631 | )) |some| { | 6637 | )) |some| { |
| 6632 | return some; | 6638 | return some; |
| 6633 | } else |err| switch (err) { | 6639 | } else |err| switch (err) { |
| ... | @@ -7016,6 +7022,8 @@ fn analyzeCall( | ... | @@ -7016,6 +7022,8 @@ fn analyzeCall( |
| 7016 | } | 7022 | } |
| 7017 | } | 7023 | } |
| 7018 | | 7024 | |
| | 7025 | if (call_dbg_node) |some| try sema.zirDbgStmt(block, some); |
| | 7026 | |
| 7019 | try sema.queueFullTypeResolution(func_ty_info.return_type); | 7027 | try sema.queueFullTypeResolution(func_ty_info.return_type); |
| 7020 | if (sema.owner_func != null and func_ty_info.return_type.isError()) { | 7028 | if (sema.owner_func != null and func_ty_info.return_type.isError()) { |
| 7021 | sema.owner_func.?.calls_or_awaits_errorable_fn = true; | 7029 | sema.owner_func.?.calls_or_awaits_errorable_fn = true; |
| ... | @@ -7252,6 +7260,7 @@ fn instantiateGenericCall( | ... | @@ -7252,6 +7260,7 @@ fn instantiateGenericCall( |
| 7252 | uncasted_args: []const Air.Inst.Ref, | 7260 | uncasted_args: []const Air.Inst.Ref, |
| 7253 | call_tag: Air.Inst.Tag, | 7261 | call_tag: Air.Inst.Tag, |
| 7254 | bound_arg_src: ?LazySrcLoc, | 7262 | bound_arg_src: ?LazySrcLoc, |
| | 7263 | call_dbg_node: ?Zir.Inst.Index, |
| 7255 | ) CompileError!Air.Inst.Ref { | 7264 | ) CompileError!Air.Inst.Ref { |
| 7256 | const mod = sema.mod; | 7265 | const mod = sema.mod; |
| 7257 | const gpa = sema.gpa; | 7266 | const gpa = sema.gpa; |
| ... | @@ -7508,6 +7517,8 @@ fn instantiateGenericCall( | ... | @@ -7508,6 +7517,8 @@ fn instantiateGenericCall( |
| 7508 | try sema.queueFullTypeResolution(new_fn_info.return_type); | 7517 | try sema.queueFullTypeResolution(new_fn_info.return_type); |
| 7509 | } | 7518 | } |
| 7510 | | 7519 | |
| | 7520 | if (call_dbg_node) |some| try sema.zirDbgStmt(block, some); |
| | 7521 | |
| 7511 | if (sema.owner_func != null and new_fn_info.return_type.isError()) { | 7522 | if (sema.owner_func != null and new_fn_info.return_type.isError()) { |
| 7512 | sema.owner_func.?.calls_or_awaits_errorable_fn = true; | 7523 | sema.owner_func.?.calls_or_awaits_errorable_fn = true; |
| 7513 | } | 7524 | } |
| ... | @@ -11822,7 +11833,7 @@ fn maybeErrorUnwrap(sema: *Sema, block: *Block, body: []const Zir.Inst.Index, op | ... | @@ -11822,7 +11833,7 @@ fn maybeErrorUnwrap(sema: *Sema, block: *Block, body: []const Zir.Inst.Index, op |
| 11822 | const panic_fn = try sema.getBuiltin("panicUnwrapError"); | 11833 | const panic_fn = try sema.getBuiltin("panicUnwrapError"); |
| 11823 | const err_return_trace = try sema.getErrorReturnTrace(block); | 11834 | const err_return_trace = try sema.getErrorReturnTrace(block); |
| 11824 | const args: [2]Air.Inst.Ref = .{ err_return_trace, operand }; | 11835 | const args: [2]Air.Inst.Ref = .{ err_return_trace, operand }; |
| 11825 | _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null); | 11836 | _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null, null); |
| 11826 | return true; | 11837 | return true; |
| 11827 | }, | 11838 | }, |
| 11828 | .panic => { | 11839 | .panic => { |
| ... | @@ -11833,7 +11844,7 @@ fn maybeErrorUnwrap(sema: *Sema, block: *Block, body: []const Zir.Inst.Index, op | ... | @@ -11833,7 +11844,7 @@ fn maybeErrorUnwrap(sema: *Sema, block: *Block, body: []const Zir.Inst.Index, op |
| 11833 | const panic_fn = try sema.getBuiltin("panic"); | 11844 | const panic_fn = try sema.getBuiltin("panic"); |
| 11834 | const err_return_trace = try sema.getErrorReturnTrace(block); | 11845 | const err_return_trace = try sema.getErrorReturnTrace(block); |
| 11835 | const args: [3]Air.Inst.Ref = .{ msg_inst, err_return_trace, .null_value }; | 11846 | const args: [3]Air.Inst.Ref = .{ msg_inst, err_return_trace, .null_value }; |
| 11836 | _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null); | 11847 | _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null, null); |
| 11837 | return true; | 11848 | return true; |
| 11838 | }, | 11849 | }, |
| 11839 | else => unreachable, | 11850 | else => unreachable, |
| ... | @@ -17279,7 +17290,7 @@ fn retWithErrTracing( | ... | @@ -17279,7 +17290,7 @@ fn retWithErrTracing( |
| 17279 | const args: [1]Air.Inst.Ref = .{err_return_trace}; | 17290 | const args: [1]Air.Inst.Ref = .{err_return_trace}; |
| 17280 | | 17291 | |
| 17281 | if (!need_check) { | 17292 | if (!need_check) { |
| 17282 | _ = try sema.analyzeCall(block, return_err_fn, src, src, .never_inline, false, &args, null); | 17293 | _ = try sema.analyzeCall(block, return_err_fn, src, src, .never_inline, false, &args, null, null); |
| 17283 | _ = try block.addUnOp(ret_tag, operand); | 17294 | _ = try block.addUnOp(ret_tag, operand); |
| 17284 | return always_noreturn; | 17295 | return always_noreturn; |
| 17285 | } | 17296 | } |
| ... | @@ -17290,7 +17301,7 @@ fn retWithErrTracing( | ... | @@ -17290,7 +17301,7 @@ fn retWithErrTracing( |
| 17290 | | 17301 | |
| 17291 | var else_block = block.makeSubBlock(); | 17302 | var else_block = block.makeSubBlock(); |
| 17292 | defer else_block.instructions.deinit(gpa); | 17303 | defer else_block.instructions.deinit(gpa); |
| 17293 | _ = try sema.analyzeCall(&else_block, return_err_fn, src, src, .never_inline, false, &args, null); | 17304 | _ = try sema.analyzeCall(&else_block, return_err_fn, src, src, .never_inline, false, &args, null, null); |
| 17294 | _ = try else_block.addUnOp(ret_tag, operand); | 17305 | _ = try else_block.addUnOp(ret_tag, operand); |
| 17295 | | 17306 | |
| 17296 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len + | 17307 | try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len + |
| ... | @@ -21647,7 +21658,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -21647,7 +21658,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 21647 | } | 21658 | } |
| 21648 | } | 21659 | } |
| 21649 | const ensure_result_used = extra.flags.ensure_result_used; | 21660 | const ensure_result_used = extra.flags.ensure_result_used; |
| 21650 | return sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src); | 21661 | return sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src, null); |
| 21651 | } | 21662 | } |
| 21652 | | 21663 | |
| 21653 | fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 21664 | fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -23481,7 +23492,7 @@ fn panicWithMsg( | ... | @@ -23481,7 +23492,7 @@ fn panicWithMsg( |
| 23481 | Value.null, | 23492 | Value.null, |
| 23482 | ); | 23493 | ); |
| 23483 | const args: [3]Air.Inst.Ref = .{ msg_inst, null_stack_trace, .null_value }; | 23494 | const args: [3]Air.Inst.Ref = .{ msg_inst, null_stack_trace, .null_value }; |
| 23484 | _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null); | 23495 | _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, &args, null, null); |
| 23485 | } | 23496 | } |
| 23486 | | 23497 | |
| 23487 | fn panicUnwrapError( | 23498 | fn panicUnwrapError( |
| ... | @@ -23519,7 +23530,7 @@ fn panicUnwrapError( | ... | @@ -23519,7 +23530,7 @@ fn panicUnwrapError( |
| 23519 | const err = try fail_block.addTyOp(unwrap_err_tag, Type.anyerror, operand); | 23530 | const err = try fail_block.addTyOp(unwrap_err_tag, Type.anyerror, operand); |
| 23520 | const err_return_trace = try sema.getErrorReturnTrace(&fail_block); | 23531 | const err_return_trace = try sema.getErrorReturnTrace(&fail_block); |
| 23521 | const args: [2]Air.Inst.Ref = .{ err_return_trace, err }; | 23532 | const args: [2]Air.Inst.Ref = .{ err_return_trace, err }; |
| 23522 | _ = try sema.analyzeCall(&fail_block, panic_fn, sema.src, sema.src, .auto, false, &args, null); | 23533 | _ = try sema.analyzeCall(&fail_block, panic_fn, sema.src, sema.src, .auto, false, &args, null, null); |
| 23523 | } | 23534 | } |
| 23524 | } | 23535 | } |
| 23525 | try sema.addSafetyCheckExtra(parent_block, ok, &fail_block); | 23536 | try sema.addSafetyCheckExtra(parent_block, ok, &fail_block); |
| ... | @@ -23604,7 +23615,7 @@ fn panicSentinelMismatch( | ... | @@ -23604,7 +23615,7 @@ fn panicSentinelMismatch( |
| 23604 | else { | 23615 | else { |
| 23605 | const panic_fn = try sema.getBuiltin("checkNonScalarSentinel"); | 23616 | const panic_fn = try sema.getBuiltin("checkNonScalarSentinel"); |
| 23606 | const args: [2]Air.Inst.Ref = .{ expected_sentinel, actual_sentinel }; | 23617 | const args: [2]Air.Inst.Ref = .{ expected_sentinel, actual_sentinel }; |
| 23607 | _ = try sema.analyzeCall(parent_block, panic_fn, sema.src, sema.src, .auto, false, &args, null); | 23618 | _ = try sema.analyzeCall(parent_block, panic_fn, sema.src, sema.src, .auto, false, &args, null, null); |
| 23608 | return; | 23619 | return; |
| 23609 | }; | 23620 | }; |
| 23610 | | 23621 | |
| ... | @@ -23641,7 +23652,7 @@ fn safetyCheckFormatted( | ... | @@ -23641,7 +23652,7 @@ fn safetyCheckFormatted( |
| 23641 | _ = try fail_block.addNoOp(.trap); | 23652 | _ = try fail_block.addNoOp(.trap); |
| 23642 | } else { | 23653 | } else { |
| 23643 | const panic_fn = try sema.getBuiltin(func); | 23654 | const panic_fn = try sema.getBuiltin(func); |
| 23644 | _ = try sema.analyzeCall(&fail_block, panic_fn, sema.src, sema.src, .auto, false, args, null); | 23655 | _ = try sema.analyzeCall(&fail_block, panic_fn, sema.src, sema.src, .auto, false, args, null, null); |
| 23645 | } | 23656 | } |
| 23646 | try sema.addSafetyCheckExtra(parent_block, ok, &fail_block); | 23657 | try sema.addSafetyCheckExtra(parent_block, ok, &fail_block); |
| 23647 | } | 23658 | } |