From ccfacb541f4e788bf411adbcb377e7abd104110c Mon Sep 17 00:00:00 2001 From: "M.Shahabadi" Date: Sun, 17 Nov 2024 22:32:26 +0330 Subject: [PATCH] fix: redundant memory store statements for static variables --- ctowasm/src/processor/processDeclaration.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ctowasm/src/processor/processDeclaration.ts b/ctowasm/src/processor/processDeclaration.ts index c61f272..a183fd9 100644 --- a/ctowasm/src/processor/processDeclaration.ts +++ b/ctowasm/src/processor/processDeclaration.ts @@ -78,7 +78,8 @@ export function processLocalDeclaration( symbolEntry = symbolEntry as VariableSymbolEntry; // definitely not dealing with a function declaration already - if (typeof declaration.initializer !== "undefined") { + // We have already allocated space for data segment variables, no more memory statements are needed + if (typeof declaration.initializer !== "undefined" && symbolEntry.type !== "dataSegmentVariable") { return unpackLocalVariableInitializerAccordingToDataType( symbolEntry, declaration.initializer,