| author | |
| committer | |
| log | 6c06944b5958e2b624004e986deee8e52c765e6e |
| tree | e5fe5776ad1cacb85125f82c7d07973688a58fb4 |
| parent | 43e89026ac90ee6e8c2cb066068eb8ff10352ac1 |
| signature |
When we have a `ret_load` instruction with a zero-sized type which was
not an error, we would not emit any instruction. This resulted in
no `return` instruction and also not correctly resetting the global
stack_pointer.
This commit also enables the regular test runner for the WebAssembly
backend.2 files changed, 4 insertions(+), 9 deletions(-)
lib/test_runner.zig+1-3| ... | ... | @@ -12,9 +12,7 @@ var cmdline_buffer: [4096]u8 = undefined; |
| 12 | 12 | var fba = std.heap.FixedBufferAllocator.init(&cmdline_buffer); |
| 13 | 13 | |
| 14 | 14 | pub fn main() void { |
| 15 | if (builtin.zig_backend == .stage2_wasm or | |
| 16 | builtin.zig_backend == .stage2_aarch64) | |
| 17 | { | |
| 15 | if (builtin.zig_backend == .stage2_aarch64) { | |
| 18 | 16 | return mainSimple() catch @panic("test failure"); |
| 19 | 17 | } |
| 20 | 18 |
src/arch/wasm/CodeGen.zig+3-6| ... | ... | @@ -2122,16 +2122,13 @@ fn airRetLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2122 | 2122 | const un_op = func.air.instructions.items(.data)[inst].un_op; |
| 2123 | 2123 | const operand = try func.resolveInst(un_op); |
| 2124 | 2124 | const ret_ty = func.air.typeOf(un_op).childType(); |
| 2125 | ||
| 2126 | const fn_info = func.decl.ty.fnInfo(); | |
| 2125 | 2127 | if (!ret_ty.hasRuntimeBitsIgnoreComptime()) { |
| 2126 | 2128 | if (ret_ty.isError()) { |
| 2127 | 2129 | try func.addImm32(0); |
| 2128 | } else { | |
| 2129 | return func.finishAir(inst, .none, &.{}); | |
| 2130 | 2130 | } |
| 2131 | } | |
| 2132 | ||
| 2133 | const fn_info = func.decl.ty.fnInfo(); | |
| 2134 | if (!firstParamSRet(fn_info.cc, fn_info.return_type, func.target)) { | |
| 2131 | } else if (!firstParamSRet(fn_info.cc, fn_info.return_type, func.target)) { | |
| 2135 | 2132 | // leave on the stack |
| 2136 | 2133 | _ = try func.load(operand, ret_ty, 0); |
| 2137 | 2134 | } |