aboutsummaryrefslogtreecommitdiff
path: root/src/arch/wasm/CodeGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-03 18:31:55 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-03 18:31:55 -0700
commite532b0c0b5d55d212d885c779ab9f2fa7443e56a (patch)
tree0a1e9b277c745518f2b64d8913fe5e065fe9cc1b /src/arch/wasm/CodeGen.zig
parent7fd32de0180c29dc4e3da72e9347f6f5ce167a38 (diff)
downloadzig-e532b0c0b5d55d212d885c779ab9f2fa7443e56a.tar.gz
zig-e532b0c0b5d55d212d885c779ab9f2fa7443e56a.zip
stage2: cleanups to wasm memory intrinsics
* AIR: use pl_op instead of ty_pl for wasm_memory_size. No need to store the type because the type is always `u32`. * AstGen: use coerced_ty for `@wasmMemorySize` and `@wasmMemoryGrow` and do the coercions in Sema. * Sema: use more accurate source locations for errors. * Provide more information in the compiler error message. * Codegen: use liveness data to avoid lowering unused `@wasmMemorySize`. * LLVM backend: add implementation - I wasn't able to test it because we are hitting a linker error for `-target wasm32-wasi -fLLVM`. * C backend: use `zig_unimplemented()` instead of silently doing wrong behavior for these builtins. * behavior tests: branch only on stage2_arch for inclusion of the wasm.zig file. We would change it to `builtin.cpu.arch` but that is causing a compiler crash on some backends.
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
-rw-r--r--src/arch/wasm/CodeGen.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig
index b1c4be9fef..ca571370ad 100644
--- a/src/arch/wasm/CodeGen.zig
+++ b/src/arch/wasm/CodeGen.zig
@@ -3430,10 +3430,12 @@ fn airPrefetch(self: *Self, inst: Air.Inst.Index) InnerError!WValue {
}
fn airWasmMemorySize(self: *Self, inst: Air.Inst.Index) !WValue {
- const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
+ if (self.liveness.isUnused(inst)) return WValue{ .none = {} };
+
+ const pl_op = self.air.instructions.items(.data)[inst].pl_op;
const result = try self.allocLocal(self.air.typeOfIndex(inst));
- try self.addLabel(.memory_size, ty_pl.payload);
+ try self.addLabel(.memory_size, pl_op.payload);
try self.addLabel(.local_set, result.local);
return result;
}