wasm: fix return ret_load with zero-size type

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.
This commit is contained in:
Luuk de Gram 2023-05-10 17:04:55 +02:00
parent 43e89026ac
commit 6c06944b59
No known key found for this signature in database
GPG Key ID: A8CFE58E4DC7D664
2 changed files with 4 additions and 9 deletions

View File

@ -12,9 +12,7 @@ var cmdline_buffer: [4096]u8 = undefined;
var fba = std.heap.FixedBufferAllocator.init(&cmdline_buffer);
pub fn main() void {
if (builtin.zig_backend == .stage2_wasm or
builtin.zig_backend == .stage2_aarch64)
{
if (builtin.zig_backend == .stage2_aarch64) {
return mainSimple() catch @panic("test failure");
}

View File

@ -2122,16 +2122,13 @@ fn airRetLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const un_op = func.air.instructions.items(.data)[inst].un_op;
const operand = try func.resolveInst(un_op);
const ret_ty = func.air.typeOf(un_op).childType();
const fn_info = func.decl.ty.fnInfo();
if (!ret_ty.hasRuntimeBitsIgnoreComptime()) {
if (ret_ty.isError()) {
try func.addImm32(0);
} else {
return func.finishAir(inst, .none, &.{});
}
}
const fn_info = func.decl.ty.fnInfo();
if (!firstParamSRet(fn_info.cc, fn_info.return_type, func.target)) {
} else if (!firstParamSRet(fn_info.cc, fn_info.return_type, func.target)) {
// leave on the stack
_ = try func.load(operand, ret_ty, 0);
}