| ... | @@ -1329,13 +1329,13 @@ fn analyzeBodyInner( | ... | @@ -1329,13 +1329,13 @@ fn analyzeBodyInner( |
| 1329 | }, | 1329 | }, |
| 1330 | .dbg_block_begin => { | 1330 | .dbg_block_begin => { |
| 1331 | dbg_block_begins += 1; | 1331 | dbg_block_begins += 1; |
| 1332 | try sema.zirDbgBlockBegin(block); | 1332 | try zirDbgBlockBegin(block); |
| 1333 | i += 1; | 1333 | i += 1; |
| 1334 | continue; | 1334 | continue; |
| 1335 | }, | 1335 | }, |
| 1336 | .dbg_block_end => { | 1336 | .dbg_block_end => { |
| 1337 | dbg_block_begins -= 1; | 1337 | dbg_block_begins -= 1; |
| 1338 | try sema.zirDbgBlockEnd(block); | 1338 | try zirDbgBlockEnd(block); |
| 1339 | i += 1; | 1339 | i += 1; |
| 1340 | continue; | 1340 | continue; |
| 1341 | }, | 1341 | }, |
| ... | @@ -1830,17 +1830,17 @@ fn analyzeBodyInner( | ... | @@ -1830,17 +1830,17 @@ fn analyzeBodyInner( |
| 1830 | }; | 1830 | }; |
| 1831 | | 1831 | |
| 1832 | // balance out dbg_block_begins in case of early noreturn | 1832 | // balance out dbg_block_begins in case of early noreturn |
| 1833 | const noreturn_inst = block.instructions.popOrNull(); | 1833 | if (!block.is_comptime and !block.ownerModule().strip) { |
| 1834 | while (dbg_block_begins > 0) { | 1834 | const noreturn_inst = block.instructions.popOrNull(); |
| 1835 | dbg_block_begins -= 1; | 1835 | while (dbg_block_begins > 0) { |
| 1836 | if (block.is_comptime or mod.comp.bin_file.options.strip) continue; | 1836 | dbg_block_begins -= 1; |
| 1837 | | 1837 | _ = try block.addInst(.{ |
| 1838 | _ = try block.addInst(.{ | 1838 | .tag = .dbg_block_end, |
| 1839 | .tag = .dbg_block_end, | 1839 | .data = undefined, |
| 1840 | .data = undefined, | 1840 | }); |
| 1841 | }); | 1841 | } |
| | 1842 | if (noreturn_inst) |some| try block.instructions.append(sema.gpa, some); |
| 1842 | } | 1843 | } |
| 1843 | if (noreturn_inst) |some| try block.instructions.append(sema.gpa, some); | | |
| 1844 | | 1844 | |
| 1845 | // We may have overwritten the capture scope due to a `repeat` instruction where | 1845 | // We may have overwritten the capture scope due to a `repeat` instruction where |
| 1846 | // the body had a capture; restore it now. | 1846 | // the body had a capture; restore it now. |
| ... | @@ -6272,7 +6272,7 @@ fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi | ... | @@ -6272,7 +6272,7 @@ fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi |
| 6272 | // ZIR code that possibly will need to generate runtime code. So error messages | 6272 | // ZIR code that possibly will need to generate runtime code. So error messages |
| 6273 | // and other source locations must not rely on sema.src being set from dbg_stmt | 6273 | // and other source locations must not rely on sema.src being set from dbg_stmt |
| 6274 | // instructions. | 6274 | // instructions. |
| 6275 | if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return; | 6275 | if (block.is_comptime or block.ownerModule().strip) return; |
| 6276 | | 6276 | |
| 6277 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt; | 6277 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt; |
| 6278 | | 6278 | |
| ... | @@ -6297,8 +6297,8 @@ fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi | ... | @@ -6297,8 +6297,8 @@ fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi |
| 6297 | }); | 6297 | }); |
| 6298 | } | 6298 | } |
| 6299 | | 6299 | |
| 6300 | fn zirDbgBlockBegin(sema: *Sema, block: *Block) CompileError!void { | 6300 | fn zirDbgBlockBegin(block: *Block) CompileError!void { |
| 6301 | if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return; | 6301 | if (block.is_comptime or block.ownerModule().strip) return; |
| 6302 | | 6302 | |
| 6303 | _ = try block.addInst(.{ | 6303 | _ = try block.addInst(.{ |
| 6304 | .tag = .dbg_block_begin, | 6304 | .tag = .dbg_block_begin, |
| ... | @@ -6306,8 +6306,8 @@ fn zirDbgBlockBegin(sema: *Sema, block: *Block) CompileError!void { | ... | @@ -6306,8 +6306,8 @@ fn zirDbgBlockBegin(sema: *Sema, block: *Block) CompileError!void { |
| 6306 | }); | 6306 | }); |
| 6307 | } | 6307 | } |
| 6308 | | 6308 | |
| 6309 | fn zirDbgBlockEnd(sema: *Sema, block: *Block) CompileError!void { | 6309 | fn zirDbgBlockEnd(block: *Block) CompileError!void { |
| 6310 | if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return; | 6310 | if (block.is_comptime or block.ownerModule().strip) return; |
| 6311 | | 6311 | |
| 6312 | _ = try block.addInst(.{ | 6312 | _ = try block.addInst(.{ |
| 6313 | .tag = .dbg_block_end, | 6313 | .tag = .dbg_block_end, |
| ... | @@ -6321,7 +6321,7 @@ fn zirDbgVar( | ... | @@ -6321,7 +6321,7 @@ fn zirDbgVar( |
| 6321 | inst: Zir.Inst.Index, | 6321 | inst: Zir.Inst.Index, |
| 6322 | air_tag: Air.Inst.Tag, | 6322 | air_tag: Air.Inst.Tag, |
| 6323 | ) CompileError!void { | 6323 | ) CompileError!void { |
| 6324 | if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return; | 6324 | if (block.is_comptime or block.ownerModule().strip) return; |
| 6325 | | 6325 | |
| 6326 | const str_op = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_op; | 6326 | const str_op = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_op; |
| 6327 | const operand = try sema.resolveInst(str_op.operand); | 6327 | const operand = try sema.resolveInst(str_op.operand); |
| ... | @@ -6519,7 +6519,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref | ... | @@ -6519,7 +6519,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref |
| 6519 | const src = sema.src; | 6519 | const src = sema.src; |
| 6520 | | 6520 | |
| 6521 | if (!mod.backendSupportsFeature(.error_return_trace)) return .none; | 6521 | if (!mod.backendSupportsFeature(.error_return_trace)) return .none; |
| 6522 | if (!mod.comp.bin_file.options.error_return_tracing) return .none; | 6522 | if (!block.ownerModule().error_tracing) return .none; |
| 6523 | | 6523 | |
| 6524 | if (block.is_comptime) | 6524 | if (block.is_comptime) |
| 6525 | return .none; | 6525 | return .none; |
| ... | @@ -6703,7 +6703,7 @@ fn zirCall( | ... | @@ -6703,7 +6703,7 @@ fn zirCall( |
| 6703 | input_is_error = false; | 6703 | input_is_error = false; |
| 6704 | } | 6704 | } |
| 6705 | | 6705 | |
| 6706 | if (mod.backendSupportsFeature(.error_return_trace) and mod.comp.bin_file.options.error_return_tracing and | 6706 | if (mod.backendSupportsFeature(.error_return_trace) and block.ownerModule().error_tracing and |
| 6707 | !block.is_comptime and !block.is_typeof and (input_is_error or pop_error_return_trace)) | 6707 | !block.is_comptime and !block.is_typeof and (input_is_error or pop_error_return_trace)) |
| 6708 | { | 6708 | { |
| 6709 | const return_ty = sema.typeOf(call_inst); | 6709 | const return_ty = sema.typeOf(call_inst); |
| ... | @@ -7456,7 +7456,7 @@ fn analyzeCall( | ... | @@ -7456,7 +7456,7 @@ fn analyzeCall( |
| 7456 | new_fn_info.return_type = sema.fn_ret_ty.toIntern(); | 7456 | new_fn_info.return_type = sema.fn_ret_ty.toIntern(); |
| 7457 | const new_func_resolved_ty = try mod.funcType(new_fn_info); | 7457 | const new_func_resolved_ty = try mod.funcType(new_fn_info); |
| 7458 | if (!is_comptime_call and !block.is_typeof) { | 7458 | if (!is_comptime_call and !block.is_typeof) { |
| 7459 | try sema.emitDbgInline(block, prev_fn_index, module_fn_index, new_func_resolved_ty, .dbg_inline_begin); | 7459 | try emitDbgInline(block, prev_fn_index, module_fn_index, new_func_resolved_ty, .dbg_inline_begin); |
| 7460 | | 7460 | |
| 7461 | const zir_tags = sema.code.instructions.items(.tag); | 7461 | const zir_tags = sema.code.instructions.items(.tag); |
| 7462 | for (fn_info.param_body) |param| switch (zir_tags[@intFromEnum(param)]) { | 7462 | for (fn_info.param_body) |param| switch (zir_tags[@intFromEnum(param)]) { |
| ... | @@ -7494,7 +7494,7 @@ fn analyzeCall( | ... | @@ -7494,7 +7494,7 @@ fn analyzeCall( |
| 7494 | if (!is_comptime_call and !block.is_typeof and | 7494 | if (!is_comptime_call and !block.is_typeof and |
| 7495 | sema.typeOf(result).zigTypeTag(mod) != .NoReturn) | 7495 | sema.typeOf(result).zigTypeTag(mod) != .NoReturn) |
| 7496 | { | 7496 | { |
| 7497 | try sema.emitDbgInline( | 7497 | try emitDbgInline( |
| 7498 | block, | 7498 | block, |
| 7499 | module_fn_index, | 7499 | module_fn_index, |
| 7500 | prev_fn_index, | 7500 | prev_fn_index, |
| ... | @@ -8067,15 +8067,13 @@ fn resolveTupleLazyValues(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) | ... | @@ -8067,15 +8067,13 @@ fn resolveTupleLazyValues(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) |
| 8067 | } | 8067 | } |
| 8068 | | 8068 | |
| 8069 | fn emitDbgInline( | 8069 | fn emitDbgInline( |
| 8070 | sema: *Sema, | | |
| 8071 | block: *Block, | 8070 | block: *Block, |
| 8072 | old_func: InternPool.Index, | 8071 | old_func: InternPool.Index, |
| 8073 | new_func: InternPool.Index, | 8072 | new_func: InternPool.Index, |
| 8074 | new_func_ty: Type, | 8073 | new_func_ty: Type, |
| 8075 | tag: Air.Inst.Tag, | 8074 | tag: Air.Inst.Tag, |
| 8076 | ) CompileError!void { | 8075 | ) CompileError!void { |
| 8077 | const mod = sema.mod; | 8076 | if (block.ownerModule().strip) return; |
| 8078 | if (mod.comp.bin_file.options.strip) return; | | |
| 8079 | | 8077 | |
| 8080 | // Recursive inline call; no dbg_inline needed. | 8078 | // Recursive inline call; no dbg_inline needed. |
| 8081 | if (old_func == new_func) return; | 8079 | if (old_func == new_func) return; |
| ... | @@ -9109,7 +9107,7 @@ fn handleExternLibName( | ... | @@ -9109,7 +9107,7 @@ fn handleExternLibName( |
| 9109 | ); | 9107 | ); |
| 9110 | break :blk; | 9108 | break :blk; |
| 9111 | } | 9109 | } |
| 9112 | if (!target.isWasm() and !comp.bin_file.options.pic) { | 9110 | if (!target.isWasm() and !block.ownerModule().pic) { |
| 9113 | return sema.fail( | 9111 | return sema.fail( |
| 9114 | block, | 9112 | block, |
| 9115 | src_loc, | 9113 | src_loc, |
| ... | @@ -18738,16 +18736,16 @@ fn wantErrorReturnTracing(sema: *Sema, fn_ret_ty: Type) bool { | ... | @@ -18738,16 +18736,16 @@ fn wantErrorReturnTracing(sema: *Sema, fn_ret_ty: Type) bool { |
| 18738 | const mod = sema.mod; | 18736 | const mod = sema.mod; |
| 18739 | if (!mod.backendSupportsFeature(.error_return_trace)) return false; | 18737 | if (!mod.backendSupportsFeature(.error_return_trace)) return false; |
| 18740 | | 18738 | |
| 18741 | return fn_ret_ty.isError(mod) and | 18739 | return fn_ret_ty.isError(mod) and mod.comp.config.any_error_tracing; |
| 18742 | mod.comp.bin_file.options.error_return_tracing; | | |
| 18743 | } | 18740 | } |
| 18744 | | 18741 | |
| 18745 | fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 18742 | fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 18746 | const mod = sema.mod; | 18743 | const mod = sema.mod; |
| 18747 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].save_err_ret_index; | 18744 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].save_err_ret_index; |
| 18748 | | 18745 | |
| | 18746 | // TODO: replace all of these checks with logic in module creation |
| 18749 | if (!mod.backendSupportsFeature(.error_return_trace)) return; | 18747 | if (!mod.backendSupportsFeature(.error_return_trace)) return; |
| 18750 | if (!mod.comp.bin_file.options.error_return_tracing) return; | 18748 | if (!block.ownerModule().error_tracing) return; |
| 18751 | | 18749 | |
| 18752 | // This is only relevant at runtime. | 18750 | // This is only relevant at runtime. |
| 18753 | if (block.is_comptime or block.is_typeof) return; | 18751 | if (block.is_comptime or block.is_typeof) return; |
| ... | @@ -18774,7 +18772,7 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) | ... | @@ -18774,7 +18772,7 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) |
| 18774 | | 18772 | |
| 18775 | if (!mod.backendSupportsFeature(.error_return_trace)) return; | 18773 | if (!mod.backendSupportsFeature(.error_return_trace)) return; |
| 18776 | if (!ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn) return; | 18774 | if (!ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn) return; |
| 18777 | if (!mod.comp.bin_file.options.error_return_tracing) return; | 18775 | if (!start_block.ownerModule().error_tracing) return; |
| 18778 | | 18776 | |
| 18779 | const tracy = trace(@src()); | 18777 | const tracy = trace(@src()); |
| 18780 | defer tracy.end(); | 18778 | defer tracy.end(); |
| ... | @@ -20045,7 +20043,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { | ... | @@ -20045,7 +20043,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
| 20045 | | 20043 | |
| 20046 | if (sema.owner_func_index != .none and | 20044 | if (sema.owner_func_index != .none and |
| 20047 | ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn and | 20045 | ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn and |
| 20048 | mod.comp.bin_file.options.error_return_tracing and | 20046 | mod.ownerModule().error_tracing and |
| 20049 | mod.backendSupportsFeature(.error_return_trace)) | 20047 | mod.backendSupportsFeature(.error_return_trace)) |
| 20050 | { | 20048 | { |
| 20051 | return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty); | 20049 | return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty); |
| ... | @@ -34504,7 +34502,9 @@ pub fn resolveFnTypes(sema: *Sema, fn_ty: Type) CompileError!void { | ... | @@ -34504,7 +34502,9 @@ pub fn resolveFnTypes(sema: *Sema, fn_ty: Type) CompileError!void { |
| 34504 | | 34502 | |
| 34505 | try sema.resolveTypeFully(Type.fromInterned(fn_ty_info.return_type)); | 34503 | try sema.resolveTypeFully(Type.fromInterned(fn_ty_info.return_type)); |
| 34506 | | 34504 | |
| 34507 | if (mod.comp.bin_file.options.error_return_tracing and Type.fromInterned(fn_ty_info.return_type).isError(mod)) { | 34505 | if (mod.comp.config.any_error_tracing and |
| | 34506 | Type.fromInterned(fn_ty_info.return_type).isError(mod)) |
| | 34507 | { |
| 34508 | // Ensure the type exists so that backends can assume that. | 34508 | // Ensure the type exists so that backends can assume that. |
| 34509 | _ = try sema.getBuiltinType("StackTrace"); | 34509 | _ = try sema.getBuiltinType("StackTrace"); |
| 34510 | } | 34510 | } |