| author | |
| committer | |
| log | 66c3988e5eebd423844d5dd20c762d6fefe20adf |
| tree | fa946dcc687f49cf8e20851f15bb1f5028beef93 |
| parent | eee8fffec70b1d3e2900970dbe836e346e499231 |
8 files changed, 42 insertions(+), 64 deletions(-)
lib/test_runner.zig+2-2| ... | ... | @@ -92,9 +92,9 @@ pub fn main() void { |
| 92 | 92 | fail_count += 1; |
| 93 | 93 | progress.log("FAIL ({s})\n", .{@errorName(err)}); |
| 94 | 94 | if (!have_tty) std.debug.print("FAIL ({s})\n", .{@errorName(err)}); |
| 95 | if (builtin.zig_backend != .stage2_llvm) if (@errorReturnTrace()) |trace| { | |
| 95 | if (@errorReturnTrace()) |trace| { | |
| 96 | 96 | std.debug.dumpStackTrace(trace.*); |
| 97 | }; | |
| 97 | } | |
| 98 | 98 | test_node.end(); |
| 99 | 99 | }, |
| 100 | 100 | } |
src/Sema.zig+18-2| ... | ... | @@ -1412,6 +1412,12 @@ fn analyzeAsType( |
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | 1414 | pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize) !void { |
| 1415 | const backend_supports_error_return_tracing = false; | |
| 1416 | if (!backend_supports_error_return_tracing) { | |
| 1417 | // TODO implement this feature in all the backends and then delete this branch | |
| 1418 | return; | |
| 1419 | } | |
| 1420 | ||
| 1415 | 1421 | var err_trace_block = block.makeSubBlock(); |
| 1416 | 1422 | err_trace_block.is_comptime = false; |
| 1417 | 1423 | defer err_trace_block.instructions.deinit(sema.gpa); |
| ... | ... | @@ -12655,7 +12661,12 @@ fn analyzeRet( |
| 12655 | 12661 | return always_noreturn; |
| 12656 | 12662 | } |
| 12657 | 12663 | |
| 12658 | if (sema.fn_ret_ty.isError() and sema.mod.comp.bin_file.options.error_return_tracing) { | |
| 12664 | // TODO implement this feature in all the backends and then delete this check. | |
| 12665 | const backend_supports_error_return_tracing = false; | |
| 12666 | ||
| 12667 | if (sema.fn_ret_ty.isError() and sema.mod.comp.bin_file.options.error_return_tracing and | |
| 12668 | backend_supports_error_return_tracing) | |
| 12669 | { | |
| 12659 | 12670 | const return_err_fn = try sema.getBuiltin(block, src, "returnError"); |
| 12660 | 12671 | const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace"); |
| 12661 | 12672 | const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty); |
| ... | ... | @@ -13397,9 +13408,14 @@ fn zirErrorReturnTrace( |
| 13397 | 13408 | const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace"); |
| 13398 | 13409 | const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty); |
| 13399 | 13410 | const opt_ptr_stack_trace_ty = try Type.Tag.optional_single_mut_pointer.create(sema.arena, stack_trace_ty); |
| 13411 | ||
| 13412 | // TODO implement this feature in all the backends and then delete this check. | |
| 13413 | const backend_supports_error_return_tracing = false; | |
| 13414 | ||
| 13400 | 13415 | if (sema.owner_func != null and |
| 13401 | 13416 | sema.owner_func.?.calls_or_awaits_errorable_fn and |
| 13402 | sema.mod.comp.bin_file.options.error_return_tracing) | |
| 13417 | sema.mod.comp.bin_file.options.error_return_tracing and | |
| 13418 | backend_supports_error_return_tracing) | |
| 13403 | 13419 | { |
| 13404 | 13420 | return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty); |
| 13405 | 13421 | } |
src/arch/aarch64/CodeGen.zig+4-8| ... | ... | @@ -2333,21 +2333,17 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { |
| 2333 | 2333 | } |
| 2334 | 2334 | |
| 2335 | 2335 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 2336 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 2336 | _ = inst; | |
| 2337 | 2337 | const result: MCValue = if (self.liveness.isUnused(inst)) |
| 2338 | 2338 | .dead |
| 2339 | 2339 | else |
| 2340 | 2340 | return self.fail("TODO implement airErrReturnTrace for {}", .{self.target.cpu.arch}); |
| 2341 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | |
| 2341 | return self.finishAir(inst, result, .{ .none, .none, .none }); | |
| 2342 | 2342 | } |
| 2343 | 2343 | |
| 2344 | 2344 | fn airSetErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 2345 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 2346 | const result: MCValue = if (self.liveness.isUnused(inst)) | |
| 2347 | .dead | |
| 2348 | else | |
| 2349 | return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch}); | |
| 2350 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | |
| 2345 | _ = inst; | |
| 2346 | return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch}); | |
| 2351 | 2347 | } |
| 2352 | 2348 | |
| 2353 | 2349 | fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void { |
src/arch/arm/CodeGen.zig+4-8| ... | ... | @@ -1846,21 +1846,17 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { |
| 1846 | 1846 | } |
| 1847 | 1847 | |
| 1848 | 1848 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 1849 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 1849 | _ = inst; | |
| 1850 | 1850 | const result: MCValue = if (self.liveness.isUnused(inst)) |
| 1851 | 1851 | .dead |
| 1852 | 1852 | else |
| 1853 | 1853 | return self.fail("TODO implement airErrReturnTrace for {}", .{self.target.cpu.arch}); |
| 1854 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | |
| 1854 | return self.finishAir(inst, result, .{ .none, .none, .none }); | |
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | 1857 | fn airSetErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 1858 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 1859 | const result: MCValue = if (self.liveness.isUnused(inst)) | |
| 1860 | .dead | |
| 1861 | else | |
| 1862 | return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch}); | |
| 1863 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | |
| 1858 | _ = inst; | |
| 1859 | return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch}); | |
| 1864 | 1860 | } |
| 1865 | 1861 | |
| 1866 | 1862 | /// T to E!T |
src/arch/riscv64/CodeGen.zig+4-8| ... | ... | @@ -1270,21 +1270,17 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { |
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 1273 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 1273 | _ = inst; | |
| 1274 | 1274 | const result: MCValue = if (self.liveness.isUnused(inst)) |
| 1275 | 1275 | .dead |
| 1276 | 1276 | else |
| 1277 | 1277 | return self.fail("TODO implement airErrReturnTrace for {}", .{self.target.cpu.arch}); |
| 1278 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | |
| 1278 | return self.finishAir(inst, result, .{ .none, .none, .none }); | |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | fn airSetErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 1282 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 1283 | const result: MCValue = if (self.liveness.isUnused(inst)) | |
| 1284 | .dead | |
| 1285 | else | |
| 1286 | return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch}); | |
| 1287 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | |
| 1282 | _ = inst; | |
| 1283 | return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch}); | |
| 1288 | 1284 | } |
| 1289 | 1285 | |
| 1290 | 1286 | fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void { |
src/arch/x86_64/CodeGen.zig+4-8| ... | ... | @@ -1858,21 +1858,17 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { |
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | 1860 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 1861 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 1861 | _ = inst; | |
| 1862 | 1862 | const result: MCValue = if (self.liveness.isUnused(inst)) |
| 1863 | 1863 | .dead |
| 1864 | 1864 | else |
| 1865 | 1865 | return self.fail("TODO implement airErrReturnTrace for {}", .{self.target.cpu.arch}); |
| 1866 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | |
| 1866 | return self.finishAir(inst, result, .{ .none, .none, .none }); | |
| 1867 | 1867 | } |
| 1868 | 1868 | |
| 1869 | 1869 | fn airSetErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 1870 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | |
| 1871 | const result: MCValue = if (self.liveness.isUnused(inst)) | |
| 1872 | .dead | |
| 1873 | else | |
| 1874 | return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch}); | |
| 1875 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | |
| 1870 | _ = inst; | |
| 1871 | return self.fail("TODO implement airSetErrReturnTrace for {}", .{self.target.cpu.arch}); | |
| 1876 | 1872 | } |
| 1877 | 1873 | |
| 1878 | 1874 | fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void { |
src/codegen/c.zig+1-23| ... | ... | @@ -3451,33 +3451,11 @@ fn airErrUnionPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3451 | 3451 | |
| 3452 | 3452 | fn airErrReturnTrace(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3453 | 3453 | if (f.liveness.isUnused(inst)) return CValue.none; |
| 3454 | ||
| 3455 | const un_op = f.air.instructions.items(.data)[inst].un_op; | |
| 3456 | const writer = f.object.writer(); | |
| 3457 | const inst_ty = f.air.typeOfIndex(inst); | |
| 3458 | const operand = try f.resolveInst(un_op); | |
| 3459 | const local = try f.allocLocal(inst_ty, .Const); | |
| 3460 | ||
| 3461 | try writer.writeAll(" = "); | |
| 3462 | ||
| 3463 | _ = operand; | |
| 3464 | _ = local; | |
| 3465 | 3454 | return f.fail("TODO: C backend: implement airErrReturnTrace", .{}); |
| 3466 | 3455 | } |
| 3467 | 3456 | |
| 3468 | 3457 | fn airSetErrReturnTrace(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3469 | if (f.liveness.isUnused(inst)) return CValue.none; | |
| 3470 | ||
| 3471 | const un_op = f.air.instructions.items(.data)[inst].un_op; | |
| 3472 | const writer = f.object.writer(); | |
| 3473 | const inst_ty = f.air.typeOfIndex(inst); | |
| 3474 | const operand = try f.resolveInst(un_op); | |
| 3475 | const local = try f.allocLocal(inst_ty, .Const); | |
| 3476 | ||
| 3477 | try writer.writeAll(" = "); | |
| 3478 | ||
| 3479 | _ = operand; | |
| 3480 | _ = local; | |
| 3458 | _ = inst; | |
| 3481 | 3459 | return f.fail("TODO: C backend: implement airSetErrReturnTrace", .{}); |
| 3482 | 3460 | } |
| 3483 | 3461 |
src/codegen/llvm.zig+5-5| ... | ... | @@ -637,7 +637,7 @@ pub const Object = struct { |
| 637 | 637 | const gpa = dg.gpa; |
| 638 | 638 | |
| 639 | 639 | const err_return_tracing = fn_info.return_type.isError() and |
| 640 | dg.module.comp.bin_file.options.error_return_tracing; | |
| 640 | dg.module.comp.bin_file.options.error_return_tracing and false; | |
| 641 | 641 | |
| 642 | 642 | const err_ret_trace = if (err_return_tracing) |
| 643 | 643 | llvm_func.getParam(@boolToInt(ret_ptr != null)) |
| ... | ... | @@ -1765,7 +1765,7 @@ pub const Object = struct { |
| 1765 | 1765 | } |
| 1766 | 1766 | |
| 1767 | 1767 | if (fn_info.return_type.isError() and |
| 1768 | o.module.comp.bin_file.options.error_return_tracing) | |
| 1768 | o.module.comp.bin_file.options.error_return_tracing and false) | |
| 1769 | 1769 | { |
| 1770 | 1770 | var ptr_ty_payload: Type.Payload.ElemType = .{ |
| 1771 | 1771 | .base = .{ .tag = .single_mut_pointer }, |
| ... | ... | @@ -2018,7 +2018,7 @@ pub const DeclGen = struct { |
| 2018 | 2018 | } |
| 2019 | 2019 | |
| 2020 | 2020 | const err_return_tracing = fn_info.return_type.isError() and |
| 2021 | dg.module.comp.bin_file.options.error_return_tracing; | |
| 2021 | dg.module.comp.bin_file.options.error_return_tracing and false; | |
| 2022 | 2022 | |
| 2023 | 2023 | if (err_return_tracing) { |
| 2024 | 2024 | dg.addArgAttr(llvm_fn, @boolToInt(sret), "nonnull"); |
| ... | ... | @@ -2484,7 +2484,7 @@ pub const DeclGen = struct { |
| 2484 | 2484 | } |
| 2485 | 2485 | |
| 2486 | 2486 | if (fn_info.return_type.isError() and |
| 2487 | dg.module.comp.bin_file.options.error_return_tracing) | |
| 2487 | dg.module.comp.bin_file.options.error_return_tracing and false) | |
| 2488 | 2488 | { |
| 2489 | 2489 | var ptr_ty_payload: Type.Payload.ElemType = .{ |
| 2490 | 2490 | .base = .{ .tag = .single_mut_pointer }, |
| ... | ... | @@ -3796,7 +3796,7 @@ pub const FuncGen = struct { |
| 3796 | 3796 | }; |
| 3797 | 3797 | |
| 3798 | 3798 | if (fn_info.return_type.isError() and |
| 3799 | self.dg.module.comp.bin_file.options.error_return_tracing) | |
| 3799 | self.dg.module.comp.bin_file.options.error_return_tracing and false) | |
| 3800 | 3800 | { |
| 3801 | 3801 | try llvm_args.append(self.err_ret_trace.?); |
| 3802 | 3802 | } |