cleanup garbage symbols in debug info
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 9 Jan 2023 01:12:40 +0000 (19:12 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 9 Jan 2023 01:12:40 +0000 (19:12 -0600)
compiler/src/wasm_emit.c

index 78753bd521d819884fe201ea29669cde73d480cf..f6504efd1ccb1451d936737741038f89defbe563 100644 (file)
@@ -726,30 +726,32 @@ EMIT_FUNC(local_allocation, AstTyped* stmt) {
     u64 local_idx = local_allocate(mod->local_alloc, stmt);
     bh_imap_put(&mod->local_map, (u64) stmt, local_idx);
 
-    if (stmt->token && local_is_wasm_local(stmt)) {
-        debug_introduce_symbol(mod, stmt->token, DSL_REGISTER, local_idx, stmt->type);
-    } else {
-        debug_introduce_symbol(mod, stmt->token, DSL_STACK, local_idx, stmt->type);
-    }
+    if (stmt->kind == Ast_Kind_Local) {
+        if (stmt->token && local_is_wasm_local(stmt)) {
+            debug_introduce_symbol(mod, stmt->token, DSL_REGISTER, local_idx, stmt->type);
+        } else {
+            debug_introduce_symbol(mod, stmt->token, DSL_STACK, local_idx, stmt->type);
+        }
 
-    if (stmt->kind == Ast_Kind_Local && !(stmt->flags & Ast_Flag_Decl_Followed_By_Init)) {
-        bh_arr(WasmInstruction) code = *pcode;
-        if (local_is_wasm_local(stmt)) {
-            emit_zero_value(mod, &code, onyx_type_to_wasm_type(stmt->type));
-            WIL(stmt->token, WI_LOCAL_SET, local_idx);
+        if (!(stmt->flags & Ast_Flag_Decl_Followed_By_Init)) {
+            bh_arr(WasmInstruction) code = *pcode;
+            if (local_is_wasm_local(stmt)) {
+                emit_zero_value(mod, &code, onyx_type_to_wasm_type(stmt->type));
+                WIL(stmt->token, WI_LOCAL_SET, local_idx);
 
-        } else {
-            emit_location(mod, &code, stmt);
-            WID(stmt->token, WI_I32_CONST, 0);
-            WID(stmt->token, WI_I32_CONST, type_size_of(stmt->type));
-            if (context.options->use_post_mvp_features) {
-                WID(stmt->token, WI_MEMORY_FILL, 0x00);
             } else {
-                emit_intrinsic_memory_fill(mod, &code);
+                emit_location(mod, &code, stmt);
+                WID(stmt->token, WI_I32_CONST, 0);
+                WID(stmt->token, WI_I32_CONST, type_size_of(stmt->type));
+                if (context.options->use_post_mvp_features) {
+                    WID(stmt->token, WI_MEMORY_FILL, 0x00);
+                } else {
+                    emit_intrinsic_memory_fill(mod, &code);
+                }
             }
-        }
 
-        *pcode = code;
+            *pcode = code;
+        }
     }
 
     bh_arr_push(mod->local_allocations, ((AllocatedSpace) {