started working on fixed bug from #63
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 6 Dec 2023 19:30:36 +0000 (13:30 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 6 Dec 2023 19:30:36 +0000 (13:30 -0600)
compiler/src/wasm_emit.c

index 4f0e0d4d02ec6dfceb16a479b4fea3b4b9856223..1be603707b7daf57ba158665514cebb8acca5e89 100644 (file)
@@ -2961,8 +2961,10 @@ EMIT_FUNC(compound_store, Type* type, u64 offset, b32 location_first) {
         type_linear_member_lookup(type, i, &two);
 
         WasmType wt = onyx_type_to_wasm_type(two.type);
-        temp_locals[i] = local_raw_allocate(mod->local_alloc, wt);
-        WIL(NULL, WI_LOCAL_SET, temp_locals[i]);
+        if (wt != WASM_TYPE_VOID) {
+            temp_locals[i] = local_raw_allocate(mod->local_alloc, wt);
+            WIL(NULL, WI_LOCAL_SET, temp_locals[i]);
+        }
     }
 
     if (!location_first) WIL(NULL, WI_LOCAL_SET, loc_idx);
@@ -2970,13 +2972,15 @@ EMIT_FUNC(compound_store, Type* type, u64 offset, b32 location_first) {
     fori (i, 0, elem_count) {
         type_linear_member_lookup(type, i, &two);
 
-        u64 tmp_idx = temp_locals[i];
-        WIL(NULL, WI_LOCAL_GET, loc_idx);
-        WIL(NULL, WI_LOCAL_GET, tmp_idx);
-        emit_store_instruction(mod, &code, two.type, offset + two.offset);
-
         WasmType wt = onyx_type_to_wasm_type(two.type);
-        local_raw_free(mod->local_alloc, wt);
+        if (wt != WASM_TYPE_VOID) {
+            u64 tmp_idx = temp_locals[i];
+            WIL(NULL, WI_LOCAL_GET, loc_idx);
+            WIL(NULL, WI_LOCAL_GET, tmp_idx);
+            emit_store_instruction(mod, &code, two.type, offset + two.offset);
+
+            local_raw_free(mod->local_alloc, wt);
+        }
     }
 
     local_raw_free(mod->local_alloc, WASM_TYPE_PTR);