Skip to content

Commit 63c25cc

Browse files
committed
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.
1 parent df507ed commit 63c25cc

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/arch/wasm/CodeGen.zig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4106,7 +4106,6 @@ fn fpext(self: *Self, operand: WValue, given: Type, wanted: Type) InnerError!WVa
41064106
return f32_result;
41074107
}
41084108
if (wanted_bits == 64) {
4109-
try self.emitWValue(f32_result);
41104109
try self.addTag(.f64_promote_f32);
41114110
return WValue{ .stack = {} };
41124111
}
@@ -4628,7 +4627,6 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) InnerError!WValue {
46284627
Type.f32,
46294628
&.{ rhs_ext, lhs_ext, addend_ext },
46304629
);
4631-
defer result.free(self);
46324630
return try (try self.fptrunc(result, Type.f32, ty)).toLocal(self, ty);
46334631
}
46344632

@@ -5353,6 +5351,7 @@ fn airShlSat(self: *Self, inst: Air.Inst.Index) InnerError!WValue {
53535351
/// This function call assumes the C-ABI.
53545352
/// Asserts arguments are not stack values when the return value is
53555353
/// passed as the first parameter.
5354+
/// May leave the return value on the stack.
53565355
fn callIntrinsic(
53575356
self: *Self,
53585357
name: []const u8,
@@ -5398,8 +5397,6 @@ fn callIntrinsic(
53985397
} else if (want_sret_param) {
53995398
return sret;
54005399
} else {
5401-
const result_local = try self.allocLocal(return_type);
5402-
try self.addLabel(.local_set, result_local.local);
5403-
return result_local;
5400+
return WValue{ .stack = {} };
54045401
}
54055402
}

0 commit comments

Comments
 (0)