diff options
| author | Luuk de Gram <luuk@degram.dev> | 2022-08-16 20:41:48 +0200 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2022-08-18 14:17:01 +0200 |
| commit | 63c25cc1cc4aef1ae5c7425496d99b30db2f44d7 (patch) | |
| tree | 4601f32c41590e381b2249e3a90739371c01cb91 /src/arch/wasm/CodeGen.zig | |
| parent | df507edffe6c1087b5f4786cb64ccaffd02b6848 (diff) | |
| download | zig-63c25cc1cc4aef1ae5c7425496d99b30db2f44d7.tar.gz zig-63c25cc1cc4aef1ae5c7425496d99b30db2f44d7.zip | |
wasm: fix callInstrinsic return value
Rather than storing it in a local and returning that,
we now keep this on the stack as all internal functions
expect it to be on the stack already and therefore were
generating extra `local.set` instructions.
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
| -rw-r--r-- | src/arch/wasm/CodeGen.zig | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index 8eb3e2175b..95a0a8e4aa 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -4106,7 +4106,6 @@ fn fpext(self: *Self, operand: WValue, given: Type, wanted: Type) InnerError!WVa return f32_result; } if (wanted_bits == 64) { - try self.emitWValue(f32_result); try self.addTag(.f64_promote_f32); return WValue{ .stack = {} }; } @@ -4628,7 +4627,6 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) InnerError!WValue { Type.f32, &.{ rhs_ext, lhs_ext, addend_ext }, ); - defer result.free(self); return try (try self.fptrunc(result, Type.f32, ty)).toLocal(self, ty); } @@ -5353,6 +5351,7 @@ fn airShlSat(self: *Self, inst: Air.Inst.Index) InnerError!WValue { /// This function call assumes the C-ABI. /// Asserts arguments are not stack values when the return value is /// passed as the first parameter. +/// May leave the return value on the stack. fn callIntrinsic( self: *Self, name: []const u8, @@ -5398,8 +5397,6 @@ fn callIntrinsic( } else if (want_sret_param) { return sret; } else { - const result_local = try self.allocLocal(return_type); - try self.addLabel(.local_set, result_local.local); - return result_local; + return WValue{ .stack = {} }; } } |
