diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-29 16:39:17 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-29 16:39:17 -0700 |
commit | f33f1dbbee7b3f95d8437f1ee60c9075013858b6 (patch) | |
tree | f0f7a4bc5cd7d948f4285298b3b3930f30cc0185 | |
parent | 1715b4a1ec845f1dd6b08f48a599f346beb0f758 (diff) | |
parent | 44aeb85b2fa2c743e2d0f7e00349f99cfcbc7639 (diff) | |
download | binaryen-f33f1dbbee7b3f95d8437f1ee60c9075013858b6.tar.gz binaryen-f33f1dbbee7b3f95d8437f1ee60c9075013858b6.tar.bz2 binaryen-f33f1dbbee7b3f95d8437f1ee60c9075013858b6.zip |
Merge pull request #550 from WebAssembly/dfe-nice
Duplicate function elimination
-rwxr-xr-x | build-js.sh | 4 | ||||
-rw-r--r-- | src/ast_utils.h | 378 | ||||
-rw-r--r-- | src/passes/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/passes/DuplicateFunctionElimination.cpp | 179 | ||||
-rw-r--r-- | src/passes/Metrics.cpp | 4 | ||||
-rw-r--r-- | src/passes/ReorderLocals.cpp | 19 | ||||
-rw-r--r-- | src/passes/pass.cpp | 2 | ||||
-rw-r--r-- | src/support/hash.h | 39 | ||||
-rw-r--r-- | src/wasm.h | 12 | ||||
-rw-r--r-- | test/emcc_O2_hello_world.fromasm | 20 | ||||
-rw-r--r-- | test/emcc_O2_hello_world.fromasm.imprecise | 20 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm | 784 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm.imprecise | 784 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 33 | ||||
-rw-r--r-- | test/hello_libcxx.cpp | 8 | ||||
-rw-r--r-- | test/memorygrowth.fromasm | 40 | ||||
-rw-r--r-- | test/memorygrowth.fromasm.imprecise | 40 | ||||
-rw-r--r-- | test/passes/duplicate-function-elimination.txt | 864 | ||||
-rw-r--r-- | test/passes/duplicate-function-elimination.wast | 702 | ||||
-rw-r--r-- | test/passes/metrics.txt | 1 | ||||
-rw-r--r-- | test/unit.fromasm | 35 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise | 31 |
22 files changed, 3062 insertions, 938 deletions
diff --git a/build-js.sh b/build-js.sh index 726955a27..4643143a3 100755 --- a/build-js.sh +++ b/build-js.sh @@ -6,9 +6,9 @@ echo "building wasm.js" -em++ -std=c++11 src/wasm-js.cpp src/passes/pass.cpp src/passes/DeadCodeElimination.cpp src/passes/MergeBlocks.cpp src/passes/Print.cpp src/passes/OptimizeInstructions.cpp src/passes/RemoveUnusedBrs.cpp src/passes/RemoveUnusedNames.cpp src/passes/PostEmscripten.cpp src/passes/SimplifyLocals.cpp src/passes/ReorderLocals.cpp src/passes/Vacuum.cpp src/passes/CoalesceLocals.cpp src/emscripten-optimizer/parser.cpp src/emscripten-optimizer/simple_ast.cpp src/emscripten-optimizer/optimizer-shared.cpp src/support/colors.cpp src/support/safe_integer.cpp src/support/bits.cpp src/support/threads.cpp src/asmjs/asm_v_wasm.cpp src/asmjs/shared-constants.cpp src/wasm.cpp -Isrc/ -o bin/wasm.js -s MODULARIZE=1 -s 'EXPORT_NAME="WasmJS"' --memory-init-file 0 -Oz -s ALLOW_MEMORY_GROWTH=1 -profiling -s DEMANGLE_SUPPORT=1 #-DWASM_JS_DEBUG -DWASM_INTERPRETER_DEBUG=2 +em++ -std=c++11 src/wasm-js.cpp src/passes/pass.cpp src/passes/DeadCodeElimination.cpp src/passes/MergeBlocks.cpp src/passes/Print.cpp src/passes/OptimizeInstructions.cpp src/passes/RemoveUnusedBrs.cpp src/passes/RemoveUnusedNames.cpp src/passes/PostEmscripten.cpp src/passes/SimplifyLocals.cpp src/passes/ReorderLocals.cpp src/passes/Vacuum.cpp src/passes/DuplicateFunctionElimination.cpp src/passes/CoalesceLocals.cpp src/emscripten-optimizer/parser.cpp src/emscripten-optimizer/simple_ast.cpp src/emscripten-optimizer/optimizer-shared.cpp src/support/colors.cpp src/support/safe_integer.cpp src/support/bits.cpp src/support/threads.cpp src/asmjs/asm_v_wasm.cpp src/asmjs/shared-constants.cpp src/wasm.cpp -Isrc/ -o bin/wasm.js -s MODULARIZE=1 -s 'EXPORT_NAME="WasmJS"' --memory-init-file 0 -Oz -s ALLOW_MEMORY_GROWTH=1 -profiling -s DEMANGLE_SUPPORT=1 #-DWASM_JS_DEBUG -DWASM_INTERPRETER_DEBUG=2 echo "building binaryen.js" python ~/Dev/emscripten/tools/webidl_binder.py src/js/binaryen.idl glue -em++ -std=c++11 src/binaryen-js.cpp src/passes/pass.cpp src/passes/MergeBlocks.cpp src/passes/Print.cpp src/passes/RemoveUnusedBrs.cpp src/passes/RemoveUnusedNames.cpp src/passes/PostEmscripten.cpp src/passes/SimplifyLocals.cpp src/passes/ReorderLocals.cpp src/passes/Vacuum.cpp src/passes/CoalesceLocals.cpp src/emscripten-optimizer/parser.cpp src/emscripten-optimizer/simple_ast.cpp src/emscripten-optimizer/optimizer-shared.cpp src/support/colors.cpp src/support/safe_integer.cpp src/support/bits.cpp src/support/threads.cpp src/asmjs/asm_v_wasm.cpp src/asmjs/shared-constants.cpp src/wasm.cpp -Isrc/ -o bin/binaryen.js -s MODULARIZE=1 -s 'EXPORT_NAME="Binaryen"' --memory-init-file 0 -Oz -s ALLOW_MEMORY_GROWTH=1 -profiling -s DEMANGLE_SUPPORT=1 -s INVOKE_RUN=0 --post-js glue.js +em++ -std=c++11 src/binaryen-js.cpp src/passes/pass.cpp src/passes/MergeBlocks.cpp src/passes/Print.cpp src/passes/RemoveUnusedBrs.cpp src/passes/RemoveUnusedNames.cpp src/passes/PostEmscripten.cpp src/passes/SimplifyLocals.cpp src/passes/ReorderLocals.cpp src/passes/Vacuum.cpp src/passes/DuplicateFunctionElimination.cpp src/passes/CoalesceLocals.cpp src/emscripten-optimizer/parser.cpp src/emscripten-optimizer/simple_ast.cpp src/emscripten-optimizer/optimizer-shared.cpp src/support/colors.cpp src/support/safe_integer.cpp src/support/bits.cpp src/support/threads.cpp src/asmjs/asm_v_wasm.cpp src/asmjs/shared-constants.cpp src/wasm.cpp -Isrc/ -o bin/binaryen.js -s MODULARIZE=1 -s 'EXPORT_NAME="Binaryen"' --memory-init-file 0 -Oz -s ALLOW_MEMORY_GROWTH=1 -profiling -s DEMANGLE_SUPPORT=1 -s INVOKE_RUN=0 --post-js glue.js diff --git a/src/ast_utils.h b/src/ast_utils.h index a43fc6b2f..ee5c76b69 100644 --- a/src/ast_utils.h +++ b/src/ast_utils.h @@ -17,6 +17,7 @@ #ifndef wasm_ast_utils_h #define wasm_ast_utils_h +#include "support/hash.h" #include "wasm.h" #include "wasm-traversal.h" @@ -241,6 +242,383 @@ struct ExpressionAnalyzer { // The value might be used, so it depends on if the function returns return func->result != none; } + + static bool equal(Expression* left, Expression* right) { + std::vector<Name> nameStack; + std::map<Name, std::vector<Name>> rightNames; // for each name on the left, the stack of names on the right (a stack, since names are scoped and can nest duplicatively + Nop popNameMarker; + std::vector<Expression*> leftStack; + std::vector<Expression*> rightStack; + + auto noteNames = [&](Name left, Name right) { + if (left.is() != right.is()) return false; + if (left.is()) { + nameStack.push_back(left); + rightNames[left].push_back(right); + leftStack.push_back(&popNameMarker); + rightStack.push_back(&popNameMarker); + } + return true; + }; + auto checkNames = [&](Name left, Name right) { + auto iter = rightNames.find(left); + if (iter == rightNames.end()) return left == right; // non-internal name + return iter->second.back() == right; + }; + auto popName = [&]() { + auto left = nameStack.back(); + nameStack.pop_back(); + rightNames[left].pop_back(); + }; + + leftStack.push_back(left); + rightStack.push_back(right); + + while (leftStack.size() > 0 && rightStack.size() > 0) { + left = leftStack.back(); + leftStack.pop_back(); + right = rightStack.back(); + rightStack.pop_back(); + if (!left != !right) return false; + if (!left) continue; + if (left == &popNameMarker) { + popName(); + continue; + } + if (left->_id != right->_id) return false; + #define PUSH(clazz, what) \ + leftStack.push_back(left->cast<clazz>()->what); \ + rightStack.push_back(right->cast<clazz>()->what); + #define CHECK(clazz, what) \ + if (left->cast<clazz>()->what != right->cast<clazz>()->what) return false; + switch (left->_id) { + case Expression::Id::BlockId: { + if (!noteNames(left->cast<Block>()->name, right->cast<Block>()->name)) return false; + CHECK(Block, list.size()); + for (Index i = 0; i < left->cast<Block>()->list.size(); i++) { + PUSH(Block, list[i]); + } + break; + } + case Expression::Id::IfId: { + PUSH(If, condition); + PUSH(If, ifTrue); + PUSH(If, ifFalse); + break; + } + case Expression::Id::LoopId: { + if (!noteNames(left->cast<Loop>()->out, right->cast<Loop>()->out)) return false; + if (!noteNames(left->cast<Loop>()->in, right->cast<Loop>()->in)) return false; + PUSH(Loop, body); + break; + } + case Expression::Id::BreakId: { + if (!checkNames(left->cast<Break>()->name, right->cast<Break>()->name)) return false; + PUSH(Break, condition); + PUSH(Break, value); + break; + } + case Expression::Id::SwitchId: { + CHECK(Switch, targets.size()); + for (Index i = 0; i < left->cast<Switch>()->targets.size(); i++) { + if (!checkNames(left->cast<Switch>()->targets[i], right->cast<Switch>()->targets[i])) return false; + } + if (!checkNames(left->cast<Switch>()->default_, right->cast<Switch>()->default_)) return false; + PUSH(Switch, condition); + PUSH(Switch, value); + break; + } + case Expression::Id::CallId: { + CHECK(Call, target); + CHECK(Call, operands.size()); + for (Index i = 0; i < left->cast<Call>()->operands.size(); i++) { + PUSH(Call, operands[i]); + } + break; + } + case Expression::Id::CallImportId: { + CHECK(CallImport, target); + CHECK(CallImport, operands.size()); + for (Index i = 0; i < left->cast<CallImport>()->operands.size(); i++) { + PUSH(CallImport, operands[i]); + } + break; + } + case Expression::Id::CallIndirectId: { + PUSH(CallIndirect, target); + CHECK(CallIndirect, fullType); + CHECK(CallIndirect, operands.size()); + for (Index i = 0; i < left->cast<CallIndirect>()->operands.size(); i++) { + PUSH(CallIndirect, operands[i]); + } + break; + } + case Expression::Id::GetLocalId: { + CHECK(GetLocal, index); + break; + } + case Expression::Id::SetLocalId: { + CHECK(SetLocal, index); + PUSH(SetLocal, value); + break; + } + case Expression::Id::LoadId: { + CHECK(Load, bytes); + CHECK(Load, signed_); + CHECK(Load, offset); + CHECK(Load, align); + PUSH(Load, ptr); + break; + } + case Expression::Id::StoreId: { + CHECK(Store, bytes); + CHECK(Store, offset); + CHECK(Store, align); + PUSH(Store, ptr); + PUSH(Store, value); + break; + } + case Expression::Id::ConstId: { + CHECK(Const, value); + break; + } + case Expression::Id::UnaryId: { + CHECK(Unary, op); + PUSH(Unary, value); + break; + } + case Expression::Id::BinaryId: { + CHECK(Binary, op); + PUSH(Binary, left); + PUSH(Binary, right); + break; + } + case Expression::Id::SelectId: { + PUSH(Select, ifTrue); + PUSH(Select, ifFalse); + PUSH(Select, condition); + break; + } + case Expression::Id::ReturnId: { + PUSH(Return, value); + break; + } + case Expression::Id::HostId: { + CHECK(Host, op); + CHECK(Host, nameOperand); + CHECK(Host, operands.size()); + for (Index i = 0; i < left->cast<Host>()->operands.size(); i++) { + PUSH(Host, operands[i]); + } + break; + } + case Expression::Id::NopId: { + break; + } + case Expression::Id::UnreachableId: { + break; + } + default: WASM_UNREACHABLE(); + } + #undef CHECK + #undef PUSH + } + if (leftStack.size() > 0 || rightStack.size() > 0) return false; + return true; + } + + // hash an expression, ignoring superficial details like specific internal names + static uint32_t hash(Expression* curr) { + uint32_t digest = 0; + + auto hash = [&digest](uint32_t hash) { + digest = rehash(digest, hash); + }; + auto hash64 = [&digest](uint64_t hash) { + digest = rehash(rehash(digest, hash >> 32), uint32_t(hash)); + }; + + std::vector<Name> nameStack; + Index internalCounter = 0; + std::map<Name, std::vector<Index>> internalNames; // for each internal name, a vector if unique ids + Nop popNameMarker; + std::vector<Expression*> stack; + + auto noteName = [&](Name curr) { + if (curr.is()) { + nameStack.push_back(curr); + internalNames[curr].push_back(internalCounter++); + stack.push_back(&popNameMarker); + } + return true; + }; + auto hashName = [&](Name curr) { + auto iter = internalNames.find(curr); + if (iter == internalNames.end()) hash64(uint64_t(curr.str)); + else hash(iter->second.back()); + }; + auto popName = [&]() { + auto curr = nameStack.back(); + nameStack.pop_back(); + internalNames[curr].pop_back(); + }; + + stack.push_back(curr); + + while (stack.size() > 0) { + curr = stack.back(); + stack.pop_back(); + if (!curr) continue; + if (curr == &popNameMarker) { + popName(); + continue; + } + hash(curr->_id); + #define PUSH(clazz, what) \ + stack.push_back(curr->cast<clazz>()->what); + #define HASH(clazz, what) \ + hash(curr->cast<clazz>()->what); + #define HASH64(clazz, what) \ + hash64(curr->cast<clazz>()->what); + #define HASH_NAME(clazz, what) \ + hash64(uint64_t(curr->cast<clazz>()->what.str)); + #define HASH_PTR(clazz, what) \ + hash64(uint64_t(curr->cast<clazz>()->what)); + switch (curr->_id) { + case Expression::Id::BlockId: { + noteName(curr->cast<Block>()->name); + HASH(Block, list.size()); + for (Index i = 0; i < curr->cast<Block>()->list.size(); i++) { + PUSH(Block, list[i]); + } + break; + } + case Expression::Id::IfId: { + PUSH(If, condition); + PUSH(If, ifTrue); + PUSH(If, ifFalse); + break; + } + case Expression::Id::LoopId: { + noteName(curr->cast<Loop>()->out); + noteName(curr->cast<Loop>()->in); + PUSH(Loop, body); + break; + } + case Expression::Id::BreakId: { + hashName(curr->cast<Break>()->name); + PUSH(Break, condition); + PUSH(Break, value); + break; + } + case Expression::Id::SwitchId: { + HASH(Switch, targets.size()); + for (Index i = 0; i < curr->cast<Switch>()->targets.size(); i++) { + hashName(curr->cast<Switch>()->targets[i]); + } + hashName(curr->cast<Switch>()->default_); + PUSH(Switch, condition); + PUSH(Switch, value); + break; + } + case Expression::Id::CallId: { + HASH_NAME(Call, target); + HASH(Call, operands.size()); + for (Index i = 0; i < curr->cast<Call>()->operands.size(); i++) { + PUSH(Call, operands[i]); + } + break; + } + case Expression::Id::CallImportId: { + HASH_NAME(CallImport, target); + HASH(CallImport, operands.size()); + for (Index i = 0; i < curr->cast<CallImport>()->operands.size(); i++) { + PUSH(CallImport, operands[i]); + } + break; + } + case Expression::Id::CallIndirectId: { + PUSH(CallIndirect, target); + HASH_PTR(CallIndirect, fullType); + HASH(CallIndirect, operands.size()); + for (Index i = 0; i < curr->cast<CallIndirect>()->operands.size(); i++) { + PUSH(CallIndirect, operands[i]); + } + break; + } + case Expression::Id::GetLocalId: { + HASH(GetLocal, index); + break; + } + case Expression::Id::SetLocalId: { + HASH(SetLocal, index); + PUSH(SetLocal, value); + break; + } + case Expression::Id::LoadId: { + HASH(Load, bytes); + HASH(Load, signed_); + HASH(Load, offset); + HASH(Load, align); + PUSH(Load, ptr); + break; + } + case Expression::Id::StoreId: { + HASH(Store, bytes); + HASH(Store, offset); + HASH(Store, align); + PUSH(Store, ptr); + PUSH(Store, value); + break; + } + case Expression::Id::ConstId: { + HASH(Const, value.type); + HASH64(Const, value.getBits()); + break; + } + case Expression::Id::UnaryId: { + HASH(Unary, op); + PUSH(Unary, value); + break; + } + case Expression::Id::BinaryId: { + HASH(Binary, op); + PUSH(Binary, left); + PUSH(Binary, right); + break; + } + case Expression::Id::SelectId: { + PUSH(Select, ifTrue); + PUSH(Select, ifFalse); + PUSH(Select, condition); + break; + } + case Expression::Id::ReturnId: { + PUSH(Return, value); + break; + } + case Expression::Id::HostId: { + HASH(Host, op); + HASH_NAME(Host, nameOperand); + HASH(Host, operands.size()); + for (Index i = 0; i < curr->cast<Host>()->operands.size(); i++) { + PUSH(Host, operands[i]); + } + break; + } + case Expression::Id::NopId: { + break; + } + case Expression::Id::UnreachableId: { + break; + } + default: WASM_UNREACHABLE(); + } + #undef HASH + #undef PUSH + } + return digest; + } }; } // namespace wasm diff --git a/src/passes/CMakeLists.txt b/src/passes/CMakeLists.txt index 0ec2686da..ab55dff85 100644 --- a/src/passes/CMakeLists.txt +++ b/src/passes/CMakeLists.txt @@ -3,6 +3,7 @@ SET(passes_SOURCES CoalesceLocals.cpp DeadCodeElimination.cpp DropReturnValues.cpp + DuplicateFunctionElimination.cpp LowerIfElse.cpp MergeBlocks.cpp Metrics.cpp diff --git a/src/passes/DuplicateFunctionElimination.cpp b/src/passes/DuplicateFunctionElimination.cpp new file mode 100644 index 000000000..593ddb7d9 --- /dev/null +++ b/src/passes/DuplicateFunctionElimination.cpp @@ -0,0 +1,179 @@ +/* + * Copyright 2016 WebAssembly Community Group participants + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// Removes duplicate functions. That can happen due to C++ templates, +// and also due to types being different at the source level, but +// identical when finally lowered into concrete wasm code. +// + +#include <wasm.h> +#include <pass.h> +#include <ast_utils.h> + +namespace wasm { + +struct FunctionHasher : public PostWalker<FunctionHasher, Visitor<FunctionHasher>> { + bool isFunctionParallel() { return true; } + + FunctionHasher* create() override { + auto* ret = new FunctionHasher; + ret->setOutput(output); + return ret; + } + + void setOutput(std::map<Function*, uint32_t>* output_) { + output = output_; + } + + void walk(Expression*& root) { + assert(digest == 0); + auto* func = getFunction(); + hash(func->getNumParams()); + for (auto type : func->params) hash(type); + hash(func->getNumVars()); + for (auto type : func->vars) hash(type); + hash(func->result); + hash64(func->type.is() ? uint64_t(func->type.str) : uint64_t(0)); + hash(ExpressionAnalyzer::hash(root)); + output->at(func) = digest; + } + +private: + std::map<Function*, uint32_t>* output; + uint32_t digest = 0; + + void hash(uint32_t hash) { + digest = rehash(digest, hash); + } + void hash64(uint64_t hash) { + digest = rehash(rehash(digest, hash >> 32), uint32_t(hash)); + }; +}; + +struct FunctionReplacer : public PostWalker<FunctionReplacer, Visitor<FunctionReplacer>> { + bool isFunctionParallel() { return true; } + + FunctionReplacer* create() override { + auto* ret = new FunctionReplacer; + ret->setReplacements(replacements); + return ret; + } + + void setReplacements(std::map<Name, Name>* replacements_) { + replacements = replacements_; + } + + void visitCall(Call* curr) { + auto iter = replacements->find(curr->target); + if (iter != replacements->end()) { + curr->target = iter->second; + } + } + +private: + std::map<Name, Name>* replacements; +}; + +struct DuplicateFunctionElimination : public Pass { + void run(PassRunner* runner, Module* module) override { + while (1) { + // Hash all the functions + hashes.clear(); + for (auto& func : module->functions) { + hashes[func.get()] = 0; // ensure an entry for each function - we must not modify the map shape in parallel, just the values + } + FunctionHasher hasher; + hasher.setOutput(&hashes); + hasher.startWalk(module); + // Find hash-equal groups + std::map<uint32_t, std::vector<Function*>> hashGroups; + for (auto& func : module->functions) { + hashGroups[hashes[func.get()]].push_back(func.get()); + } + // Find actually equal functions and prepare to replace them + std::map<Name, Name> replacements; + std::set<Name> duplicates; + for (auto& pair : hashGroups) { + auto& group = pair.second; + if (group.size() == 1) continue; + // pick a base for each group, and try to replace everyone else to it. TODO: multiple bases per hash group, for collisions + Function* base = group[0]; + for (auto* func : group) { + if (func != base && equal(func, base)) { + replacements[func->name] = base->name; + duplicates.insert(func->name); + } + } + } + // perform replacements + if (replacements.size() > 0) { + // remove the duplicates + auto& v = module->functions; + v.erase(std::remove_if(v.begin(), v.end(), [&](const std::unique_ptr<Function>& curr) { + return duplicates.count(curr->name) > 0; + }), v.end()); + module->updateFunctionsMap(); + // replace direct calls + FunctionReplacer replacer; + replacer.setReplacements(&replacements); + replacer.startWalk(module); + // replace in table + for (auto& name : module->table.names) { + auto iter = replacements.find(name); + if (iter != replacements.end()) { + name = iter->second; + } + } + // replace in start + if (module->start.is()) { + auto iter = replacements.find(module->start); + if (iter != replacements.end()) { + module->start = iter->second; + } + } + // replace in exports + for (auto& exp : module->exports) { + auto iter = replacements.find(exp->value); + if (iter != replacements.end()) { + exp->value = iter->second; + } + } + } else { + break; + } + } + } + +private: + std::map<Function*, uint32_t> hashes; + + bool equal(Function* left, Function* right) { + if (left->getNumParams() != right->getNumParams()) return false; + if (left->getNumVars() != right->getNumVars()) return false; + for (Index i = 0; i < left->getNumLocals(); i++) { + if (left->getLocalType(i) != right->getLocalType(i)) return false; + } + if (left->result != right->result) return false; + if (left->type != right->type) return false; + return ExpressionAnalyzer::equal(left->body, right->body); + } +}; + +static RegisterPass<DuplicateFunctionElimination> registerPass("duplicate-function-elimination", "removes duplicate functions"); + +} // namespace wasm + diff --git a/src/passes/Metrics.cpp b/src/passes/Metrics.cpp index a6d51adbf..a01ead073 100644 --- a/src/passes/Metrics.cpp +++ b/src/passes/Metrics.cpp @@ -54,6 +54,10 @@ struct Metrics : public WalkerPass<PostWalker<Metrics, UnifiedExpressionVisitor< } keys.push_back("[vars]"); counts["[vars]"] = vars; + // add functions + keys.push_back("[funcs]"); + counts["[funcs]"] = module->functions.size(); + // sort sort(keys.begin(), keys.end(), [](const char* a, const char* b) -> bool { return strcmp(b, a) > 0; }); diff --git a/src/passes/ReorderLocals.cpp b/src/passes/ReorderLocals.cpp index 0e626e0a2..eea8ea962 100644 --- a/src/passes/ReorderLocals.cpp +++ b/src/passes/ReorderLocals.cpp @@ -17,7 +17,8 @@ // // Sorts locals by access frequency. // - +// Secondarily, sort by first appearance. This canonicalizes the order. +// #include <memory> @@ -29,7 +30,8 @@ namespace wasm { struct ReorderLocals : public WalkerPass<PostWalker<ReorderLocals, Visitor<ReorderLocals>>> { bool isFunctionParallel() { return true; } - std::map<Index, uint32_t> counts; + std::map<Index, Index> counts; // local => times it is used + std::map<Index, Index> firstUses; // local => index in the list of which local is first seen void visitFunction(Function *curr) { Index num = curr->getNumLocals(); @@ -44,10 +46,11 @@ struct ReorderLocals : public WalkerPass<PostWalker<ReorderLocals, Visitor<Reord if (curr->isParam(b) && curr->isParam(a)) { return a < b; } - if (this->counts[a] == this->counts[b]) { - return a < b; + if (counts[a] == counts[b]) { + if (counts[a] == 0) return a < b; + return firstUses[a] < firstUses[b]; } - return this->counts[a] > this->counts[b]; + return counts[a] > counts[b]; }); // sorting left params in front, perhaps slightly reordered. verify and fix. for (size_t i = 0; i < curr->params.size(); i++) { @@ -116,10 +119,16 @@ struct ReorderLocals : public WalkerPass<PostWalker<ReorderLocals, Visitor<Reord void visitGetLocal(GetLocal *curr) { counts[curr->index]++; + if (firstUses.count(curr->index) == 0) { + firstUses[curr->index] = firstUses.size(); + } } void visitSetLocal(SetLocal *curr) { counts[curr->index]++; + if (firstUses.count(curr->index) == 0) { + firstUses[curr->index] = firstUses.size(); + } } }; diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index b358243f7..ca9f477a3 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -58,6 +58,7 @@ std::string PassRegistry::getPassDescription(std::string name) { // PassRunner void PassRunner::addDefaultOptimizationPasses() { + add("duplicate-function-elimination"); add("dce"); add("remove-unused-brs"); add("remove-unused-names"); @@ -70,6 +71,7 @@ void PassRunner::addDefaultOptimizationPasses() { add("merge-blocks"); add("optimize-instructions"); add("vacuum"); // should not be needed, last few passes do not create garbage, but just to be safe + add("duplicate-function-elimination"); // optimizations show more functions as duplicate } void PassRunner::run() { diff --git a/src/support/hash.h b/src/support/hash.h new file mode 100644 index 000000000..e2d393d25 --- /dev/null +++ b/src/support/hash.h @@ -0,0 +1,39 @@ +/* + * Copyright 2015 WebAssembly Community Group participants + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef wasm_support_hash_h +#define wasm_support_hash_h + +#include <stdint.h> + +namespace wasm { + +inline uint32_t rehash(uint32_t x, uint32_t y) { // see http://www.cse.yorku.ca/~oz/hash.html + uint32_t hash = 5381; + while (x) { + hash = ((hash << 5) + hash) ^ (x & 0xff); + x >>= 8; + } + while (y) { + hash = ((hash << 5) + hash) ^ (y & 0xff); + y >>= 8; + } + return hash; +} + +} // namespace wasm + +#endif // wasm_support_hash_h diff --git a/src/wasm.h b/src/wasm.h index e8f82f47c..f59e4368f 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -250,6 +250,14 @@ private: } } + int64_t getBits() { + switch (type) { + case WasmType::i32: case WasmType::f32: return i32; + case WasmType::i64: case WasmType::f64: return i64; + default: abort(); + } + } + bool operator==(const Literal& other) const { if (type != other.type) return false; switch (type) { @@ -262,6 +270,10 @@ private: } } + bool operator!=(const Literal& other) const { + return !(*this == other); + } + static uint32_t NaNPayload(float f) { assert(std::isnan(f) && "expected a NaN"); // SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm index 7f2c87803..ad3f945f3 100644 --- a/test/emcc_O2_hello_world.fromasm +++ b/test/emcc_O2_hello_world.fromasm @@ -1561,7 +1561,7 @@ (set_local $25 (get_local $19) ) - (set_local $30 + (set_local $29 (get_local $19) ) (set_local $8 @@ -1632,7 +1632,7 @@ (set_local $34 (get_local $18) ) - (set_local $29 + (set_local $30 (get_local $6) ) (set_local $8 @@ -1671,7 +1671,7 @@ (set_local $34 (i32.const 0) ) - (set_local $29 + (set_local $30 (i32.const 0) ) (set_local $8 @@ -1694,7 +1694,7 @@ (i32.const 0) ) (i32.eq - (get_local $29) + (get_local $30) (i32.const 0) ) ) @@ -1833,8 +1833,8 @@ (set_local $25 (get_local $0) ) - (set_local $30 - (get_local $29) + (set_local $29 + (get_local $30) ) (set_local $8 (i32.const 90) @@ -1845,7 +1845,7 @@ (get_local $33) ) (set_local $12 - (get_local $29) + (get_local $30) ) ) ) @@ -1885,7 +1885,7 @@ (set_local $6 (select (get_local $25) - (get_local $30) + (get_local $29) (get_local $1) ) ) @@ -1902,7 +1902,7 @@ (set_local $25 (get_local $1) ) - (set_local $30 + (set_local $29 (get_local $6) ) (br $while-in$20) @@ -1918,7 +1918,7 @@ (set_local $27 (get_local $4) ) - (set_local $30 + (set_local $29 (get_local $6) ) ) diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise index 7f2c87803..ad3f945f3 100644 --- a/test/emcc_O2_hello_world.fromasm.imprecise +++ b/test/emcc_O2_hello_world.fromasm.imprecise @@ -1561,7 +1561,7 @@ (set_local $25 (get_local $19) ) - (set_local $30 + (set_local $29 (get_local $19) ) (set_local $8 @@ -1632,7 +1632,7 @@ (set_local $34 (get_local $18) ) - (set_local $29 + (set_local $30 (get_local $6) ) (set_local $8 @@ -1671,7 +1671,7 @@ (set_local $34 (i32.const 0) ) - (set_local $29 + (set_local $30 (i32.const 0) ) (set_local $8 @@ -1694,7 +1694,7 @@ (i32.const 0) ) (i32.eq - (get_local $29) + (get_local $30) (i32.const 0) ) ) @@ -1833,8 +1833,8 @@ (set_local $25 (get_local $0) ) - (set_local $30 - (get_local $29) + (set_local $29 + (get_local $30) ) (set_local $8 (i32.const 90) @@ -1845,7 +1845,7 @@ (get_local $33) ) (set_local $12 - (get_local $29) + (get_local $30) ) ) ) @@ -1885,7 +1885,7 @@ (set_local $6 (select (get_local $25) - (get_local $30) + (get_local $29) (get_local $1) ) ) @@ -1902,7 +1902,7 @@ (set_local $25 (get_local $1) ) - (set_local $30 + (set_local $29 (get_local $6) ) (br $while-in$20) @@ -1918,7 +1918,7 @@ (set_local $27 (get_local $4) ) - (set_local $30 + (set_local $29 (get_local $6) ) ) diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index d5e961a92..c7b334e7d 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -1047,7 +1047,7 @@ (local $15 i32) (local $16 i32) (local $17 i32) - (set_local $10 + (set_local $8 (i32.load (i32.const 8) ) @@ -1074,17 +1074,17 @@ ) (set_local $9 (i32.add - (get_local $10) + (get_local $8) (i32.const 16) ) ) - (set_local $8 - (get_local $10) + (set_local $10 + (get_local $8) ) (i32.store (set_local $3 (i32.add - (get_local $10) + (get_local $8) (i32.const 32) ) ) @@ -1123,13 +1123,13 @@ (get_local $3) (get_local $2) ) - (set_local $13 + (set_local $12 (i32.add (get_local $0) (i32.const 60) ) ) - (set_local $12 + (set_local $13 (i32.add (get_local $0) (i32.const 44) @@ -1163,7 +1163,7 @@ (i32.store (get_local $9) (i32.load - (get_local $13) + (get_local $12) ) ) (i32.store offset=4 @@ -1187,24 +1187,24 @@ (get_local $0) ) (i32.store - (get_local $8) + (get_local $10) (i32.load - (get_local $13) + (get_local $12) ) ) (i32.store offset=4 - (get_local $8) + (get_local $10) (get_local $5) ) (i32.store offset=8 - (get_local $8) + (get_local $10) (get_local $6) ) (set_local $1 (call $___syscall_ret (call_import $___syscall146 (i32.const 146) - (get_local $8) + (get_local $10) ) ) ) @@ -1262,7 +1262,7 @@ (get_local $7) (set_local $4 (i32.load - (get_local $12) + (get_local $13) ) ) ) @@ -1365,7 +1365,7 @@ (i32.add (set_local $1 (i32.load - (get_local $12) + (get_local $13) ) ) (i32.load offset=48 @@ -1434,7 +1434,7 @@ ) (i32.store (i32.const 8) - (get_local $10) + (get_local $8) ) (get_local $14) ) @@ -1451,7 +1451,7 @@ (local $12 i32) (local $13 i32) (local $14 i32) - (set_local $4 + (set_local $3 (i32.load (i32.const 8) ) @@ -1478,25 +1478,25 @@ ) (set_local $5 (i32.add - (get_local $4) + (get_local $3) (i32.const 120) ) ) (set_local $8 - (get_local $4) + (get_local $3) ) - (set_local $7 + (set_local $6 (i32.add - (get_local $4) + (get_local $3) (i32.const 136) ) ) - (set_local $6 + (set_local $7 (i32.add - (set_local $3 + (set_local $4 (set_local $9 (i32.add - (get_local $4) + (get_local $3) (i32.const 80) ) ) @@ -1506,18 +1506,18 @@ ) (loop $do-out$0 $do-in$1 (i32.store - (get_local $3) + (get_local $4) (i32.const 0) ) (br_if $do-in$1 (i32.lt_s - (set_local $3 + (set_local $4 (i32.add - (get_local $3) + (get_local $4) (i32.const 4) ) ) - (get_local $6) + (get_local $7) ) ) ) @@ -1555,7 +1555,7 @@ (i32.const 0) ) ) - (set_local $3 + (set_local $4 (i32.and (set_local $2 (i32.load @@ -1603,7 +1603,7 @@ (block (set_local $2 (i32.load - (set_local $6 + (set_local $7 (i32.add (get_local $0) (i32.const 44) @@ -1612,8 +1612,8 @@ ) ) (i32.store - (get_local $6) (get_local $7) + (get_local $6) ) (i32.store (set_local $13 @@ -1622,7 +1622,7 @@ (i32.const 28) ) ) - (get_local $7) + (get_local $6) ) (i32.store (set_local $11 @@ -1631,7 +1631,7 @@ (i32.const 20) ) ) - (get_local $7) + (get_local $6) ) (i32.store (get_local $10) @@ -1645,7 +1645,7 @@ ) ) (i32.add - (get_local $7) + (get_local $6) (i32.const 80) ) ) @@ -1692,7 +1692,7 @@ ) ) (i32.store - (get_local $6) + (get_local $7) (get_local $2) ) (i32.store @@ -1741,7 +1741,7 @@ (get_local $0) (i32.or (get_local $1) - (get_local $3) + (get_local $4) ) ) (if @@ -1759,7 +1759,7 @@ ) (i32.store (i32.const 8) - (get_local $4) + (get_local $3) ) (get_local $0) ) @@ -2403,7 +2403,7 @@ (set_local $6 (get_local $3) ) - (set_local $8 + (set_local $7 (get_local $2) ) (set_local $3 @@ -2445,7 +2445,7 @@ (set_local $11 (get_local $0) ) - (set_local $14 + (set_local $13 (get_local $2) ) (set_local $16 @@ -2464,7 +2464,7 @@ (set_local $11 (get_local $2) ) - (set_local $14 + (set_local $13 (get_local $0) ) (set_local $16 @@ -2487,19 +2487,19 @@ (set_local $6 (get_local $11) ) - (set_local $8 - (get_local $14) + (set_local $7 + (get_local $13) ) (set_local $3 (i32.const 6) ) ) (block - (set_local $7 + (set_local $8 (i32.const 0) ) - (set_local $10 - (get_local $14) + (set_local $9 + (get_local $13) ) ) ) @@ -2515,7 +2515,7 @@ (i32.shr_s (i32.shl (i32.load8_s - (get_local $8) + (get_local $7) ) (i32.const 24) ) @@ -2535,11 +2535,11 @@ ) ) (block - (set_local $7 + (set_local $8 (get_local $6) ) - (set_local $10 - (get_local $8) + (set_local $9 + (get_local $7) ) ) (block @@ -2560,7 +2560,7 @@ (get_local $6) ) (set_local $5 - (get_local $8) + (get_local $7) ) (loop $while-out$5 $while-in$6 (set_local $1 @@ -2620,7 +2620,7 @@ (get_local $1) ) (block - (set_local $13 + (set_local $14 (get_local $4) ) (set_local $15 @@ -2637,16 +2637,16 @@ (set_local $12 (get_local $1) ) - (set_local $9 + (set_local $10 (get_local $2) ) ) (block - (set_local $13 + (set_local $14 (get_local $6) ) (set_local $15 - (get_local $8) + (get_local $7) ) (set_local $3 (i32.const 11) @@ -2661,23 +2661,23 @@ ) (if (i32.eq - (get_local $13) + (get_local $14) (i32.const 0) ) (block - (set_local $7 + (set_local $8 (i32.const 0) ) - (set_local $10 + (set_local $9 (get_local $15) ) (br $label$break$L8) ) (block (set_local $12 - (get_local $13) + (get_local $14) ) - (set_local $9 + (set_local $10 (get_local $15) ) ) @@ -2689,7 +2689,7 @@ (i32.shr_s (i32.shl (i32.load8_s - (get_local $9) + (get_local $10) ) (i32.const 24) ) @@ -2704,18 +2704,18 @@ ) ) (block - (set_local $7 + (set_local $8 (get_local $12) ) - (set_local $10 - (get_local $9) + (set_local $9 + (get_local $10) ) (br $label$break$L8) ) ) (set_local $2 (i32.add - (get_local $9) + (get_local $10) (i32.const 1) ) ) @@ -2730,10 +2730,10 @@ (i32.const 0) ) (block - (set_local $7 + (set_local $8 (i32.const 0) ) - (set_local $10 + (set_local $9 (get_local $2) ) (br $while-out$7) @@ -2742,7 +2742,7 @@ (set_local $12 (get_local $1) ) - (set_local $9 + (set_local $10 (get_local $2) ) ) @@ -2754,10 +2754,10 @@ ) ) (select - (get_local $10) + (get_local $9) (i32.const 0) (i32.ne - (get_local $7) + (get_local $8) (i32.const 0) ) ) @@ -2805,7 +2805,7 @@ ) ) (i32.load - (set_local $6 + (set_local $4 (i32.add (get_local $0) (i32.const 28) @@ -2867,7 +2867,7 @@ ) (set_local $2 (i32.load - (set_local $4 + (set_local $6 (i32.add (get_local $0) (i32.const 8) @@ -2899,7 +2899,7 @@ (i32.const 0) ) (i32.store - (get_local $6) + (get_local $4) (i32.const 0) ) (i32.store @@ -2907,7 +2907,7 @@ (i32.const 0) ) (i32.store - (get_local $4) + (get_local $6) (i32.const 0) ) (i32.store @@ -3017,7 +3017,7 @@ (local $81 i32) (local $82 i32) (local $83 i32) - (set_local $32 + (set_local $31 (i32.load (i32.const 8) ) @@ -3044,31 +3044,31 @@ ) (set_local $25 (i32.add - (get_local $32) + (get_local $31) (i32.const 16) ) ) (set_local $18 - (get_local $32) + (get_local $31) ) - (set_local $64 + (set_local $63 (i32.add - (get_local $32) + (get_local $31) (i32.const 528) ) ) - (set_local $52 + (set_local $45 (i32.ne (get_local $0) (i32.const 0) ) ) - (set_local $73 + (set_local $71 (set_local $27 (i32.add (set_local $5 (i32.add - (get_local $32) + (get_local $31) (i32.const 536) ) ) @@ -3076,87 +3076,87 @@ ) ) ) - (set_local $71 + (set_local $72 (i32.add (get_local $5) (i32.const 39) ) ) - (set_local $77 + (set_local $76 (i32.add - (set_local $75 + (set_local $73 (i32.add - (get_local $32) + (get_local $31) (i32.const 8) ) ) (i32.const 4) ) ) - (set_local $55 + (set_local $54 (i32.add (set_local $5 (i32.add - (get_local $32) + (get_local $31) (i32.const 576) ) ) (i32.const 12) ) ) - (set_local $72 + (set_local $74 (i32.add (get_local $5) (i32.const 11) ) ) - (set_local $83 + (set_local $77 (i32.sub - (set_local $44 - (get_local $55) + (set_local $41 + (get_local $54) ) - (set_local $67 + (set_local $64 (set_local $28 (i32.add - (get_local $32) + (get_local $31) (i32.const 588) ) ) ) ) ) - (set_local $81 + (set_local $78 (i32.sub (i32.const -2) - (get_local $67) + (get_local $64) ) ) - (set_local $82 + (set_local $79 (i32.add - (get_local $44) + (get_local $41) (i32.const 2) ) ) - (set_local $76 + (set_local $81 (i32.add - (set_local $78 + (set_local $80 (i32.add - (get_local $32) + (get_local $31) (i32.const 24) ) ) (i32.const 288) ) ) - (set_local $74 - (set_local $48 + (set_local $75 + (set_local $46 (i32.add (get_local $28) (i32.const 9) ) ) ) - (set_local $57 + (set_local $55 (i32.add (get_local $28) (i32.const 8) @@ -3220,10 +3220,10 @@ (i32.const 0) ) (block - (set_local $79 + (set_local $82 (get_local $8) ) - (set_local $80 + (set_local $83 (get_local $11) ) (set_local $12 @@ -3256,7 +3256,7 @@ (set_local $56 (get_local $5) ) - (set_local $70 + (set_local $65 (get_local $5) ) (set_local $12 @@ -3264,10 +3264,10 @@ ) (br $label$break$L9) ) - (set_local $41 + (set_local $42 (get_local $5) ) - (set_local $62 + (set_local $57 (get_local $5) ) (br $label$break$L9) @@ -3309,18 +3309,18 @@ (i32.const 37) ) (block - (set_local $41 + (set_local $42 (get_local $56) ) - (set_local $62 - (get_local $70) + (set_local $57 + (get_local $65) ) (br $label$break$L12) ) ) (set_local $5 (i32.add - (get_local $70) + (get_local $65) (i32.const 1) ) ) @@ -3346,15 +3346,15 @@ (set_local $56 (get_local $1) ) - (set_local $70 + (set_local $65 (get_local $5) ) ) (block - (set_local $41 + (set_local $42 (get_local $1) ) - (set_local $62 + (set_local $57 (get_local $5) ) (br $while-out$7) @@ -3366,12 +3366,12 @@ ) (set_local $16 (i32.sub - (get_local $62) + (get_local $57) (get_local $20) ) ) (if - (get_local $52) + (get_local $45) (if (i32.eq (i32.and @@ -3391,7 +3391,7 @@ ) (if (i32.ne - (get_local $62) + (get_local $57) (get_local $20) ) (block @@ -3399,7 +3399,7 @@ (get_local $8) ) (set_local $20 - (get_local $41) + (get_local $42) ) (set_local $1 (get_local $16) @@ -3418,7 +3418,7 @@ (i32.load8_s (set_local $5 (i32.add - (get_local $41) + (get_local $42) (i32.const 1) ) ) @@ -3439,7 +3439,7 @@ (set_local $5 (select (i32.add - (get_local $41) + (get_local $42) (i32.const 3) ) (get_local $5) @@ -3448,7 +3448,7 @@ (i32.shr_s (i32.shl (i32.load8_s offset=2 - (get_local $41) + (get_local $42) ) (i32.const 24) ) @@ -3676,16 +3676,16 @@ (i32.load offset=4 (get_local $1) ) - (set_local $63 + (set_local $66 (i32.const 1) ) - (set_local $66 + (set_local $67 (i32.add (get_local $9) (i32.const 3) ) ) - (set_local $61 + (set_local $58 (get_local $5) ) ) @@ -3720,7 +3720,7 @@ ) (if (i32.eqz - (get_local $52) + (get_local $45) ) (block (set_local $9 @@ -3772,13 +3772,13 @@ (i32.const 4) ) ) - (set_local $63 + (set_local $66 (i32.const 0) ) - (set_local $66 + (set_local $67 (get_local $7) ) - (set_local $61 + (set_local $58 (get_local $5) ) ) @@ -3786,20 +3786,20 @@ (set_local $11 (if (i32.lt_s - (get_local $61) + (get_local $58) (i32.const 0) ) (block (set_local $9 - (get_local $66) + (get_local $67) ) (set_local $22 - (get_local $63) + (get_local $66) ) (set_local $15 (i32.sub (i32.const 0) - (get_local $61) + (get_local $58) ) ) (i32.or @@ -3809,13 +3809,13 @@ ) (block (set_local $9 - (get_local $66) + (get_local $67) ) (set_local $22 - (get_local $63) + (get_local $66) ) (set_local $15 - (get_local $61) + (get_local $58) ) (get_local $11) ) @@ -4148,7 +4148,7 @@ ) ) (if - (get_local $52) + (get_local $45) (block (set_local $5 (i32.load @@ -4385,7 +4385,7 @@ ) (if (i32.eqz - (get_local $52) + (get_local $45) ) (block (set_local $23 @@ -4413,7 +4413,7 @@ ) (if (i32.eqz - (get_local $52) + (get_local $45) ) (block (set_local $19 @@ -4724,13 +4724,13 @@ (br $label$continue$L1) ) ) - (set_local $49 + (set_local $47 (i32.or (get_local $17) (i32.const 8) ) ) - (set_local $58 + (set_local $59 (select (get_local $10) (i32.const 8) @@ -4740,7 +4740,7 @@ ) ) ) - (set_local $69 + (set_local $68 (i32.const 120) ) (set_local $12 @@ -4749,13 +4749,13 @@ (br $switch$24) ) ) - (set_local $49 + (set_local $47 (get_local $17) ) - (set_local $58 + (set_local $59 (get_local $10) ) - (set_local $69 + (set_local $68 (get_local $33) ) (set_local $12 @@ -4866,13 +4866,13 @@ (set_local $35 (get_local $17) ) - (set_local $31 + (set_local $32 (get_local $10) ) - (set_local $38 + (set_local $36 (i32.const 0) ) - (set_local $40 + (set_local $37 (i32.const 4091) ) (set_local $12 @@ -4887,7 +4887,7 @@ (set_local $1 (i32.add (i32.sub - (get_local $73) + (get_local $71) (get_local $6) ) (i32.const 1) @@ -4898,17 +4898,17 @@ (set_local $35 (get_local $17) ) - (set_local $31 + (set_local $32 (select (get_local $1) (get_local $10) (get_local $5) ) ) - (set_local $38 + (set_local $36 (i32.const 0) ) - (set_local $40 + (set_local $37 (i32.const 4091) ) (set_local $12 @@ -4961,16 +4961,16 @@ (get_local $6) (get_local $5) ) - (set_local $45 + (set_local $48 (get_local $1) ) - (set_local $54 + (set_local $60 (get_local $5) ) - (set_local $59 + (set_local $61 (i32.const 1) ) - (set_local $60 + (set_local $62 (i32.const 4091) ) (set_local $12 @@ -4979,7 +4979,7 @@ (br $label$break$L75) ) ) - (set_local $45 + (set_local $48 (if (i32.eq (i32.and @@ -4994,7 +4994,7 @@ (i32.const 4091) (i32.const 4093) (i32.eq - (set_local $45 + (set_local $48 (i32.and (get_local $17) (i32.const 1) @@ -5004,13 +5004,13 @@ ) ) ) - (set_local $54 + (set_local $60 (get_local $6) ) - (set_local $59 - (get_local $45) + (set_local $61 + (get_local $48) ) - (set_local $60 + (set_local $62 (get_local $1) ) (set_local $12 @@ -5019,13 +5019,13 @@ (get_local $5) ) (block - (set_local $54 + (set_local $60 (get_local $6) ) - (set_local $59 + (set_local $61 (i32.const 1) ) - (set_local $60 + (set_local $62 (i32.const 4092) ) (set_local $12 @@ -5037,22 +5037,22 @@ ) (br $switch$24) ) - (set_local $45 + (set_local $48 (i32.load (set_local $1 (get_local $18) ) ) ) - (set_local $54 + (set_local $60 (i32.load offset=4 (get_local $1) ) ) - (set_local $59 + (set_local $61 (i32.const 0) ) - (set_local $60 + (set_local $62 (i32.const 4091) ) (set_local $12 @@ -5071,33 +5071,33 @@ (get_local $1) ) (i32.store8 - (get_local $71) + (get_local $72) (i32.and (get_local $5) (i32.const 255) ) ) - (set_local $47 - (get_local $71) + (set_local $49 + (get_local $72) ) - (set_local $36 + (set_local $38 (get_local $7) ) - (set_local $42 + (set_local $43 (i32.const 1) ) - (set_local $43 + (set_local $44 (i32.const 0) ) - (set_local $51 + (set_local $50 (i32.const 4091) ) - (set_local $53 + (set_local $51 (get_local $27) ) (br $switch$24) ) - (set_local $46 + (set_local $52 (call $_strerror (i32.load (call $___errno_location) @@ -5119,7 +5119,7 @@ (i32.const 0) ) ) - (set_local $46 + (set_local $52 (select (get_local $1) (i32.const 4101) @@ -5142,18 +5142,18 @@ (get_local $1) ) (i32.store - (get_local $75) + (get_local $73) (get_local $5) ) (i32.store - (get_local $77) + (get_local $76) (i32.const 0) ) (i32.store (get_local $18) - (get_local $75) + (get_local $73) ) - (set_local $65 + (set_local $69 (i32.const -1) ) (set_local $12 @@ -5175,13 +5175,13 @@ (i32.const 0) (get_local $17) ) - (set_local $37 + (set_local $39 (i32.const 0) ) (i32.const 98) ) (block - (set_local $65 + (set_local $69 (get_local $10) ) (i32.const 86) @@ -5217,7 +5217,7 @@ (i32.const 24) ) ) - (set_local $50 + (set_local $53 (if (i32.lt_s (i32.load offset=4 @@ -5228,7 +5228,7 @@ (i32.const 0) ) (block - (set_local $39 + (set_local $40 (i32.const 4108) ) (set_local $14 @@ -5247,7 +5247,7 @@ (i32.const 0) ) (block - (set_local $39 + (set_local $40 (select (i32.const 4109) (i32.const 4114) @@ -5265,7 +5265,7 @@ (get_local $1) ) (block - (set_local $39 + (set_local $40 (i32.const 4111) ) (i32.const 1) @@ -5357,9 +5357,9 @@ (block (set_local $11 (select - (get_local $39) + (get_local $40) (i32.add - (get_local $39) + (get_local $40) (i32.const 9) ) (i32.eq @@ -5375,7 +5375,7 @@ ) (set_local $6 (i32.or - (get_local $50) + (get_local $53) (i32.const 2) ) ) @@ -5497,17 +5497,17 @@ (call $_fmt_u (get_local $8) (get_local $5) - (get_local $55) + (get_local $54) ) ) - (get_local $55) + (get_local $54) ) (block (i32.store8 - (get_local $72) + (get_local $74) (i32.const 48) ) - (get_local $72) + (get_local $74) ) (get_local $5) ) @@ -5606,7 +5606,7 @@ (i32.const 1) ) ) - (get_local $67) + (get_local $64) ) (i32.const 1) ) @@ -5659,7 +5659,7 @@ ) (i32.lt_s (i32.add - (get_local $81) + (get_local $78) (get_local $1) ) (get_local $10) @@ -5676,14 +5676,14 @@ (select (i32.sub (i32.add - (get_local $82) + (get_local $79) (get_local $10) ) (get_local $8) ) (i32.add (i32.sub - (get_local $83) + (get_local $77) (get_local $8) ) (get_local $1) @@ -5725,7 +5725,7 @@ (set_local $1 (i32.sub (get_local $1) - (get_local $67) + (get_local $64) ) ) (if @@ -5753,7 +5753,7 @@ (get_local $1) (set_local $1 (i32.sub - (get_local $44) + (get_local $41) (get_local $8) ) ) @@ -5813,8 +5813,8 @@ (set_local $30 (set_local $11 (select - (get_local $78) - (get_local $76) + (get_local $80) + (get_local $81) (i32.lt_s (if (get_local $5) @@ -6142,7 +6142,7 @@ (get_local $24) ) (block - (set_local $68 + (set_local $70 (i32.add (i32.shl (i32.const 1) @@ -6171,7 +6171,7 @@ (get_local $16) ) ) - (get_local $68) + (get_local $70) ) ) (i32.store @@ -6435,7 +6435,7 @@ (i32.shr_s (i32.shl (i32.and - (set_local $68 + (set_local $70 (i32.ne (get_local $1) (i32.const 0) @@ -6638,7 +6638,7 @@ (block $do-once$90 (if (i32.eq - (get_local $50) + (get_local $53) (i32.const 0) ) (get_local $14) @@ -6648,7 +6648,7 @@ (i32.shr_s (i32.shl (i32.load8_s - (get_local $39) + (get_local $40) ) (i32.const 24) ) @@ -6943,7 +6943,7 @@ (i32.add (i32.xor (i32.and - (get_local $68) + (get_local $70) (i32.const 1) ) (i32.const 1) @@ -7274,12 +7274,12 @@ (if (i32.lt_s (i32.sub - (get_local $44) + (get_local $41) (set_local $5 (call $_fmt_u (get_local $7) (get_local $5) - (get_local $55) + (get_local $54) ) ) ) @@ -7298,7 +7298,7 @@ (if (i32.lt_s (i32.sub - (get_local $44) + (get_local $41) (get_local $5) ) (i32.const 2) @@ -7343,7 +7343,7 @@ ) (set_local $7 (i32.sub - (get_local $44) + (get_local $41) (get_local $5) ) ) @@ -7360,7 +7360,7 @@ (i32.add (i32.add (i32.add - (get_local $50) + (get_local $53) (i32.const 1) ) (get_local $21) @@ -7383,8 +7383,8 @@ (i32.const 0) ) (call $___fwritex - (get_local $39) - (get_local $50) + (get_local $40) + (get_local $53) (get_local $0) ) ) @@ -7421,7 +7421,7 @@ (get_local $6) ) (i32.const 0) - (get_local $48) + (get_local $46) ) ) (block $do-once$110 @@ -7434,16 +7434,16 @@ (if (i32.ne (get_local $5) - (get_local $48) + (get_local $46) ) (br $do-once$110) ) (i32.store8 - (get_local $57) + (get_local $55) (i32.const 48) ) (set_local $5 - (get_local $57) + (get_local $55) ) ) (block @@ -7491,7 +7491,7 @@ (call $___fwritex (get_local $5) (i32.sub - (get_local $74) + (get_local $75) (get_local $5) ) (get_local $0) @@ -7564,7 +7564,7 @@ (get_local $5) ) (i32.const 0) - (get_local $48) + (get_local $46) ) ) (get_local $28) @@ -7708,17 +7708,17 @@ (get_local $5) ) (i32.const 0) - (get_local $48) + (get_local $46) ) ) - (get_local $48) + (get_local $46) ) (block (i32.store8 - (get_local $57) + (get_local $55) (i32.const 48) ) - (get_local $57) + (get_local $55) ) (get_local $1) ) @@ -7821,7 +7821,7 @@ ) (set_local $11 (i32.sub - (get_local $74) + (get_local $75) (get_local $1) ) ) @@ -7910,7 +7910,7 @@ (call $___fwritex (get_local $10) (i32.sub - (get_local $44) + (get_local $41) (get_local $10) ) (get_local $0) @@ -7956,7 +7956,7 @@ (set_local $6 (select (i32.const 0) - (get_local $50) + (get_local $53) (set_local $1 (i32.or (f64.ne @@ -8011,7 +8011,7 @@ ) (block (call $___fwritex - (get_local $39) + (get_local $40) (get_local $6) (get_local $0) ) @@ -8058,22 +8058,22 @@ ) (br $label$continue$L1) ) - (set_local $47 + (set_local $49 (get_local $20) ) - (set_local $36 + (set_local $38 (get_local $17) ) - (set_local $42 + (set_local $43 (get_local $10) ) - (set_local $43 + (set_local $44 (i32.const 0) ) - (set_local $51 + (set_local $50 (i32.const 4091) ) - (set_local $53 + (set_local $51 (get_local $27) ) ) @@ -8088,7 +8088,7 @@ (block (set_local $6 (i32.and - (get_local $69) + (get_local $68) (i32.const 32) ) ) @@ -8116,15 +8116,15 @@ ) (block (set_local $35 - (get_local $49) + (get_local $47) ) - (set_local $31 - (get_local $58) + (set_local $32 + (get_local $59) ) - (set_local $38 + (set_local $36 (i32.const 0) ) - (set_local $40 + (set_local $37 (i32.const 4091) ) (set_local $12 @@ -8197,7 +8197,7 @@ (i32.or (i32.eq (i32.and - (get_local $49) + (get_local $47) (i32.const 8) ) (i32.const 0) @@ -8221,15 +8221,15 @@ ) (block (set_local $35 - (get_local $49) + (get_local $47) ) - (set_local $31 - (get_local $58) + (set_local $32 + (get_local $59) ) - (set_local $38 + (set_local $36 (i32.const 0) ) - (set_local $40 + (set_local $37 (i32.const 4091) ) (set_local $12 @@ -8239,19 +8239,19 @@ ) (block (set_local $35 - (get_local $49) + (get_local $47) ) - (set_local $31 - (get_local $58) + (set_local $32 + (get_local $59) ) - (set_local $38 + (set_local $36 (i32.const 2) ) - (set_local $40 + (set_local $37 (i32.add (i32.const 4091) (i32.shr_s - (get_local $69) + (get_local $68) (i32.const 4) ) ) @@ -8274,22 +8274,22 @@ (block (set_local $34 (call $_fmt_u - (get_local $45) - (get_local $54) + (get_local $48) + (get_local $60) (get_local $27) ) ) (set_local $35 (get_local $17) ) - (set_local $31 + (set_local $32 (get_local $10) ) - (set_local $38 - (get_local $59) + (set_local $36 + (get_local $61) ) - (set_local $40 - (get_local $60) + (set_local $37 + (get_local $62) ) (set_local $12 (i32.const 77) @@ -8308,7 +8308,7 @@ (i32.eq (set_local $1 (call $_memchr - (get_local $46) + (get_local $52) (i32.const 0) (get_local $10) ) @@ -8316,32 +8316,32 @@ (i32.const 0) ) ) - (set_local $47 - (get_local $46) + (set_local $49 + (get_local $52) ) - (set_local $36 + (set_local $38 (get_local $7) ) - (set_local $42 + (set_local $43 (select (get_local $10) (i32.sub (get_local $1) - (get_local $46) + (get_local $52) ) (get_local $5) ) ) - (set_local $43 + (set_local $44 (i32.const 0) ) - (set_local $51 + (set_local $50 (i32.const 4091) ) - (set_local $53 + (set_local $51 (select (i32.add - (get_local $46) + (get_local $52) (get_local $10) ) (get_local $1) @@ -8391,7 +8391,7 @@ (i32.lt_s (set_local $5 (call $_wctomb - (get_local $64) + (get_local $63) (get_local $1) ) ) @@ -8400,7 +8400,7 @@ (i32.gt_u (get_local $5) (i32.sub - (get_local $65) + (get_local $69) (get_local $6) ) ) @@ -8420,7 +8420,7 @@ ) (if (i32.gt_u - (get_local $65) + (get_local $69) (set_local $1 (i32.add (get_local $5) @@ -8468,7 +8468,7 @@ (i32.const 0) ) (block - (set_local $37 + (set_local $39 (i32.const 0) ) (set_local $12 @@ -8495,7 +8495,7 @@ (i32.const 0) ) (block - (set_local $37 + (set_local $39 (get_local $6) ) (set_local $12 @@ -8516,7 +8516,7 @@ (i32.add (set_local $5 (call $_wctomb - (get_local $64) + (get_local $63) (get_local $1) ) ) @@ -8526,7 +8526,7 @@ (get_local $6) ) (block - (set_local $37 + (set_local $39 (get_local $6) ) (set_local $12 @@ -8546,7 +8546,7 @@ (i32.const 0) ) (call $___fwritex - (get_local $64) + (get_local $63) (get_local $5) (get_local $0) ) @@ -8565,7 +8565,7 @@ ) ) (block - (set_local $37 + (set_local $39 (get_local $6) ) (set_local $12 @@ -8597,7 +8597,7 @@ (get_local $0) (i32.const 32) (get_local $15) - (get_local $37) + (get_local $39) (i32.xor (get_local $17) (i32.const 8192) @@ -8612,10 +8612,10 @@ (set_local $1 (select (get_local $15) - (get_local $37) + (get_local $39) (i32.gt_s (get_local $15) - (get_local $37) + (get_local $39) ) ) ) @@ -8642,16 +8642,16 @@ ) (get_local $35) (i32.gt_s - (get_local $31) + (get_local $32) (i32.const -1) ) ) ) - (set_local $47 + (set_local $49 (if (i32.or (i32.ne - (get_local $31) + (get_local $32) (i32.const 0) ) (set_local $1 @@ -8676,7 +8676,7 @@ (block (set_local $6 (i32.gt_s - (get_local $31) + (get_local $32) (set_local $1 (i32.add (i32.xor @@ -8687,48 +8687,48 @@ (i32.const 1) ) (i32.sub - (get_local $73) + (get_local $71) (get_local $34) ) ) ) ) ) - (set_local $36 + (set_local $38 (get_local $5) ) - (set_local $42 + (set_local $43 (select - (get_local $31) + (get_local $32) (get_local $1) (get_local $6) ) ) - (set_local $43 - (get_local $38) + (set_local $44 + (get_local $36) ) - (set_local $51 - (get_local $40) + (set_local $50 + (get_local $37) ) - (set_local $53 + (set_local $51 (get_local $27) ) (get_local $34) ) (block - (set_local $36 + (set_local $38 (get_local $5) ) - (set_local $42 + (set_local $43 (i32.const 0) ) - (set_local $43 - (get_local $38) + (set_local $44 + (get_local $36) ) - (set_local $51 - (get_local $40) + (set_local $50 + (get_local $37) ) - (set_local $53 + (set_local $51 (get_local $27) ) (get_local $27) @@ -8739,11 +8739,11 @@ ) (set_local $1 (i32.lt_s - (get_local $42) + (get_local $43) (set_local $6 (i32.sub - (get_local $53) - (get_local $47) + (get_local $51) + (get_local $49) ) ) ) @@ -8753,11 +8753,11 @@ (get_local $15) (set_local $1 (i32.add - (get_local $43) + (get_local $44) (set_local $7 (select (get_local $6) - (get_local $42) + (get_local $43) (get_local $1) ) ) @@ -8776,7 +8776,7 @@ ) ) (get_local $1) - (get_local $36) + (get_local $38) ) (if (i32.eq @@ -8789,8 +8789,8 @@ (i32.const 0) ) (call $___fwritex - (get_local $51) - (get_local $43) + (get_local $50) + (get_local $44) (get_local $0) ) ) @@ -8800,7 +8800,7 @@ (get_local $5) (get_local $1) (i32.xor - (get_local $36) + (get_local $38) (i32.const 65536) ) ) @@ -8822,7 +8822,7 @@ (i32.const 0) ) (call $___fwritex - (get_local $47) + (get_local $49) (get_local $6) (get_local $0) ) @@ -8833,7 +8833,7 @@ (get_local $5) (get_local $1) (i32.xor - (get_local $36) + (get_local $38) (i32.const 8192) ) ) @@ -8864,7 +8864,7 @@ ) (if (i32.eq - (get_local $80) + (get_local $83) (i32.const 0) ) (set_local $23 @@ -8986,14 +8986,14 @@ ) ) (set_local $23 - (get_local $79) + (get_local $82) ) ) ) ) (i32.store (i32.const 8) - (get_local $32) + (get_local $31) ) (get_local $23) ) @@ -11458,13 +11458,13 @@ (i32.const 0) ) (block - (set_local $34 + (set_local $31 (get_local $13) ) - (set_local $35 + (set_local $32 (i32.const 0) ) - (set_local $29 + (set_local $28 (i32.const 0) ) (set_local $11 @@ -11500,7 +11500,7 @@ (set_local $23 (get_local $3) ) - (set_local $41 + (set_local $36 (i32.const 0) ) (loop $while-out$17 $while-in$18 @@ -11533,7 +11533,7 @@ (set_local $24 (get_local $23) ) - (set_local $30 + (set_local $29 (get_local $23) ) (set_local $11 @@ -11541,7 +11541,7 @@ ) (br $label$break$L123) ) - (set_local $41 + (set_local $36 (get_local $23) ) ) @@ -11608,14 +11608,14 @@ (if (get_local $6) (block - (set_local $34 + (set_local $31 (get_local $13) ) - (set_local $35 + (set_local $32 (get_local $14) ) - (set_local $29 - (get_local $41) + (set_local $28 + (get_local $36) ) (set_local $11 (i32.const 86) @@ -11647,11 +11647,11 @@ (if (i32.and (i32.eq - (get_local $35) + (get_local $32) (i32.const 0) ) (i32.eq - (get_local $29) + (get_local $28) (i32.const 0) ) ) @@ -11784,28 +11784,28 @@ ) ) ) - (get_local $35) + (get_local $32) ) ) (i32.const 0) ) (block (set_local $17 - (get_local $34) + (get_local $31) ) (set_local $15 - (get_local $29) + (get_local $28) ) ) (block (set_local $26 - (get_local $34) + (get_local $31) ) (set_local $24 (get_local $0) ) - (set_local $30 - (get_local $29) + (set_local $29 + (get_local $28) ) (set_local $11 (i32.const 90) @@ -11848,7 +11848,7 @@ (set_local $6 (select (get_local $24) - (get_local $30) + (get_local $29) (get_local $0) ) ) @@ -11868,7 +11868,7 @@ (set_local $24 (get_local $0) ) - (set_local $30 + (set_local $29 (get_local $6) ) (br $while-in$20) @@ -11899,7 +11899,7 @@ (set_local $24 (get_local $0) ) - (set_local $30 + (set_local $29 (get_local $6) ) ) @@ -12727,7 +12727,7 @@ (set_local $25 (get_local $2) ) - (set_local $38 + (set_local $37 (get_local $1) ) (set_local $11 @@ -12753,7 +12753,7 @@ ) (if (i32.lt_u - (get_local $38) + (get_local $37) (i32.load (i32.const 192) ) @@ -12761,7 +12761,7 @@ (call_import $_abort) (block (i32.store - (get_local $38) + (get_local $37) (get_local $3) ) (i32.store offset=24 @@ -13289,7 +13289,7 @@ ) ) (block - (set_local $28 + (set_local $30 (get_local $3) ) (set_local $21 @@ -13423,7 +13423,7 @@ ) ) (block - (set_local $28 + (set_local $30 (get_local $0) ) (set_local $21 @@ -13465,7 +13465,7 @@ (i32.const 2147483647) ) (i32.ne - (get_local $28) + (get_local $30) (i32.const -1) ) ) @@ -13523,12 +13523,12 @@ ) (if (i32.ne - (get_local $28) + (get_local $30) (i32.const -1) ) (block (set_local $16 - (get_local $28) + (get_local $30) ) (set_local $19 (get_local $0) @@ -13844,10 +13844,10 @@ (set_local $2 (get_local $3) ) - (set_local $45 + (set_local $42 (get_local $5) ) - (set_local $46 + (set_local $43 (get_local $6) ) (set_local $11 @@ -13881,7 +13881,7 @@ (i32.eq (i32.and (i32.load offset=12 - (get_local $46) + (get_local $43) ) (i32.const 8) ) @@ -13900,7 +13900,7 @@ ) (block (i32.store - (get_local $45) + (get_local $42) (i32.add (get_local $2) (get_local $19) @@ -14023,7 +14023,7 @@ (set_local $44 (get_local $1) ) - (set_local $40 + (set_local $38 (get_local $1) ) (set_local $11 @@ -14060,7 +14060,7 @@ (i32.eq (i32.and (i32.load offset=12 - (get_local $40) + (get_local $38) ) (i32.const 8) ) @@ -14076,7 +14076,7 @@ (i32.load (set_local $2 (i32.add - (get_local $40) + (get_local $38) (i32.const 4) ) ) @@ -14869,7 +14869,7 @@ (i32.const 8) ) ) - (set_local $31 + (set_local $33 (get_local $2) ) ) @@ -14894,7 +14894,7 @@ (set_local $7 (get_local $0) ) - (set_local $31 + (set_local $33 (get_local $1) ) (br $do-once$67) @@ -14909,12 +14909,12 @@ (get_local $5) ) (i32.store offset=12 - (get_local $31) + (get_local $33) (get_local $5) ) (i32.store offset=8 (get_local $5) - (get_local $31) + (get_local $33) ) (i32.store offset=12 (get_local $5) @@ -15137,7 +15137,7 @@ (get_local $4) ) (block - (set_local $32 + (set_local $34 (get_local $2) ) (set_local $11 @@ -15176,10 +15176,10 @@ (i32.const 0) ) (block - (set_local $42 + (set_local $45 (get_local $2) ) - (set_local $37 + (set_local $40 (get_local $1) ) (set_local $11 @@ -15205,7 +15205,7 @@ ) (if (i32.lt_u - (get_local $37) + (get_local $40) (i32.load (i32.const 192) ) @@ -15213,12 +15213,12 @@ (call_import $_abort) (block (i32.store - (get_local $37) + (get_local $40) (get_local $5) ) (i32.store offset=24 (get_local $5) - (get_local $42) + (get_local $45) ) (i32.store offset=12 (get_local $5) @@ -15242,7 +15242,7 @@ (i32.load (set_local $2 (i32.add - (get_local $32) + (get_local $34) (i32.const 8) ) ) @@ -15255,7 +15255,7 @@ ) ) (i32.ge_u - (get_local $32) + (get_local $34) (get_local $1) ) ) @@ -15274,7 +15274,7 @@ ) (i32.store offset=12 (get_local $5) - (get_local $32) + (get_local $34) ) (i32.store offset=24 (get_local $5) @@ -15880,7 +15880,7 @@ (get_local $3) ) (block - (set_local $33 + (set_local $35 (get_local $4) ) (set_local $11 @@ -15919,10 +15919,10 @@ (i32.const 0) ) (block - (set_local $43 + (set_local $46 (get_local $4) ) - (set_local $36 + (set_local $41 (get_local $2) ) (set_local $11 @@ -15948,7 +15948,7 @@ ) (if (i32.lt_u - (get_local $36) + (get_local $41) (i32.load (i32.const 192) ) @@ -15956,12 +15956,12 @@ (call_import $_abort) (block (i32.store - (get_local $36) + (get_local $41) (get_local $0) ) (i32.store offset=24 (get_local $0) - (get_local $43) + (get_local $46) ) (i32.store offset=12 (get_local $0) @@ -15985,7 +15985,7 @@ (i32.load (set_local $4 (i32.add - (get_local $33) + (get_local $35) (i32.const 8) ) ) @@ -15998,7 +15998,7 @@ ) ) (i32.ge_u - (get_local $33) + (get_local $35) (get_local $2) ) ) @@ -16017,7 +16017,7 @@ ) (i32.store offset=12 (get_local $0) - (get_local $33) + (get_local $35) ) (i32.store offset=24 (get_local $0) @@ -17054,7 +17054,7 @@ (get_local $1) (get_local $2) ) - (set_local $17 + (set_local $16 (i32.add (get_local $1) (i32.const 8) @@ -17082,7 +17082,7 @@ ) (get_local $8) ) - (set_local $17 + (set_local $16 (get_local $2) ) (call_import $_abort) @@ -17094,7 +17094,7 @@ (get_local $1) ) (i32.store - (get_local $17) + (get_local $16) (get_local $0) ) ) @@ -17884,7 +17884,7 @@ (set_local $18 (get_local $1) ) - (set_local $16 + (set_local $17 (get_local $5) ) (set_local $0 @@ -17910,7 +17910,7 @@ ) (if (i32.lt_u - (get_local $16) + (get_local $17) (i32.load (i32.const 192) ) @@ -17918,7 +17918,7 @@ (call_import $_abort) (block (i32.store - (get_local $16) + (get_local $17) (get_local $3) ) (i32.store offset=24 @@ -19300,7 +19300,7 @@ (i32.const 30) ) (block - (set_local $14 + (set_local $13 (set_local $0 (i32.add (get_local $5) @@ -19308,7 +19308,7 @@ ) ) ) - (set_local $13 + (set_local $14 (i32.or (i32.shl (get_local $6) @@ -19407,7 +19407,7 @@ (i32.const 31) ) (block - (set_local $14 + (set_local $13 (set_local $0 (i32.add (get_local $5) @@ -19415,7 +19415,7 @@ ) ) ) - (set_local $13 + (set_local $14 (i32.or (i32.and (i32.shr_u @@ -19562,10 +19562,10 @@ (i32.const 31) ) ) - (set_local $14 + (set_local $13 (get_local $0) ) - (set_local $13 + (set_local $14 (i32.or (i32.and (i32.shr_s @@ -19729,7 +19729,7 @@ (set_local $0 (if (i32.eq - (get_local $14) + (get_local $13) (i32.const 0) ) (block @@ -19743,7 +19743,7 @@ (get_local $12) ) (set_local $2 - (get_local $13) + (get_local $14) ) (set_local $1 (i32.const 0) @@ -19790,10 +19790,10 @@ (get_local $12) ) (set_local $6 - (get_local $13) + (get_local $14) ) (set_local $9 - (get_local $14) + (get_local $13) ) (set_local $0 (i32.const 0) diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise index 0b7f2497b..29492cd2c 100644 --- a/test/emcc_hello_world.fromasm.imprecise +++ b/test/emcc_hello_world.fromasm.imprecise @@ -1045,7 +1045,7 @@ (local $15 i32) (local $16 i32) (local $17 i32) - (set_local $10 + (set_local $8 (i32.load (i32.const 8) ) @@ -1072,17 +1072,17 @@ ) (set_local $9 (i32.add - (get_local $10) + (get_local $8) (i32.const 16) ) ) - (set_local $8 - (get_local $10) + (set_local $10 + (get_local $8) ) (i32.store (set_local $3 (i32.add - (get_local $10) + (get_local $8) (i32.const 32) ) ) @@ -1121,13 +1121,13 @@ (get_local $3) (get_local $2) ) - (set_local $13 + (set_local $12 (i32.add (get_local $0) (i32.const 60) ) ) - (set_local $12 + (set_local $13 (i32.add (get_local $0) (i32.const 44) @@ -1161,7 +1161,7 @@ (i32.store (get_local $9) (i32.load - (get_local $13) + (get_local $12) ) ) (i32.store offset=4 @@ -1185,24 +1185,24 @@ (get_local $0) ) (i32.store - (get_local $8) + (get_local $10) (i32.load - (get_local $13) + (get_local $12) ) ) (i32.store offset=4 - (get_local $8) + (get_local $10) (get_local $5) ) (i32.store offset=8 - (get_local $8) + (get_local $10) (get_local $6) ) (set_local $1 (call $___syscall_ret (call_import $___syscall146 (i32.const 146) - (get_local $8) + (get_local $10) ) ) ) @@ -1260,7 +1260,7 @@ (get_local $7) (set_local $4 (i32.load - (get_local $12) + (get_local $13) ) ) ) @@ -1363,7 +1363,7 @@ (i32.add (set_local $1 (i32.load - (get_local $12) + (get_local $13) ) ) (i32.load offset=48 @@ -1432,7 +1432,7 @@ ) (i32.store (i32.const 8) - (get_local $10) + (get_local $8) ) (get_local $14) ) @@ -1449,7 +1449,7 @@ (local $12 i32) (local $13 i32) (local $14 i32) - (set_local $4 + (set_local $3 (i32.load (i32.const 8) ) @@ -1476,25 +1476,25 @@ ) (set_local $5 (i32.add - (get_local $4) + (get_local $3) (i32.const 120) ) ) (set_local $8 - (get_local $4) + (get_local $3) ) - (set_local $7 + (set_local $6 (i32.add - (get_local $4) + (get_local $3) (i32.const 136) ) ) - (set_local $6 + (set_local $7 (i32.add - (set_local $3 + (set_local $4 (set_local $9 (i32.add - (get_local $4) + (get_local $3) (i32.const 80) ) ) @@ -1504,18 +1504,18 @@ ) (loop $do-out$0 $do-in$1 (i32.store - (get_local $3) + (get_local $4) (i32.const 0) ) (br_if $do-in$1 (i32.lt_s - (set_local $3 + (set_local $4 (i32.add - (get_local $3) + (get_local $4) (i32.const 4) ) ) - (get_local $6) + (get_local $7) ) ) ) @@ -1553,7 +1553,7 @@ (i32.const 0) ) ) - (set_local $3 + (set_local $4 (i32.and (set_local $2 (i32.load @@ -1601,7 +1601,7 @@ (block (set_local $2 (i32.load - (set_local $6 + (set_local $7 (i32.add (get_local $0) (i32.const 44) @@ -1610,8 +1610,8 @@ ) ) (i32.store - (get_local $6) (get_local $7) + (get_local $6) ) (i32.store (set_local $13 @@ -1620,7 +1620,7 @@ (i32.const 28) ) ) - (get_local $7) + (get_local $6) ) (i32.store (set_local $11 @@ -1629,7 +1629,7 @@ (i32.const 20) ) ) - (get_local $7) + (get_local $6) ) (i32.store (get_local $10) @@ -1643,7 +1643,7 @@ ) ) (i32.add - (get_local $7) + (get_local $6) (i32.const 80) ) ) @@ -1690,7 +1690,7 @@ ) ) (i32.store - (get_local $6) + (get_local $7) (get_local $2) ) (i32.store @@ -1739,7 +1739,7 @@ (get_local $0) (i32.or (get_local $1) - (get_local $3) + (get_local $4) ) ) (if @@ -1757,7 +1757,7 @@ ) (i32.store (i32.const 8) - (get_local $4) + (get_local $3) ) (get_local $0) ) @@ -2401,7 +2401,7 @@ (set_local $6 (get_local $3) ) - (set_local $8 + (set_local $7 (get_local $2) ) (set_local $3 @@ -2443,7 +2443,7 @@ (set_local $11 (get_local $0) ) - (set_local $14 + (set_local $13 (get_local $2) ) (set_local $16 @@ -2462,7 +2462,7 @@ (set_local $11 (get_local $2) ) - (set_local $14 + (set_local $13 (get_local $0) ) (set_local $16 @@ -2485,19 +2485,19 @@ (set_local $6 (get_local $11) ) - (set_local $8 - (get_local $14) + (set_local $7 + (get_local $13) ) (set_local $3 (i32.const 6) ) ) (block - (set_local $7 + (set_local $8 (i32.const 0) ) - (set_local $10 - (get_local $14) + (set_local $9 + (get_local $13) ) ) ) @@ -2513,7 +2513,7 @@ (i32.shr_s (i32.shl (i32.load8_s - (get_local $8) + (get_local $7) ) (i32.const 24) ) @@ -2533,11 +2533,11 @@ ) ) (block - (set_local $7 + (set_local $8 (get_local $6) ) - (set_local $10 - (get_local $8) + (set_local $9 + (get_local $7) ) ) (block @@ -2558,7 +2558,7 @@ (get_local $6) ) (set_local $5 - (get_local $8) + (get_local $7) ) (loop $while-out$5 $while-in$6 (set_local $1 @@ -2618,7 +2618,7 @@ (get_local $1) ) (block - (set_local $13 + (set_local $14 (get_local $4) ) (set_local $15 @@ -2635,16 +2635,16 @@ (set_local $12 (get_local $1) ) - (set_local $9 + (set_local $10 (get_local $2) ) ) (block - (set_local $13 + (set_local $14 (get_local $6) ) (set_local $15 - (get_local $8) + (get_local $7) ) (set_local $3 (i32.const 11) @@ -2659,23 +2659,23 @@ ) (if (i32.eq - (get_local $13) + (get_local $14) (i32.const 0) ) (block - (set_local $7 + (set_local $8 (i32.const 0) ) - (set_local $10 + (set_local $9 (get_local $15) ) (br $label$break$L8) ) (block (set_local $12 - (get_local $13) + (get_local $14) ) - (set_local $9 + (set_local $10 (get_local $15) ) ) @@ -2687,7 +2687,7 @@ (i32.shr_s (i32.shl (i32.load8_s - (get_local $9) + (get_local $10) ) (i32.const 24) ) @@ -2702,18 +2702,18 @@ ) ) (block - (set_local $7 + (set_local $8 (get_local $12) ) - (set_local $10 - (get_local $9) + (set_local $9 + (get_local $10) ) (br $label$break$L8) ) ) (set_local $2 (i32.add - (get_local $9) + (get_local $10) (i32.const 1) ) ) @@ -2728,10 +2728,10 @@ (i32.const 0) ) (block - (set_local $7 + (set_local $8 (i32.const 0) ) - (set_local $10 + (set_local $9 (get_local $2) ) (br $while-out$7) @@ -2740,7 +2740,7 @@ (set_local $12 (get_local $1) ) - (set_local $9 + (set_local $10 (get_local $2) ) ) @@ -2752,10 +2752,10 @@ ) ) (select - (get_local $10) + (get_local $9) (i32.const 0) (i32.ne - (get_local $7) + (get_local $8) (i32.const 0) ) ) @@ -2803,7 +2803,7 @@ ) ) (i32.load - (set_local $6 + (set_local $4 (i32.add (get_local $0) (i32.const 28) @@ -2865,7 +2865,7 @@ ) (set_local $2 (i32.load - (set_local $4 + (set_local $6 (i32.add (get_local $0) (i32.const 8) @@ -2897,7 +2897,7 @@ (i32.const 0) ) (i32.store - (get_local $6) + (get_local $4) (i32.const 0) ) (i32.store @@ -2905,7 +2905,7 @@ (i32.const 0) ) (i32.store - (get_local $4) + (get_local $6) (i32.const 0) ) (i32.store @@ -3015,7 +3015,7 @@ (local $81 i32) (local $82 i32) (local $83 i32) - (set_local $32 + (set_local $31 (i32.load (i32.const 8) ) @@ -3042,31 +3042,31 @@ ) (set_local $25 (i32.add - (get_local $32) + (get_local $31) (i32.const 16) ) ) (set_local $18 - (get_local $32) + (get_local $31) ) - (set_local $64 + (set_local $63 (i32.add - (get_local $32) + (get_local $31) (i32.const 528) ) ) - (set_local $52 + (set_local $45 (i32.ne (get_local $0) (i32.const 0) ) ) - (set_local $73 + (set_local $71 (set_local $27 (i32.add (set_local $5 (i32.add - (get_local $32) + (get_local $31) (i32.const 536) ) ) @@ -3074,87 +3074,87 @@ ) ) ) - (set_local $71 + (set_local $72 (i32.add (get_local $5) (i32.const 39) ) ) - (set_local $77 + (set_local $76 (i32.add - (set_local $75 + (set_local $73 (i32.add - (get_local $32) + (get_local $31) (i32.const 8) ) ) (i32.const 4) ) ) - (set_local $55 + (set_local $54 (i32.add (set_local $5 (i32.add - (get_local $32) + (get_local $31) (i32.const 576) ) ) (i32.const 12) ) ) - (set_local $72 + (set_local $74 (i32.add (get_local $5) (i32.const 11) ) ) - (set_local $83 + (set_local $77 (i32.sub - (set_local $44 - (get_local $55) + (set_local $41 + (get_local $54) ) - (set_local $67 + (set_local $64 (set_local $28 (i32.add - (get_local $32) + (get_local $31) (i32.const 588) ) ) ) ) ) - (set_local $81 + (set_local $78 (i32.sub (i32.const -2) - (get_local $67) + (get_local $64) ) ) - (set_local $82 + (set_local $79 (i32.add - (get_local $44) + (get_local $41) (i32.const 2) ) ) - (set_local $76 + (set_local $81 (i32.add - (set_local $78 + (set_local $80 (i32.add - (get_local $32) + (get_local $31) (i32.const 24) ) ) (i32.const 288) ) ) - (set_local $74 - (set_local $48 + (set_local $75 + (set_local $46 (i32.add (get_local $28) (i32.const 9) ) ) ) - (set_local $57 + (set_local $55 (i32.add (get_local $28) (i32.const 8) @@ -3218,10 +3218,10 @@ (i32.const 0) ) (block - (set_local $79 + (set_local $82 (get_local $8) ) - (set_local $80 + (set_local $83 (get_local $11) ) (set_local $12 @@ -3254,7 +3254,7 @@ (set_local $56 (get_local $5) ) - (set_local $70 + (set_local $65 (get_local $5) ) (set_local $12 @@ -3262,10 +3262,10 @@ ) (br $label$break$L9) ) - (set_local $41 + (set_local $42 (get_local $5) ) - (set_local $62 + (set_local $57 (get_local $5) ) (br $label$break$L9) @@ -3307,18 +3307,18 @@ (i32.const 37) ) (block - (set_local $41 + (set_local $42 (get_local $56) ) - (set_local $62 - (get_local $70) + (set_local $57 + (get_local $65) ) (br $label$break$L12) ) ) (set_local $5 (i32.add - (get_local $70) + (get_local $65) (i32.const 1) ) ) @@ -3344,15 +3344,15 @@ (set_local $56 (get_local $1) ) - (set_local $70 + (set_local $65 (get_local $5) ) ) (block - (set_local $41 + (set_local $42 (get_local $1) ) - (set_local $62 + (set_local $57 (get_local $5) ) (br $while-out$7) @@ -3364,12 +3364,12 @@ ) (set_local $16 (i32.sub - (get_local $62) + (get_local $57) (get_local $20) ) ) (if - (get_local $52) + (get_local $45) (if (i32.eq (i32.and @@ -3389,7 +3389,7 @@ ) (if (i32.ne - (get_local $62) + (get_local $57) (get_local $20) ) (block @@ -3397,7 +3397,7 @@ (get_local $8) ) (set_local $20 - (get_local $41) + (get_local $42) ) (set_local $1 (get_local $16) @@ -3416,7 +3416,7 @@ (i32.load8_s (set_local $5 (i32.add - (get_local $41) + (get_local $42) (i32.const 1) ) ) @@ -3437,7 +3437,7 @@ (set_local $5 (select (i32.add - (get_local $41) + (get_local $42) (i32.const 3) ) (get_local $5) @@ -3446,7 +3446,7 @@ (i32.shr_s (i32.shl (i32.load8_s offset=2 - (get_local $41) + (get_local $42) ) (i32.const 24) ) @@ -3674,16 +3674,16 @@ (i32.load offset=4 (get_local $1) ) - (set_local $63 + (set_local $66 (i32.const 1) ) - (set_local $66 + (set_local $67 (i32.add (get_local $9) (i32.const 3) ) ) - (set_local $61 + (set_local $58 (get_local $5) ) ) @@ -3718,7 +3718,7 @@ ) (if (i32.eqz - (get_local $52) + (get_local $45) ) (block (set_local $9 @@ -3770,13 +3770,13 @@ (i32.const 4) ) ) - (set_local $63 + (set_local $66 (i32.const 0) ) - (set_local $66 + (set_local $67 (get_local $7) ) - (set_local $61 + (set_local $58 (get_local $5) ) ) @@ -3784,20 +3784,20 @@ (set_local $11 (if (i32.lt_s - (get_local $61) + (get_local $58) (i32.const 0) ) (block (set_local $9 - (get_local $66) + (get_local $67) ) (set_local $22 - (get_local $63) + (get_local $66) ) (set_local $15 (i32.sub (i32.const 0) - (get_local $61) + (get_local $58) ) ) (i32.or @@ -3807,13 +3807,13 @@ ) (block (set_local $9 - (get_local $66) + (get_local $67) ) (set_local $22 - (get_local $63) + (get_local $66) ) (set_local $15 - (get_local $61) + (get_local $58) ) (get_local $11) ) @@ -4146,7 +4146,7 @@ ) ) (if - (get_local $52) + (get_local $45) (block (set_local $5 (i32.load @@ -4383,7 +4383,7 @@ ) (if (i32.eqz - (get_local $52) + (get_local $45) ) (block (set_local $23 @@ -4411,7 +4411,7 @@ ) (if (i32.eqz - (get_local $52) + (get_local $45) ) (block (set_local $19 @@ -4722,13 +4722,13 @@ (br $label$continue$L1) ) ) - (set_local $49 + (set_local $47 (i32.or (get_local $17) (i32.const 8) ) ) - (set_local $58 + (set_local $59 (select (get_local $10) (i32.const 8) @@ -4738,7 +4738,7 @@ ) ) ) - (set_local $69 + (set_local $68 (i32.const 120) ) (set_local $12 @@ -4747,13 +4747,13 @@ (br $switch$24) ) ) - (set_local $49 + (set_local $47 (get_local $17) ) - (set_local $58 + (set_local $59 (get_local $10) ) - (set_local $69 + (set_local $68 (get_local $33) ) (set_local $12 @@ -4864,13 +4864,13 @@ (set_local $35 (get_local $17) ) - (set_local $31 + (set_local $32 (get_local $10) ) - (set_local $38 + (set_local $36 (i32.const 0) ) - (set_local $40 + (set_local $37 (i32.const 4091) ) (set_local $12 @@ -4885,7 +4885,7 @@ (set_local $1 (i32.add (i32.sub - (get_local $73) + (get_local $71) (get_local $6) ) (i32.const 1) @@ -4896,17 +4896,17 @@ (set_local $35 (get_local $17) ) - (set_local $31 + (set_local $32 (select (get_local $1) (get_local $10) (get_local $5) ) ) - (set_local $38 + (set_local $36 (i32.const 0) ) - (set_local $40 + (set_local $37 (i32.const 4091) ) (set_local $12 @@ -4959,16 +4959,16 @@ (get_local $6) (get_local $5) ) - (set_local $45 + (set_local $48 (get_local $1) ) - (set_local $54 + (set_local $60 (get_local $5) ) - (set_local $59 + (set_local $61 (i32.const 1) ) - (set_local $60 + (set_local $62 (i32.const 4091) ) (set_local $12 @@ -4977,7 +4977,7 @@ (br $label$break$L75) ) ) - (set_local $45 + (set_local $48 (if (i32.eq (i32.and @@ -4992,7 +4992,7 @@ (i32.const 4091) (i32.const 4093) (i32.eq - (set_local $45 + (set_local $48 (i32.and (get_local $17) (i32.const 1) @@ -5002,13 +5002,13 @@ ) ) ) - (set_local $54 + (set_local $60 (get_local $6) ) - (set_local $59 - (get_local $45) + (set_local $61 + (get_local $48) ) - (set_local $60 + (set_local $62 (get_local $1) ) (set_local $12 @@ -5017,13 +5017,13 @@ (get_local $5) ) (block - (set_local $54 + (set_local $60 (get_local $6) ) - (set_local $59 + (set_local $61 (i32.const 1) ) - (set_local $60 + (set_local $62 (i32.const 4092) ) (set_local $12 @@ -5035,22 +5035,22 @@ ) (br $switch$24) ) - (set_local $45 + (set_local $48 (i32.load (set_local $1 (get_local $18) ) ) ) - (set_local $54 + (set_local $60 (i32.load offset=4 (get_local $1) ) ) - (set_local $59 + (set_local $61 (i32.const 0) ) - (set_local $60 + (set_local $62 (i32.const 4091) ) (set_local $12 @@ -5069,33 +5069,33 @@ (get_local $1) ) (i32.store8 - (get_local $71) + (get_local $72) (i32.and (get_local $5) (i32.const 255) ) ) - (set_local $47 - (get_local $71) + (set_local $49 + (get_local $72) ) - (set_local $36 + (set_local $38 (get_local $7) ) - (set_local $42 + (set_local $43 (i32.const 1) ) - (set_local $43 + (set_local $44 (i32.const 0) ) - (set_local $51 + (set_local $50 (i32.const 4091) ) - (set_local $53 + (set_local $51 (get_local $27) ) (br $switch$24) ) - (set_local $46 + (set_local $52 (call $_strerror (i32.load (call $___errno_location) @@ -5117,7 +5117,7 @@ (i32.const 0) ) ) - (set_local $46 + (set_local $52 (select (get_local $1) (i32.const 4101) @@ -5140,18 +5140,18 @@ (get_local $1) ) (i32.store - (get_local $75) + (get_local $73) (get_local $5) ) (i32.store - (get_local $77) + (get_local $76) (i32.const 0) ) (i32.store (get_local $18) - (get_local $75) + (get_local $73) ) - (set_local $65 + (set_local $69 (i32.const -1) ) (set_local $12 @@ -5173,13 +5173,13 @@ (i32.const 0) (get_local $17) ) - (set_local $37 + (set_local $39 (i32.const 0) ) (i32.const 98) ) (block - (set_local $65 + (set_local $69 (get_local $10) ) (i32.const 86) @@ -5215,7 +5215,7 @@ (i32.const 24) ) ) - (set_local $50 + (set_local $53 (if (i32.lt_s (i32.load offset=4 @@ -5226,7 +5226,7 @@ (i32.const 0) ) (block - (set_local $39 + (set_local $40 (i32.const 4108) ) (set_local $14 @@ -5245,7 +5245,7 @@ (i32.const 0) ) (block - (set_local $39 + (set_local $40 (select (i32.const 4109) (i32.const 4114) @@ -5263,7 +5263,7 @@ (get_local $1) ) (block - (set_local $39 + (set_local $40 (i32.const 4111) ) (i32.const 1) @@ -5355,9 +5355,9 @@ (block (set_local $11 (select - (get_local $39) + (get_local $40) (i32.add - (get_local $39) + (get_local $40) (i32.const 9) ) (i32.eq @@ -5373,7 +5373,7 @@ ) (set_local $6 (i32.or - (get_local $50) + (get_local $53) (i32.const 2) ) ) @@ -5495,17 +5495,17 @@ (call $_fmt_u (get_local $8) (get_local $5) - (get_local $55) + (get_local $54) ) ) - (get_local $55) + (get_local $54) ) (block (i32.store8 - (get_local $72) + (get_local $74) (i32.const 48) ) - (get_local $72) + (get_local $74) ) (get_local $5) ) @@ -5604,7 +5604,7 @@ (i32.const 1) ) ) - (get_local $67) + (get_local $64) ) (i32.const 1) ) @@ -5657,7 +5657,7 @@ ) (i32.lt_s (i32.add - (get_local $81) + (get_local $78) (get_local $1) ) (get_local $10) @@ -5674,14 +5674,14 @@ (select (i32.sub (i32.add - (get_local $82) + (get_local $79) (get_local $10) ) (get_local $8) ) (i32.add (i32.sub - (get_local $83) + (get_local $77) (get_local $8) ) (get_local $1) @@ -5723,7 +5723,7 @@ (set_local $1 (i32.sub (get_local $1) - (get_local $67) + (get_local $64) ) ) (if @@ -5751,7 +5751,7 @@ (get_local $1) (set_local $1 (i32.sub - (get_local $44) + (get_local $41) (get_local $8) ) ) @@ -5811,8 +5811,8 @@ (set_local $30 (set_local $11 (select - (get_local $78) - (get_local $76) + (get_local $80) + (get_local $81) (i32.lt_s (if (get_local $5) @@ -6140,7 +6140,7 @@ (get_local $24) ) (block - (set_local $68 + (set_local $70 (i32.add (i32.shl (i32.const 1) @@ -6169,7 +6169,7 @@ (get_local $16) ) ) - (get_local $68) + (get_local $70) ) ) (i32.store @@ -6433,7 +6433,7 @@ (i32.shr_s (i32.shl (i32.and - (set_local $68 + (set_local $70 (i32.ne (get_local $1) (i32.const 0) @@ -6636,7 +6636,7 @@ (block $do-once$90 (if (i32.eq - (get_local $50) + (get_local $53) (i32.const 0) ) (get_local $14) @@ -6646,7 +6646,7 @@ (i32.shr_s (i32.shl (i32.load8_s - (get_local $39) + (get_local $40) ) (i32.const 24) ) @@ -6941,7 +6941,7 @@ (i32.add (i32.xor (i32.and - (get_local $68) + (get_local $70) (i32.const 1) ) (i32.const 1) @@ -7272,12 +7272,12 @@ (if (i32.lt_s (i32.sub - (get_local $44) + (get_local $41) (set_local $5 (call $_fmt_u (get_local $7) (get_local $5) - (get_local $55) + (get_local $54) ) ) ) @@ -7296,7 +7296,7 @@ (if (i32.lt_s (i32.sub - (get_local $44) + (get_local $41) (get_local $5) ) (i32.const 2) @@ -7341,7 +7341,7 @@ ) (set_local $7 (i32.sub - (get_local $44) + (get_local $41) (get_local $5) ) ) @@ -7358,7 +7358,7 @@ (i32.add (i32.add (i32.add - (get_local $50) + (get_local $53) (i32.const 1) ) (get_local $21) @@ -7381,8 +7381,8 @@ (i32.const 0) ) (call $___fwritex - (get_local $39) - (get_local $50) + (get_local $40) + (get_local $53) (get_local $0) ) ) @@ -7419,7 +7419,7 @@ (get_local $6) ) (i32.const 0) - (get_local $48) + (get_local $46) ) ) (block $do-once$110 @@ -7432,16 +7432,16 @@ (if (i32.ne (get_local $5) - (get_local $48) + (get_local $46) ) (br $do-once$110) ) (i32.store8 - (get_local $57) + (get_local $55) (i32.const 48) ) (set_local $5 - (get_local $57) + (get_local $55) ) ) (block @@ -7489,7 +7489,7 @@ (call $___fwritex (get_local $5) (i32.sub - (get_local $74) + (get_local $75) (get_local $5) ) (get_local $0) @@ -7562,7 +7562,7 @@ (get_local $5) ) (i32.const 0) - (get_local $48) + (get_local $46) ) ) (get_local $28) @@ -7706,17 +7706,17 @@ (get_local $5) ) (i32.const 0) - (get_local $48) + (get_local $46) ) ) - (get_local $48) + (get_local $46) ) (block (i32.store8 - (get_local $57) + (get_local $55) (i32.const 48) ) - (get_local $57) + (get_local $55) ) (get_local $1) ) @@ -7819,7 +7819,7 @@ ) (set_local $11 (i32.sub - (get_local $74) + (get_local $75) (get_local $1) ) ) @@ -7908,7 +7908,7 @@ (call $___fwritex (get_local $10) (i32.sub - (get_local $44) + (get_local $41) (get_local $10) ) (get_local $0) @@ -7954,7 +7954,7 @@ (set_local $6 (select (i32.const 0) - (get_local $50) + (get_local $53) (set_local $1 (i32.or (f64.ne @@ -8009,7 +8009,7 @@ ) (block (call $___fwritex - (get_local $39) + (get_local $40) (get_local $6) (get_local $0) ) @@ -8056,22 +8056,22 @@ ) (br $label$continue$L1) ) - (set_local $47 + (set_local $49 (get_local $20) ) - (set_local $36 + (set_local $38 (get_local $17) ) - (set_local $42 + (set_local $43 (get_local $10) ) - (set_local $43 + (set_local $44 (i32.const 0) ) - (set_local $51 + (set_local $50 (i32.const 4091) ) - (set_local $53 + (set_local $51 (get_local $27) ) ) @@ -8086,7 +8086,7 @@ (block (set_local $6 (i32.and - (get_local $69) + (get_local $68) (i32.const 32) ) ) @@ -8114,15 +8114,15 @@ ) (block (set_local $35 - (get_local $49) + (get_local $47) ) - (set_local $31 - (get_local $58) + (set_local $32 + (get_local $59) ) - (set_local $38 + (set_local $36 (i32.const 0) ) - (set_local $40 + (set_local $37 (i32.const 4091) ) (set_local $12 @@ -8195,7 +8195,7 @@ (i32.or (i32.eq (i32.and - (get_local $49) + (get_local $47) (i32.const 8) ) (i32.const 0) @@ -8219,15 +8219,15 @@ ) (block (set_local $35 - (get_local $49) + (get_local $47) ) - (set_local $31 - (get_local $58) + (set_local $32 + (get_local $59) ) - (set_local $38 + (set_local $36 (i32.const 0) ) - (set_local $40 + (set_local $37 (i32.const 4091) ) (set_local $12 @@ -8237,19 +8237,19 @@ ) (block (set_local $35 - (get_local $49) + (get_local $47) ) - (set_local $31 - (get_local $58) + (set_local $32 + (get_local $59) ) - (set_local $38 + (set_local $36 (i32.const 2) ) - (set_local $40 + (set_local $37 (i32.add (i32.const 4091) (i32.shr_s - (get_local $69) + (get_local $68) (i32.const 4) ) ) @@ -8272,22 +8272,22 @@ (block (set_local $34 (call $_fmt_u - (get_local $45) - (get_local $54) + (get_local $48) + (get_local $60) (get_local $27) ) ) (set_local $35 (get_local $17) ) - (set_local $31 + (set_local $32 (get_local $10) ) - (set_local $38 - (get_local $59) + (set_local $36 + (get_local $61) ) - (set_local $40 - (get_local $60) + (set_local $37 + (get_local $62) ) (set_local $12 (i32.const 77) @@ -8306,7 +8306,7 @@ (i32.eq (set_local $1 (call $_memchr - (get_local $46) + (get_local $52) (i32.const 0) (get_local $10) ) @@ -8314,32 +8314,32 @@ (i32.const 0) ) ) - (set_local $47 - (get_local $46) + (set_local $49 + (get_local $52) ) - (set_local $36 + (set_local $38 (get_local $7) ) - (set_local $42 + (set_local $43 (select (get_local $10) (i32.sub (get_local $1) - (get_local $46) + (get_local $52) ) (get_local $5) ) ) - (set_local $43 + (set_local $44 (i32.const 0) ) - (set_local $51 + (set_local $50 (i32.const 4091) ) - (set_local $53 + (set_local $51 (select (i32.add - (get_local $46) + (get_local $52) (get_local $10) ) (get_local $1) @@ -8389,7 +8389,7 @@ (i32.lt_s (set_local $5 (call $_wctomb - (get_local $64) + (get_local $63) (get_local $1) ) ) @@ -8398,7 +8398,7 @@ (i32.gt_u (get_local $5) (i32.sub - (get_local $65) + (get_local $69) (get_local $6) ) ) @@ -8418,7 +8418,7 @@ ) (if (i32.gt_u - (get_local $65) + (get_local $69) (set_local $1 (i32.add (get_local $5) @@ -8466,7 +8466,7 @@ (i32.const 0) ) (block - (set_local $37 + (set_local $39 (i32.const 0) ) (set_local $12 @@ -8493,7 +8493,7 @@ (i32.const 0) ) (block - (set_local $37 + (set_local $39 (get_local $6) ) (set_local $12 @@ -8514,7 +8514,7 @@ (i32.add (set_local $5 (call $_wctomb - (get_local $64) + (get_local $63) (get_local $1) ) ) @@ -8524,7 +8524,7 @@ (get_local $6) ) (block - (set_local $37 + (set_local $39 (get_local $6) ) (set_local $12 @@ -8544,7 +8544,7 @@ (i32.const 0) ) (call $___fwritex - (get_local $64) + (get_local $63) (get_local $5) (get_local $0) ) @@ -8563,7 +8563,7 @@ ) ) (block - (set_local $37 + (set_local $39 (get_local $6) ) (set_local $12 @@ -8595,7 +8595,7 @@ (get_local $0) (i32.const 32) (get_local $15) - (get_local $37) + (get_local $39) (i32.xor (get_local $17) (i32.const 8192) @@ -8610,10 +8610,10 @@ (set_local $1 (select (get_local $15) - (get_local $37) + (get_local $39) (i32.gt_s (get_local $15) - (get_local $37) + (get_local $39) ) ) ) @@ -8640,16 +8640,16 @@ ) (get_local $35) (i32.gt_s - (get_local $31) + (get_local $32) (i32.const -1) ) ) ) - (set_local $47 + (set_local $49 (if (i32.or (i32.ne - (get_local $31) + (get_local $32) (i32.const 0) ) (set_local $1 @@ -8674,7 +8674,7 @@ (block (set_local $6 (i32.gt_s - (get_local $31) + (get_local $32) (set_local $1 (i32.add (i32.xor @@ -8685,48 +8685,48 @@ (i32.const 1) ) (i32.sub - (get_local $73) + (get_local $71) (get_local $34) ) ) ) ) ) - (set_local $36 + (set_local $38 (get_local $5) ) - (set_local $42 + (set_local $43 (select - (get_local $31) + (get_local $32) (get_local $1) (get_local $6) ) ) - (set_local $43 - (get_local $38) + (set_local $44 + (get_local $36) ) - (set_local $51 - (get_local $40) + (set_local $50 + (get_local $37) ) - (set_local $53 + (set_local $51 (get_local $27) ) (get_local $34) ) (block - (set_local $36 + (set_local $38 (get_local $5) ) - (set_local $42 + (set_local $43 (i32.const 0) ) - (set_local $43 - (get_local $38) + (set_local $44 + (get_local $36) ) - (set_local $51 - (get_local $40) + (set_local $50 + (get_local $37) ) - (set_local $53 + (set_local $51 (get_local $27) ) (get_local $27) @@ -8737,11 +8737,11 @@ ) (set_local $1 (i32.lt_s - (get_local $42) + (get_local $43) (set_local $6 (i32.sub - (get_local $53) - (get_local $47) + (get_local $51) + (get_local $49) ) ) ) @@ -8751,11 +8751,11 @@ (get_local $15) (set_local $1 (i32.add - (get_local $43) + (get_local $44) (set_local $7 (select (get_local $6) - (get_local $42) + (get_local $43) (get_local $1) ) ) @@ -8774,7 +8774,7 @@ ) ) (get_local $1) - (get_local $36) + (get_local $38) ) (if (i32.eq @@ -8787,8 +8787,8 @@ (i32.const 0) ) (call $___fwritex - (get_local $51) - (get_local $43) + (get_local $50) + (get_local $44) (get_local $0) ) ) @@ -8798,7 +8798,7 @@ (get_local $5) (get_local $1) (i32.xor - (get_local $36) + (get_local $38) (i32.const 65536) ) ) @@ -8820,7 +8820,7 @@ (i32.const 0) ) (call $___fwritex - (get_local $47) + (get_local $49) (get_local $6) (get_local $0) ) @@ -8831,7 +8831,7 @@ (get_local $5) (get_local $1) (i32.xor - (get_local $36) + (get_local $38) (i32.const 8192) ) ) @@ -8862,7 +8862,7 @@ ) (if (i32.eq - (get_local $80) + (get_local $83) (i32.const 0) ) (set_local $23 @@ -8984,14 +8984,14 @@ ) ) (set_local $23 - (get_local $79) + (get_local $82) ) ) ) ) (i32.store (i32.const 8) - (get_local $32) + (get_local $31) ) (get_local $23) ) @@ -11456,13 +11456,13 @@ (i32.const 0) ) (block - (set_local $34 + (set_local $31 (get_local $13) ) - (set_local $35 + (set_local $32 (i32.const 0) ) - (set_local $29 + (set_local $28 (i32.const 0) ) (set_local $11 @@ -11498,7 +11498,7 @@ (set_local $23 (get_local $3) ) - (set_local $41 + (set_local $36 (i32.const 0) ) (loop $while-out$17 $while-in$18 @@ -11531,7 +11531,7 @@ (set_local $24 (get_local $23) ) - (set_local $30 + (set_local $29 (get_local $23) ) (set_local $11 @@ -11539,7 +11539,7 @@ ) (br $label$break$L123) ) - (set_local $41 + (set_local $36 (get_local $23) ) ) @@ -11606,14 +11606,14 @@ (if (get_local $6) (block - (set_local $34 + (set_local $31 (get_local $13) ) - (set_local $35 + (set_local $32 (get_local $14) ) - (set_local $29 - (get_local $41) + (set_local $28 + (get_local $36) ) (set_local $11 (i32.const 86) @@ -11645,11 +11645,11 @@ (if (i32.and (i32.eq - (get_local $35) + (get_local $32) (i32.const 0) ) (i32.eq - (get_local $29) + (get_local $28) (i32.const 0) ) ) @@ -11782,28 +11782,28 @@ ) ) ) - (get_local $35) + (get_local $32) ) ) (i32.const 0) ) (block (set_local $17 - (get_local $34) + (get_local $31) ) (set_local $15 - (get_local $29) + (get_local $28) ) ) (block (set_local $26 - (get_local $34) + (get_local $31) ) (set_local $24 (get_local $0) ) - (set_local $30 - (get_local $29) + (set_local $29 + (get_local $28) ) (set_local $11 (i32.const 90) @@ -11846,7 +11846,7 @@ (set_local $6 (select (get_local $24) - (get_local $30) + (get_local $29) (get_local $0) ) ) @@ -11866,7 +11866,7 @@ (set_local $24 (get_local $0) ) - (set_local $30 + (set_local $29 (get_local $6) ) (br $while-in$20) @@ -11897,7 +11897,7 @@ (set_local $24 (get_local $0) ) - (set_local $30 + (set_local $29 (get_local $6) ) ) @@ -12725,7 +12725,7 @@ (set_local $25 (get_local $2) ) - (set_local $38 + (set_local $37 (get_local $1) ) (set_local $11 @@ -12751,7 +12751,7 @@ ) (if (i32.lt_u - (get_local $38) + (get_local $37) (i32.load (i32.const 192) ) @@ -12759,7 +12759,7 @@ (call_import $_abort) (block (i32.store - (get_local $38) + (get_local $37) (get_local $3) ) (i32.store offset=24 @@ -13287,7 +13287,7 @@ ) ) (block - (set_local $28 + (set_local $30 (get_local $3) ) (set_local $21 @@ -13421,7 +13421,7 @@ ) ) (block - (set_local $28 + (set_local $30 (get_local $0) ) (set_local $21 @@ -13463,7 +13463,7 @@ (i32.const 2147483647) ) (i32.ne - (get_local $28) + (get_local $30) (i32.const -1) ) ) @@ -13521,12 +13521,12 @@ ) (if (i32.ne - (get_local $28) + (get_local $30) (i32.const -1) ) (block (set_local $16 - (get_local $28) + (get_local $30) ) (set_local $19 (get_local $0) @@ -13842,10 +13842,10 @@ (set_local $2 (get_local $3) ) - (set_local $45 + (set_local $42 (get_local $5) ) - (set_local $46 + (set_local $43 (get_local $6) ) (set_local $11 @@ -13879,7 +13879,7 @@ (i32.eq (i32.and (i32.load offset=12 - (get_local $46) + (get_local $43) ) (i32.const 8) ) @@ -13898,7 +13898,7 @@ ) (block (i32.store - (get_local $45) + (get_local $42) (i32.add (get_local $2) (get_local $19) @@ -14021,7 +14021,7 @@ (set_local $44 (get_local $1) ) - (set_local $40 + (set_local $38 (get_local $1) ) (set_local $11 @@ -14058,7 +14058,7 @@ (i32.eq (i32.and (i32.load offset=12 - (get_local $40) + (get_local $38) ) (i32.const 8) ) @@ -14074,7 +14074,7 @@ (i32.load (set_local $2 (i32.add - (get_local $40) + (get_local $38) (i32.const 4) ) ) @@ -14867,7 +14867,7 @@ (i32.const 8) ) ) - (set_local $31 + (set_local $33 (get_local $2) ) ) @@ -14892,7 +14892,7 @@ (set_local $7 (get_local $0) ) - (set_local $31 + (set_local $33 (get_local $1) ) (br $do-once$67) @@ -14907,12 +14907,12 @@ (get_local $5) ) (i32.store offset=12 - (get_local $31) + (get_local $33) (get_local $5) ) (i32.store offset=8 (get_local $5) - (get_local $31) + (get_local $33) ) (i32.store offset=12 (get_local $5) @@ -15135,7 +15135,7 @@ (get_local $4) ) (block - (set_local $32 + (set_local $34 (get_local $2) ) (set_local $11 @@ -15174,10 +15174,10 @@ (i32.const 0) ) (block - (set_local $42 + (set_local $45 (get_local $2) ) - (set_local $37 + (set_local $40 (get_local $1) ) (set_local $11 @@ -15203,7 +15203,7 @@ ) (if (i32.lt_u - (get_local $37) + (get_local $40) (i32.load (i32.const 192) ) @@ -15211,12 +15211,12 @@ (call_import $_abort) (block (i32.store - (get_local $37) + (get_local $40) (get_local $5) ) (i32.store offset=24 (get_local $5) - (get_local $42) + (get_local $45) ) (i32.store offset=12 (get_local $5) @@ -15240,7 +15240,7 @@ (i32.load (set_local $2 (i32.add - (get_local $32) + (get_local $34) (i32.const 8) ) ) @@ -15253,7 +15253,7 @@ ) ) (i32.ge_u - (get_local $32) + (get_local $34) (get_local $1) ) ) @@ -15272,7 +15272,7 @@ ) (i32.store offset=12 (get_local $5) - (get_local $32) + (get_local $34) ) (i32.store offset=24 (get_local $5) @@ -15878,7 +15878,7 @@ (get_local $3) ) (block - (set_local $33 + (set_local $35 (get_local $4) ) (set_local $11 @@ -15917,10 +15917,10 @@ (i32.const 0) ) (block - (set_local $43 + (set_local $46 (get_local $4) ) - (set_local $36 + (set_local $41 (get_local $2) ) (set_local $11 @@ -15946,7 +15946,7 @@ ) (if (i32.lt_u - (get_local $36) + (get_local $41) (i32.load (i32.const 192) ) @@ -15954,12 +15954,12 @@ (call_import $_abort) (block (i32.store - (get_local $36) + (get_local $41) (get_local $0) ) (i32.store offset=24 (get_local $0) - (get_local $43) + (get_local $46) ) (i32.store offset=12 (get_local $0) @@ -15983,7 +15983,7 @@ (i32.load (set_local $4 (i32.add - (get_local $33) + (get_local $35) (i32.const 8) ) ) @@ -15996,7 +15996,7 @@ ) ) (i32.ge_u - (get_local $33) + (get_local $35) (get_local $2) ) ) @@ -16015,7 +16015,7 @@ ) (i32.store offset=12 (get_local $0) - (get_local $33) + (get_local $35) ) (i32.store offset=24 (get_local $0) @@ -17052,7 +17052,7 @@ (get_local $1) (get_local $2) ) - (set_local $17 + (set_local $16 (i32.add (get_local $1) (i32.const 8) @@ -17080,7 +17080,7 @@ ) (get_local $8) ) - (set_local $17 + (set_local $16 (get_local $2) ) (call_import $_abort) @@ -17092,7 +17092,7 @@ (get_local $1) ) (i32.store - (get_local $17) + (get_local $16) (get_local $0) ) ) @@ -17882,7 +17882,7 @@ (set_local $18 (get_local $1) ) - (set_local $16 + (set_local $17 (get_local $5) ) (set_local $0 @@ -17908,7 +17908,7 @@ ) (if (i32.lt_u - (get_local $16) + (get_local $17) (i32.load (i32.const 192) ) @@ -17916,7 +17916,7 @@ (call_import $_abort) (block (i32.store - (get_local $16) + (get_local $17) (get_local $3) ) (i32.store offset=24 @@ -19298,7 +19298,7 @@ (i32.const 30) ) (block - (set_local $14 + (set_local $13 (set_local $0 (i32.add (get_local $5) @@ -19306,7 +19306,7 @@ ) ) ) - (set_local $13 + (set_local $14 (i32.or (i32.shl (get_local $6) @@ -19405,7 +19405,7 @@ (i32.const 31) ) (block - (set_local $14 + (set_local $13 (set_local $0 (i32.add (get_local $5) @@ -19413,7 +19413,7 @@ ) ) ) - (set_local $13 + (set_local $14 (i32.or (i32.and (i32.shr_u @@ -19560,10 +19560,10 @@ (i32.const 31) ) ) - (set_local $14 + (set_local $13 (get_local $0) ) - (set_local $13 + (set_local $14 (i32.or (i32.and (i32.shr_s @@ -19727,7 +19727,7 @@ (set_local $0 (if (i32.eq - (get_local $14) + (get_local $13) (i32.const 0) ) (block @@ -19741,7 +19741,7 @@ (get_local $12) ) (set_local $2 - (get_local $13) + (get_local $14) ) (set_local $1 (i32.const 0) @@ -19788,10 +19788,10 @@ (get_local $12) ) (set_local $6 - (get_local $13) + (get_local $14) ) (set_local $9 - (get_local $14) + (get_local $13) ) (set_local $0 (i32.const 0) diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 27cd7d91e..52b6cd6ed 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -635,39 +635,6 @@ optimized: (func $just-one-block (type $v) (nop) ) - (func $two-blocks (type $v) - (nop) - ) - (func $two-blocks-plus-code (type $v) - (nop) - ) - (func $loop (type $v) - (nop) - ) - (func $loop-plus-code (type $v) - (nop) - ) - (func $split (type $v) - (nop) - ) - (func $split-plus-code (type $v) - (nop) - ) - (func $if (type $v) - (nop) - ) - (func $if-plus-code (type $v) - (nop) - ) - (func $if-else (type $v) - (nop) - ) - (func $loop-tail (type $v) - (nop) - ) - (func $nontrivial-loop-plus-phi-to-head (type $v) - (nop) - ) ) module loaded from binary form: (module diff --git a/test/hello_libcxx.cpp b/test/hello_libcxx.cpp new file mode 100644 index 000000000..445c5513b --- /dev/null +++ b/test/hello_libcxx.cpp @@ -0,0 +1,8 @@ +#include <iostream> + +int main() +{ + std::cout << "hello, world!" << std::endl; + return 0; +} + diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm index 9e8d34b83..f2acc39d2 100644 --- a/test/memorygrowth.fromasm +++ b/test/memorygrowth.fromasm @@ -1598,7 +1598,7 @@ (set_local $27 (get_local $8) ) - (set_local $32 + (set_local $31 (get_local $8) ) (set_local $8 @@ -1669,7 +1669,7 @@ (set_local $37 (get_local $13) ) - (set_local $31 + (set_local $32 (get_local $1) ) (set_local $8 @@ -1708,7 +1708,7 @@ (set_local $37 (i32.const 0) ) - (set_local $31 + (set_local $32 (i32.const 0) ) (set_local $8 @@ -1731,7 +1731,7 @@ (i32.const 0) ) (i32.eq - (get_local $31) + (get_local $32) (i32.const 0) ) ) @@ -1873,8 +1873,8 @@ (set_local $27 (get_local $0) ) - (set_local $32 - (get_local $31) + (set_local $31 + (get_local $32) ) (set_local $8 (i32.const 90) @@ -1885,7 +1885,7 @@ (get_local $36) ) (set_local $10 - (get_local $31) + (get_local $32) ) ) ) @@ -1925,7 +1925,7 @@ (set_local $1 (select (get_local $27) - (get_local $32) + (get_local $31) (get_local $7) ) ) @@ -1942,7 +1942,7 @@ (set_local $27 (get_local $7) ) - (set_local $32 + (set_local $31 (get_local $1) ) (br $while-in$20) @@ -1958,7 +1958,7 @@ (set_local $28 (get_local $6) ) - (set_local $32 + (set_local $31 (get_local $1) ) ) @@ -9013,29 +9013,29 @@ (i32.load (get_local $3) ) - (set_local $2 + (set_local $1 (i32.const 3) ) - (set_local $1 + (set_local $2 (i32.const -1) ) ) ) - (set_local $2 + (set_local $1 (i32.const 3) ) ) (if (i32.eq - (get_local $2) + (get_local $1) (i32.const 3) ) (block (if (i32.lt_u - (set_local $1 + (set_local $2 (i32.load - (set_local $2 + (set_local $1 (i32.add (get_local $0) (i32.const 4) @@ -9066,7 +9066,7 @@ ) (get_local $0) (i32.sub - (get_local $1) + (get_local $2) (get_local $6) ) (i32.const 1) @@ -9089,15 +9089,15 @@ (i32.const 0) ) (i32.store - (get_local $2) + (get_local $1) (i32.const 0) ) - (set_local $1 + (set_local $2 (i32.const 0) ) ) ) - (get_local $1) + (get_local $2) ) (func $jb (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise index 9e8d34b83..f2acc39d2 100644 --- a/test/memorygrowth.fromasm.imprecise +++ b/test/memorygrowth.fromasm.imprecise @@ -1598,7 +1598,7 @@ (set_local $27 (get_local $8) ) - (set_local $32 + (set_local $31 (get_local $8) ) (set_local $8 @@ -1669,7 +1669,7 @@ (set_local $37 (get_local $13) ) - (set_local $31 + (set_local $32 (get_local $1) ) (set_local $8 @@ -1708,7 +1708,7 @@ (set_local $37 (i32.const 0) ) - (set_local $31 + (set_local $32 (i32.const 0) ) (set_local $8 @@ -1731,7 +1731,7 @@ (i32.const 0) ) (i32.eq - (get_local $31) + (get_local $32) (i32.const 0) ) ) @@ -1873,8 +1873,8 @@ (set_local $27 (get_local $0) ) - (set_local $32 - (get_local $31) + (set_local $31 + (get_local $32) ) (set_local $8 (i32.const 90) @@ -1885,7 +1885,7 @@ (get_local $36) ) (set_local $10 - (get_local $31) + (get_local $32) ) ) ) @@ -1925,7 +1925,7 @@ (set_local $1 (select (get_local $27) - (get_local $32) + (get_local $31) (get_local $7) ) ) @@ -1942,7 +1942,7 @@ (set_local $27 (get_local $7) ) - (set_local $32 + (set_local $31 (get_local $1) ) (br $while-in$20) @@ -1958,7 +1958,7 @@ (set_local $28 (get_local $6) ) - (set_local $32 + (set_local $31 (get_local $1) ) ) @@ -9013,29 +9013,29 @@ (i32.load (get_local $3) ) - (set_local $2 + (set_local $1 (i32.const 3) ) - (set_local $1 + (set_local $2 (i32.const -1) ) ) ) - (set_local $2 + (set_local $1 (i32.const 3) ) ) (if (i32.eq - (get_local $2) + (get_local $1) (i32.const 3) ) (block (if (i32.lt_u - (set_local $1 + (set_local $2 (i32.load - (set_local $2 + (set_local $1 (i32.add (get_local $0) (i32.const 4) @@ -9066,7 +9066,7 @@ ) (get_local $0) (i32.sub - (get_local $1) + (get_local $2) (get_local $6) ) (i32.const 1) @@ -9089,15 +9089,15 @@ (i32.const 0) ) (i32.store - (get_local $2) + (get_local $1) (i32.const 0) ) - (set_local $1 + (set_local $2 (i32.const 0) ) ) ) - (get_local $1) + (get_local $2) ) (func $jb (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) diff --git a/test/passes/duplicate-function-elimination.txt b/test/passes/duplicate-function-elimination.txt new file mode 100644 index 000000000..9595f5705 --- /dev/null +++ b/test/passes/duplicate-function-elimination.txt @@ -0,0 +1,864 @@ +(module + (memory 0) + (func $erase + (nop) + ) +) +(module + (memory 0) + (func $keep2 + (i32.const 0) + ) + (func $other + (nop) + ) +) +(module + (memory 0) + (func $erase + (i32.const 0) + ) +) +(module + (memory 0) + (func $keep2 + (i32.const 0) + ) + (func $other + (i32.const 1) + ) +) +(module + (memory 0) + (start $keep2) + (export "keep2" $keep2) + (export "other" $keep2) + (table $keep2 $keep2 $caller) + (func $keep2 + (nop) + ) + (func $caller + (call $keep2) + (call $keep2) + ) +) +(module + (memory 0) + (func $keep2-after-two-passes + (nop) + ) + (func $keep-caller + (call $keep2-after-two-passes) + ) +) +(module + (memory 0) + (func $keep-4 + (nop) + ) + (func $other + (unreachable) + ) + (func $keep-caller + (call $keep-4) + ) + (func $other-caller + (call $other) + ) +) +(module + (memory 0) + (type $T (func (result i32))) + (type $S (func (result i32))) + (func $keep4-similar-but-func-sig-differs + (i32.const 0) + ) + (func $other1 (param $i i32) + (i32.const 0) + ) + (func $other2 (type $T) (result i32) + (i32.const 0) + ) + (func $other3 (type $S) (result i32) + (i32.const 0) + ) +) +(module + (memory 0) + (type $S (func (result i32))) + (func $keep2-similar-but-func-sig-differs (param $i i32) + (i32.const 0) + ) + (func $other2 (type $S) (result i32) + (i32.const 0) + ) +) +(module + (memory 0) + (func $keep2 + (nop) + ) + (func $other + (nop) + (nop) + ) +) +(module + (memory 0) + (func $erase + (block $block0 + ) + ) +) +(module + (memory 0) + (func $keep2 + (block $block0 + ) + ) + (func $other + (block $block0 + (nop) + ) + ) +) +(module + (memory 0) + (func $erase + (block $block0 + (nop) + ) + ) +) +(module + (memory 0) + (func $keep2 + (block $block0 + (nop) + ) + ) + (func $other + (block $block0 + (nop) + (unreachable) + ) + ) +) +(module + (memory 0) + (func $keep2 + (block $block0 + (nop) + ) + ) + (func $other + (block $block0 + (unreachable) + ) + ) +) +(module + (memory 0) + (func $erase-since-block-names-do-not-matter + (block $foo + ) + ) +) +(module + (memory 0) + (func $erase-since-block-names-do-not-matter + (block $foo + (br $foo) + (br_table $foo $foo + (i32.const 0) + ) + ) + ) +) +(module + (memory 0) + (func $keep2 + (block $foo + (br $foo + (i32.const 0) + ) + ) + ) + (func $other + (block $bar + (br $bar + (i32.const 1) + ) + ) + ) +) +(module + (memory 0) + (func $keep2 + (block $foo + (br_if $foo + (i32.const 0) + ) + ) + ) + (func $other + (block $bar + (br_if $bar + (i32.const 1) + ) + ) + ) +) +(module + (memory 0) + (func $erase + (block $foo + (br_if $foo + (i32.const 0) + ) + ) + ) +) +(module + (memory 0) + (func $keep2 + (block $foo + (br_table $foo $foo + (i32.const 0) + ) + ) + ) + (func $other + (block $bar + (br_table $bar $bar + (i32.const 1) + ) + ) + ) +) +(module + (memory 0) + (func $erase + (loop $foo $bar + (nop) + ) + ) +) +(module + (memory 0) + (func $keep2 + (block $foo + (br_table $foo $foo + (i32.const 0) + (i32.const 0) + ) + ) + ) + (func $other + (block $bar + (br_table $bar $bar + (i32.const 0) + (i32.const 1) + ) + ) + ) +) +(module + (memory 0) + (func $keep2 + (block $foo + (block $bar + (br_table $foo $bar + (i32.const 0) + ) + ) + ) + ) +) +(module + (memory 0) + (func $erase + (block $foo + (block $bar + (br_table $foo $bar + (i32.const 0) + ) + ) + ) + ) + (func $other + (block $bar + (block $foo + (br_table $foo $bar + (i32.const 0) + ) + ) + ) + ) +) +(module + (memory 0) + (func $erase + (call $erase) + ) +) +(module + (memory 0) + (func $keep2-but-in-theory-we-could-erase + (call $keep2-but-in-theory-we-could-erase) + ) + (func $other + (call $other) + ) +) +(module + (memory 0) + (type $FUNCSIG$v (func)) + (import $i "env" "i") + (import $i "env" "j") + (func $erase + (call_import $i) + ) +) +(module + (memory 0) + (type $FUNCSIG$v (func)) + (import $i "env" "i") + (import $j "env" "j") + (func $keep2 + (call_import $i) + ) + (func $other + (call_import $j) + ) +) +(module + (memory 0) + (type $T (func)) + (table $erase $erase) + (func $erase + (call_indirect $T + (i32.const 0) + ) + ) +) +(module + (memory 0) + (type $T (func)) + (table $keep2 $other) + (func $keep2 + (call_indirect $T + (i32.const 0) + ) + ) + (func $other + (call_indirect $T + (i32.const 1) + ) + ) +) +(module + (memory 0) + (type $T (func)) + (type $S (func)) + (table $keep2 $other) + (func $keep2 + (call_indirect $T + (i32.const 0) + ) + ) + (func $other + (call_indirect $S + (i32.const 0) + ) + ) +) +(module + (memory 0) + (func $erase-even-locals-with-different-names + (local $i i32) + (get_local $i) + ) +) +(module + (memory 0) + (func $keep2 + (local $i i32) + (get_local $i) + ) + (func $other + (local $j i64) + (get_local $j) + ) +) +(module + (memory 0) + (func $erase-even-locals-with-different-names + (local $i i32) + (set_local $i + (i32.const 0) + ) + ) +) +(module + (memory 0) + (func $keep2 + (local $i i32) + (set_local $i + (i32.const 0) + ) + ) + (func $other + (local $j i64) + (set_local $j + (i64.const 0) + ) + ) +) +(module + (memory 0) + (func $keep2 + (local $i i32) + (set_local $i + (i32.const 0) + ) + ) + (func $other + (local $j i32) + (set_local $j + (i32.const 1) + ) + ) +) +(module + (memory 10) + (func $erase + (i32.load + (i32.const 0) + ) + (i32.load8_s offset=3 align=2 + (i32.const 0) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load16_s offset=3 + (i32.const 0) + ) + ) + (func $other + (i32.load8_s offset=3 align=2 + (i32.const 0) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load8_s offset=3 + (i32.const 0) + ) + ) + (func $other + (i32.load8_s offset=3 align=2 + (i32.const 0) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load8_s align=2 + (i32.const 0) + ) + ) + (func $other + (i32.load8_s offset=3 align=2 + (i32.const 0) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load8_s offset=3 align=2 + (i32.const 0) + ) + ) + (func $other + (i32.load8_s offset=3 align=2 + (i32.const 1) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load8_u offset=3 align=2 + (i32.const 0) + ) + ) + (func $other + (i32.load8_s offset=3 align=2 + (i32.const 0) + ) + ) +) +(module + (memory 10) + (func $erase + (i32.store + (i32.const 0) + (i32.const 100) + ) + (i32.store8 offset=3 align=2 + (i32.const 0) + (i32.const 100) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store16 offset=3 + (i32.const 0) + (i32.const 100) + ) + ) + (func $other + (i32.store8 offset=3 align=2 + (i32.const 0) + (i32.const 100) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store8 offset=3 + (i32.const 0) + (i32.const 100) + ) + ) + (func $other + (i32.store8 offset=3 align=2 + (i32.const 0) + (i32.const 100) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store8 align=2 + (i32.const 0) + (i32.const 100) + ) + ) + (func $other + (i32.store8 offset=3 align=2 + (i32.const 0) + (i32.const 100) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store8 offset=3 align=2 + (i32.const 0) + (i32.const 100) + ) + ) + (func $other + (i32.store8 offset=3 align=2 + (i32.const 1) + (i32.const 100) + ) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store8 offset=3 align=2 + (i32.const 0) + (i32.const 100) + ) + ) + (func $other + (i32.store8 offset=3 align=2 + (i32.const 0) + (i32.const 101) + ) + ) +) +(module + (memory 0) + (func $keep2 + (i32.const 0) + ) + (func $other + (i64.const 0) + ) +) +(module + (memory 0) + (func $keep2 + (i32.const 0) + ) + (func $other + (f32.const 0) + ) +) +(module + (memory 0) + (func $keep2 + (i32.const 0) + ) + (func $other + (f64.const 0) + ) +) +(module + (memory 0) + (func $keep2 + (i64.const 0) + ) + (func $other + (i64.const 1) + ) +) +(module + (memory 0) + (func $keep2 + (f32.const 0.10000000149011612) + ) + (func $other + (f32.const -0.10000000149011612) + ) +) +(module + (memory 0) + (func $keep2 + (f64.const 0.1) + ) + (func $other + (f64.const 0.2) + ) +) +(module + (memory 0) + (func $erase + (f32.abs + (f32.const 0) + ) + ) +) +(module + (memory 0) + (func $keep2 + (f32.abs + (f32.const 0) + ) + ) + (func $other + (f32.abs + (f32.const 1) + ) + ) +) +(module + (memory 0) + (func $keep2 + (f32.abs + (f32.const 0) + ) + ) + (func $other + (f32.neg + (f32.const 0) + ) + ) +) +(module + (memory 0) + (func $erase + (f32.add + (f32.const 0) + (f32.const 0) + ) + ) +) +(module + (memory 0) + (func $keep2 + (f32.add + (f32.const 0) + (f32.const 0) + ) + ) + (func $other + (f32.add + (f32.const 0) + (f32.const 1) + ) + ) +) +(module + (memory 0) + (func $keep2 + (f32.add + (f32.const 0) + (f32.const 0) + ) + ) + (func $other + (f32.add + (f32.const 1) + (f32.const 0) + ) + ) +) +(module + (memory 0) + (func $keep2 + (f32.add + (f32.const 0) + (f32.const 0) + ) + ) + (func $other + (f32.sub + (f32.const 0) + (f32.const 0) + ) + ) +) +(module + (memory 0) + (func $erase + (select + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) +) +(module + (memory 0) + (func $keep + (select + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) + (func $other + (select + (i32.const 1) + (i32.const 0) + (i32.const 0) + ) + ) +) +(module + (memory 0) + (func $keep + (select + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) + (func $other + (select + (i32.const 0) + (i32.const 2) + (i32.const 0) + ) + ) +) +(module + (memory 0) + (func $keep + (select + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) + (func $other + (select + (i32.const 0) + (i32.const 0) + (i32.const 3) + ) + ) +) +(module + (memory 0) + (func $erase + (return) + ) +) +(module + (memory 0) + (func $erase (result i32) + (return + (i32.const 0) + ) + ) +) +(module + (memory 0) + (func $keep (result i32) + (return + (i32.const 0) + ) + ) + (func $other (result i32) + (return + (i32.const 1) + ) + ) +) +(module + (memory 0) + (func $erase + (current_memory) + ) +) +(module + (memory 0) + (func $erase + (grow_memory + (i32.const 10) + ) + ) +) +(module + (memory 0) + (func $keep + (grow_memory + (i32.const 10) + ) + ) + (func $other + (grow_memory + (i32.const 11) + ) + ) +) +(module + (memory 0) + (func $keep + (current_memory) + ) + (func $other + (grow_memory + (i32.const 10) + ) + ) +) diff --git a/test/passes/duplicate-function-elimination.wast b/test/passes/duplicate-function-elimination.wast new file mode 100644 index 000000000..8d1a85cd5 --- /dev/null +++ b/test/passes/duplicate-function-elimination.wast @@ -0,0 +1,702 @@ +(module + (func $erase + (nop) + ) + (func $other + (nop) + ) +) +(module + (func $keep2 + (i32.const 0) + ) + (func $other + (nop) + ) +) +(module + (func $erase + (i32.const 0) + ) + (func $other + (i32.const 0) + ) +) +(module + (func $keep2 + (i32.const 0) + ) + (func $other + (i32.const 1) + ) +) +(module + (export "keep2" $keep2) + (export "other" $other) + (start $other) + (table $keep2 $other $caller) + (func $keep2 + (nop) + ) + (func $other + (nop) + ) + (func $caller + (call $keep2) + (call $other) + ) +) +(module + (func $keep2-after-two-passes + (nop) + ) + (func $other + (nop) + ) + (func $keep-caller + (call $keep2-after-two-passes) + ) + (func $other-caller + (call $other) + ) +) +(module + (func $keep-4 + (nop) + ) + (func $other + (unreachable) + ) + (func $keep-caller + (call $keep-4) + ) + (func $other-caller + (call $other) + ) +) +(module + (type T (func (result i32))) + (type S (func (result i32))) + (func $keep4-similar-but-func-sig-differs + (i32.const 0) + ) + (func $other1 (param $i i32) + (i32.const 0) + ) + (func $other2 (type $T) (result i32) + (i32.const 0) + ) + (func $other3 (type $S) (result i32) + (i32.const 0) + ) +) +(module + (type S (func (result i32))) + (func $keep2-similar-but-func-sig-differs (param $i i32) + (i32.const 0) + ) + (func $other1 (param $i i32) + (i32.const 0) + ) + (func $other2 (type $S) (result i32) + (i32.const 0) + ) + (func $other3 (type $S) (result i32) + (i32.const 0) + ) +) +;; hashing tests for expressions +(module + (func $keep2 + (nop) + ) + (func $other + (nop) + (nop) + ) +) +(module + (func $erase + (block) + ) + (func $other + (block) + ) +) +(module + (func $keep2 + (block) + ) + (func $other + (block (nop)) + ) +) +(module + (func $erase + (block (nop)) + ) + (func $other + (block (nop)) + ) +) +(module + (func $keep2 + (block (nop)) + ) + (func $other + (block (nop) (unreachable)) + ) +) +(module + (func $keep2 + (block (nop)) + ) + (func $other + (block (unreachable)) + ) +) +(module + (func $erase-since-block-names-do-not-matter + (block $foo) + ) + (func $other + (block $bar) + ) +) +(module + (func $erase-since-block-names-do-not-matter + (block $foo + (br $foo) + (br_table $foo $foo (i32.const 0)) + ) + ) + (func $other + (block $bar + (br $bar) + (br_table $bar $bar (i32.const 0)) + ) + ) +) +(module + (func $keep2 + (block $foo + (br $foo (i32.const 0)) + ) + ) + (func $other + (block $bar + (br $bar (i32.const 1)) + ) + ) +) +(module + (func $keep2 + (block $foo + (br_if $foo (i32.const 0)) + ) + ) + (func $other + (block $bar + (br_if $bar (i32.const 1)) + ) + ) +) +(module + (func $erase + (block $foo + (br_if $foo (i32.const 0)) + ) + ) + (func $other + (block $bar + (br_if $bar (i32.const 0)) + ) + ) +) +(module + (func $keep2 + (block $foo + (br_table $foo $foo (i32.const 0)) + ) + ) + (func $other + (block $bar + (br_table $bar $bar (i32.const 1)) + ) + ) +) +(module + (func $erase + (loop $foo $bar) + ) + (func $other + (loop $sfo $sjc) + ) +) +(module + (func $keep2 + (block $foo + (br_table $foo $foo (i32.const 0) (i32.const 0)) + ) + ) + (func $other + (block $bar + (br_table $bar $bar (i32.const 0) (i32.const 1)) + ) + ) +) +(module + (func $keep2 + (block $foo + (block $bar + (br_table $foo $bar (i32.const 0)) + ) + ) + ) + (func $other + (block $bar + (block $foo + (br_table $bar $foo (i32.const 0)) + ) + ) + ) +) +(module + (func $erase + (block $foo + (block $bar + (br_table $foo $bar (i32.const 0)) + ) + ) + ) + (func $other + (block $bar + (block $foo + (br_table $foo $bar (i32.const 0)) + ) + ) + ) +) +(module + (func $erase + (call $erase) + ) + (func $other + (call $erase) + ) +) +(module + (func $keep2-but-in-theory-we-could-erase ;; TODO FIXME + (call $keep2-but-in-theory-we-could-erase) + ) + (func $other + (call $other) + ) +) +(module + (import $i "env" "i") + (import $i "env" "j") + (func $erase + (call_import $i) + ) + (func $other + (call_import $i) + ) +) +(module + (import $i "env" "i") + (import $j "env" "j") + (func $keep2 + (call_import $i) + ) + (func $other + (call_import $j) + ) +) +(module + (type T (func)) + (table $erase $other) + (func $erase + (call_indirect $T (i32.const 0)) + ) + (func $other + (call_indirect $T (i32.const 0)) + ) +) +(module + (type T (func)) + (table $keep2 $other) + (func $keep2 + (call_indirect $T (i32.const 0)) + ) + (func $other + (call_indirect $T (i32.const 1)) + ) +) +(module + (type T (func)) + (type S (func)) + (table $keep2 $other) + (func $keep2 + (call_indirect $T (i32.const 0)) + ) + (func $other + (call_indirect $S (i32.const 0)) + ) +) +(module + (func $erase-even-locals-with-different-names + (local $i i32) + (get_local $i) + ) + (func $other + (local $j i32) + (get_local $j) + ) +) +(module + (func $keep2 + (local $i i32) + (get_local $i) + ) + (func $other + (local $j i64) + (get_local $j) + ) +) +(module + (func $erase-even-locals-with-different-names + (local $i i32) + (set_local $i (i32.const 0)) + ) + (func $other + (local $j i32) + (set_local $j (i32.const 0)) + ) +) +(module + (func $keep2 + (local $i i32) + (set_local $i (i32.const 0)) + ) + (func $other + (local $j i64) + (set_local $j (i64.const 0)) + ) +) +(module + (func $keep2 + (local $i i32) + (set_local $i (i32.const 0)) + ) + (func $other + (local $j i32) + (set_local $j (i32.const 1)) + ) +) +(module + (memory 10) + (func $erase + (i32.load (i32.const 0)) + (i32.load8_s align=2 offset=3 (i32.const 0)) + ) + (func $other + (i32.load (i32.const 0)) + (i32.load8_s align=2 offset=3 (i32.const 0)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load16_s align=2 offset=3 (i32.const 0)) + ) + (func $other + (i32.load8_s align=2 offset=3 (i32.const 0)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load8_s offset=3 (i32.const 0)) + ) + (func $other + (i32.load8_s align=2 offset=3 (i32.const 0)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load8_s align=2 (i32.const 0)) + ) + (func $other + (i32.load8_s align=2 offset=3 (i32.const 0)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load8_s align=2 offset=3 (i32.const 0)) + ) + (func $other + (i32.load8_s align=2 offset=3 (i32.const 1)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.load8_u align=2 offset=3 (i32.const 0)) + ) + (func $other + (i32.load8_s align=2 offset=3 (i32.const 0)) + ) +) + +(module + (memory 10) + (func $erase + (i32.store (i32.const 0) (i32.const 100)) + (i32.store8 align=2 offset=3 (i32.const 0) (i32.const 100)) + ) + (func $other + (i32.store (i32.const 0) (i32.const 100)) + (i32.store8 align=2 offset=3 (i32.const 0) (i32.const 100)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store16 align=2 offset=3 (i32.const 0) (i32.const 100)) + ) + (func $other + (i32.store8 align=2 offset=3 (i32.const 0) (i32.const 100)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store8 offset=3 (i32.const 0) (i32.const 100)) + ) + (func $other + (i32.store8 align=2 offset=3 (i32.const 0) (i32.const 100)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store8 align=2 (i32.const 0) (i32.const 100)) + ) + (func $other + (i32.store8 align=2 offset=3 (i32.const 0) (i32.const 100)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store8 align=2 offset=3 (i32.const 0) (i32.const 100)) + ) + (func $other + (i32.store8 align=2 offset=3 (i32.const 1) (i32.const 100)) + ) +) +(module + (memory 10) + (func $keep2 + (i32.store8 align=2 offset=3 (i32.const 0) (i32.const 100)) + ) + (func $other + (i32.store8 align=2 offset=3 (i32.const 0) (i32.const 101)) + ) +) +(module + (func $keep2 + (i32.const 0) + ) + (func $other + (i64.const 0) + ) +) +(module + (func $keep2 + (i32.const 0) + ) + (func $other + (f32.const 0) + ) +) +(module + (func $keep2 + (i32.const 0) + ) + (func $other + (f64.const 0) + ) +) +(module + (func $keep2 + (i64.const 0) + ) + (func $other + (i64.const 1) + ) +) +(module + (func $keep2 + (f32.const 0.1) + ) + (func $other + (f32.const -0.1) + ) +) +(module + (func $keep2 + (f64.const 0.1) + ) + (func $other + (f64.const 0.2) + ) +) +(module + (func $erase + (f32.abs (f32.const 0)) + ) + (func $other + (f32.abs (f32.const 0)) + ) +) +(module + (func $keep2 + (f32.abs (f32.const 0)) + ) + (func $other + (f32.abs (f32.const 1)) + ) +) +(module + (func $keep2 + (f32.abs (f32.const 0)) + ) + (func $other + (f32.neg (f32.const 0)) + ) +) +(module + (func $erase + (f32.add (f32.const 0) (f32.const 0)) + ) + (func $other + (f32.add (f32.const 0) (f32.const 0)) + ) +) +(module + (func $keep2 + (f32.add (f32.const 0) (f32.const 0)) + ) + (func $other + (f32.add (f32.const 0) (f32.const 1)) + ) +) +(module + (func $keep2 + (f32.add (f32.const 0) (f32.const 0)) + ) + (func $other + (f32.add (f32.const 1) (f32.const 0)) + ) +) +(module + (func $keep2 + (f32.add (f32.const 0) (f32.const 0)) + ) + (func $other + (f32.sub (f32.const 0) (f32.const 0)) + ) +) +(module + (func $erase + (select (i32.const 0) (i32.const 0) (i32.const 0)) + ) + (func $other + (select (i32.const 0) (i32.const 0) (i32.const 0)) + ) +) +(module + (func $keep + (select (i32.const 0) (i32.const 0) (i32.const 0)) + ) + (func $other + (select (i32.const 1) (i32.const 0) (i32.const 0)) + ) +) +(module + (func $keep + (select (i32.const 0) (i32.const 0) (i32.const 0)) + ) + (func $other + (select (i32.const 0) (i32.const 2) (i32.const 0)) + ) +) +(module + (func $keep + (select (i32.const 0) (i32.const 0) (i32.const 0)) + ) + (func $other + (select (i32.const 0) (i32.const 0) (i32.const 3)) + ) +) +(module + (func $erase + (return) + ) + (func $other + (return) + ) +) +(module + (func $erase (result i32) + (return (i32.const 0)) + ) + (func $other (result i32) + (return (i32.const 0)) + ) +) +(module + (func $keep (result i32) + (return (i32.const 0)) + ) + (func $other (result i32) + (return (i32.const 1)) + ) +) +(module + (func $erase + (current_memory) + ) + (func $other + (current_memory) + ) +) +(module + (func $erase + (grow_memory (i32.const 10)) + ) + (func $other + (grow_memory (i32.const 10)) + ) +) +(module + (func $keep + (grow_memory (i32.const 10)) + ) + (func $other + (grow_memory (i32.const 11)) + ) +) +(module + (func $keep + (current_memory) + ) + (func $other + (grow_memory (i32.const 10)) + ) +) + diff --git a/test/passes/metrics.txt b/test/passes/metrics.txt index e1f67c583..9668954e3 100644 --- a/test/passes/metrics.txt +++ b/test/passes/metrics.txt @@ -1,4 +1,5 @@ Counts + [funcs] : 1 [total] : 18 [vars] : 1 binary : 1 diff --git a/test/unit.fromasm b/test/unit.fromasm index f828c415a..288b3af3b 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -11,7 +11,7 @@ (import $f64-to-int "asm2wasm" "f64-to-int" (param f64) (result i32)) (import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64)) (export "big_negative" $big_negative) - (table $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) + (table $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg) (func $big_negative (nop) ) @@ -87,27 +87,21 @@ (get_local $0) ) ) - (func $hexLiterals - (nop) - ) (func $conversions - (local $0 i32) - (local $1 f64) - (local $2 f32) + (local $0 f64) + (local $1 f32) + (local $2 i32) (call_import $f64-to-int - (get_local $1) + (get_local $0) ) - (set_local $0 + (set_local $2 (call_import $f64-to-int (f64.promote/f32 - (get_local $2) + (get_local $1) ) ) ) ) - (func $seq - (nop) - ) (func $switcher (param $0 i32) (result i32) (block $switch-default$3 (block $switch-case$2 @@ -205,9 +199,6 @@ ) (i32.const 0) ) - (func $blocker - (nop) - ) (func $frem (result f64) (call_import $f64-rem (f64.const 5.5) @@ -229,9 +220,6 @@ (func $negZero (result f64) (f64.const -0) ) - (func $abs - (nop) - ) (func $neg (local $0 f32) (call_indirect $FUNCSIG$vf @@ -259,9 +247,6 @@ (get_local $0) ) ) - (func $___syscall_ret - (nop) - ) (func $smallCompare (result i32) (local $0 i32) (local $1 i32) @@ -439,10 +424,4 @@ ) (i32.const 0) ) - (func $z - (nop) - ) - (func $w - (nop) - ) ) diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index 1bb1ae485..303a0cabf 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -9,7 +9,7 @@ (import $h "env" "h" (param i32)) (import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64)) (export "big_negative" $big_negative) - (table $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) + (table $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg) (func $big_negative (nop) ) @@ -85,21 +85,15 @@ (get_local $0) ) ) - (func $hexLiterals - (nop) - ) (func $conversions - (local $0 i32) - (local $1 f32) - (set_local $0 + (local $0 f32) + (local $1 i32) + (set_local $1 (i32.trunc_s/f32 - (get_local $1) + (get_local $0) ) ) ) - (func $seq - (nop) - ) (func $switcher (param $0 i32) (result i32) (block $switch-default$3 (block $switch-case$2 @@ -197,9 +191,6 @@ ) (i32.const 0) ) - (func $blocker - (nop) - ) (func $frem (result f64) (call_import $f64-rem (f64.const 5.5) @@ -221,9 +212,6 @@ (func $negZero (result f64) (f64.const -0) ) - (func $abs - (nop) - ) (func $neg (local $0 f32) (call_indirect $FUNCSIG$vf @@ -251,9 +239,6 @@ (get_local $0) ) ) - (func $___syscall_ret - (nop) - ) (func $smallCompare (result i32) (local $0 i32) (local $1 i32) @@ -431,10 +416,4 @@ ) (i32.const 0) ) - (func $z - (nop) - ) - (func $w - (nop) - ) ) |