diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-11-01 20:20:11 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-01 20:20:11 -0400 |
| commit | d892665694bc437898c58631cc632bc93a528e97 (patch) | |
| tree | 4aec2dd82c6ecb382a6601d8518cad2dc1ea6236 /src/arch/wasm/CodeGen.zig | |
| parent | 3ead829de191daa0bb4047aa4dfde3b1902e5cd2 (diff) | |
| parent | db1825e93159f753207f255ad6709074fece6dc5 (diff) | |
| download | zig-d892665694bc437898c58631cc632bc93a528e97.tar.gz zig-d892665694bc437898c58631cc632bc93a528e97.zip | |
Merge pull request #17819 from Luukdegram/wasm-bitcast-fix
wasm - fix bitcasting between arrays and scalar types
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
| -rw-r--r-- | src/arch/wasm/CodeGen.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index 9da4d3003b..21ddd91120 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -3814,6 +3814,16 @@ fn airBitcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { const bitcast_result = try func.bitcast(wanted_ty, given_ty, operand); break :result try bitcast_result.toLocal(func, wanted_ty); } + const mod = func.bin_file.base.options.module.?; + if (isByRef(given_ty, mod) and !isByRef(wanted_ty, mod)) { + const loaded_memory = try func.load(operand, wanted_ty, 0); + break :result try loaded_memory.toLocal(func, wanted_ty); + } + if (!isByRef(given_ty, mod) and isByRef(wanted_ty, mod)) { + const stack_memory = try func.allocStack(wanted_ty); + try func.store(stack_memory, operand, given_ty, 0); + break :result stack_memory; + } break :result func.reuseOperand(ty_op.operand, operand); }; func.finishAir(inst, result, &.{ty_op.operand}); |
