From f3bb9debe6af0576d76bda1580df2570e749bd36 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 22 Aug 2016 16:01:10 -0700 Subject: handle asm.js globals that are set and the return value used --- src/asm2wasm.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 52598ad0b..321d5275e 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1014,7 +1014,10 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { } // global var assert(mappedGlobals.find(name) != mappedGlobals.end()); - return builder.makeSetGlobal(name, process(ast[3])); + auto* ret = builder.makeSetGlobal(name, process(ast[3])); + // set_global does not return; if our value is trivially not used, don't emit a load (if nontrivially not used, opts get it later) + if (astStackHelper.getParent()[0] == STAT) return ret; + return builder.makeSequence(ret, builder.makeGetGlobal(name, ret->value->type)); } else if (ast[2][0] == SUB) { Ref target = ast[2]; assert(target[1][0] == NAME); -- cgit v1.2.3