From 724d75363855176aa5e6b3d9bcd1656e2cc1f6a6 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Wed, 14 Sep 2022 13:49:54 -0700 Subject: stage2: Add `.save_err_return_trace_index` AIR op This is encoded as a primitive AIR instruction to resolve one corner case: A function may include a `catch { ... }` or `else |err| { ... }` block but not call any errorable fn. In that case, there is no error return trace to save the index of and codegen needs to avoid interacting with the non-existing error trace. By using a primitive AIR op, we can depend on Liveness to mark this unused in this corner case. --- src/codegen/c.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/codegen/c.zig') diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 072091d9b2..d6584d75ae 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -1935,6 +1935,7 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO .errunion_payload_ptr_set => try airErrUnionPayloadPtrSet(f, inst), .err_return_trace => try airErrReturnTrace(f, inst), .set_err_return_trace => try airSetErrReturnTrace(f, inst), + .save_err_return_trace_index => try airSaveErrReturnTraceIndex(f, inst), .wasm_memory_size => try airWasmMemorySize(f, inst), .wasm_memory_grow => try airWasmMemoryGrow(f, inst), @@ -3625,6 +3626,11 @@ fn airSetErrReturnTrace(f: *Function, inst: Air.Inst.Index) !CValue { return f.fail("TODO: C backend: implement airSetErrReturnTrace", .{}); } +fn airSaveErrReturnTraceIndex(f: *Function, inst: Air.Inst.Index) !CValue { + _ = inst; + return f.fail("TODO: C backend: implement airSaveErrReturnTraceIndex", .{}); +} + fn airWrapErrUnionPay(f: *Function, inst: Air.Inst.Index) !CValue { if (f.liveness.isUnused(inst)) return CValue.none; -- cgit v1.2.3