diff --git a/src/passes/CMakeLists.txt b/src/passes/CMakeLists.txt index 9a3e1738e93..df4168cb966 100644 --- a/src/passes/CMakeLists.txt +++ b/src/passes/CMakeLists.txt @@ -91,7 +91,6 @@ set(passes_SOURCES Precompute.cpp Print.cpp PrintBoundary.cpp - PrintCallGraph.cpp PrintFeatures.cpp PrintFunctionMap.cpp RoundTrip.cpp diff --git a/src/passes/GlobalEffects.cpp b/src/passes/GlobalEffects.cpp index 720752372aa..a00d78d4226 100644 --- a/src/passes/GlobalEffects.cpp +++ b/src/passes/GlobalEffects.cpp @@ -27,6 +27,9 @@ #include "support/utilities.h" #include "wasm.h" +#include +#include + namespace wasm { namespace { @@ -369,8 +372,89 @@ struct DiscardGlobalEffects : public Pass { } }; +struct PrintCallGraph : public Pass { + bool modifiesBinaryenIR() override { return false; } + + void run(Module* module) override { + std::map funcInfos = + analyzeFuncs(*module, getPassOptions()); + + auto callGraph = + buildCallGraph(*module, funcInfos, getPassOptions().worldMode); + + printCallGraph(callGraph, std::cout); + } + +private: + std::string nodeToString(const CallGraphNode& node) { + return std::visit( + overloaded{[](Function* func) { return func->name.toString(); }, + [](HeapType type) { + std::stringstream ss; + ss << type; + return ss.str(); + }}, + node); + } + + void printCallGraph(const CallGraph& callGraph, std::ostream& o) { + std::map nodeTypes; + std::map> sortedGraph; + + auto getNodeType = [](const CallGraphNode& node) { + return std::visit(overloaded{[](Function*) { return "function"; }, + [](HeapType) { return "type"; }}, + node); + }; + + for (const auto& [caller, callees] : callGraph) { + std::string callerName = nodeToString(caller); + nodeTypes[callerName] = getNodeType(caller); + + for (const auto& callee : callees) { + std::string calleeName = nodeToString(callee); + nodeTypes[calleeName] = getNodeType(callee); + + std::string style = std::visit( + overloaded{ + [](Function*, Function*) { + return " [style=\"solid\", color=\"black\", kind=\"direct\"]"; + }, + [](Function*, HeapType) { + return " [style=\"dotted\", color=\"black\", kind=\"indirect\"]"; + }, + [](HeapType, HeapType) { + return " [style=\"solid\", color=\"blue\", kind=\"subtyping\"]"; + }, + [](HeapType, Function*) { + return " [style=\"dashed\", color=\"green\", " + "kind=\"implementation\"]"; + }}, + caller, + callee); + + sortedGraph[callerName][calleeName] = style; + } + } + + o << "digraph CallGraph {\n"; + for (const auto& [nodeName, nodeType] : nodeTypes) { + o << " \"" << nodeName << "\" [kind=\"" << nodeType << "\"];\n"; + } + for (const auto& [callerName, callees] : sortedGraph) { + for (const auto& [calleeName, style] : callees) { + o << " \"" << callerName << "\" -> \"" << calleeName << "\"" << style + << ";\n"; + } + } + o << "}\n"; + } +}; + } // namespace +Pass* createPrintCallGraphPass() { return new PrintCallGraph(); } + Pass* createGenerateGlobalEffectsPass() { return new GenerateGlobalEffects(); } Pass* createDiscardGlobalEffectsPass() { return new DiscardGlobalEffects(); } diff --git a/src/passes/PrintCallGraph.cpp b/src/passes/PrintCallGraph.cpp deleted file mode 100644 index 27095726f53..00000000000 --- a/src/passes/PrintCallGraph.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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. - */ - -// -// Prints the call graph in .dot format. You can use http://www.graphviz.org/ to -// view .dot files. -// - -#include -#include - -#include "ir/element-utils.h" -#include "ir/module-utils.h" -#include "ir/utils.h" -#include "pass.h" -#include "wasm.h" - -namespace wasm { - -struct PrintCallGraph : public Pass { - bool modifiesBinaryenIR() override { return false; } - - void run(Module* module) override { - std::ostream& o = std::cout; - o << "digraph call {\n" - " rankdir = LR;\n" - " subgraph cluster_key {\n" - " node [shape=box, fontname=courier, fontsize=10];\n" - " edge [fontname=courier, fontsize=10];\n" - " label = \"Key\";\n" - " \"Import\" [style=\"filled\", fillcolor=\"turquoise\"];\n" - " \"Export\" [style=\"filled\", fillcolor=\"gray\"];\n" - " \"Indirect Target\" [style=\"filled, rounded\", " - "fillcolor=\"white\"];\n" - " \"A\" -> \"B\" [style=\"filled, rounded\", label = \"Direct " - "Call\"];\n" - " }\n\n" - " node [shape=box, fontname=courier, fontsize=10];\n"; - - // Defined functions - ModuleUtils::iterDefinedFunctions(*module, [&](Function* curr) { - std::cout << " \"" << curr->name - << "\" [style=\"filled\", fillcolor=\"white\"];\n"; - }); - - // Imported functions - ModuleUtils::iterImportedFunctions(*module, [&](Function* curr) { - o << " \"" << curr->name - << "\" [style=\"filled\", fillcolor=\"turquoise\"];\n"; - }); - - // Exports - for (auto& curr : module->exports) { - if (curr->kind == ExternalKind::Function) { - Function* func = module->getFunction(*curr->getInternalName()); - o << " \"" << func->name - << "\" [style=\"filled\", fillcolor=\"gray\"];\n"; - } - } - - struct CallPrinter : public PostWalker { - Module* module; - Function* currFunction; - std::set visitedTargets; // Used to avoid printing duplicate edges. - std::vector allIndirectTargets; - CallPrinter(Module* module) : module(module) { - // Walk function bodies. - ModuleUtils::iterDefinedFunctions(*module, [&](Function* curr) { - currFunction = curr; - visitedTargets.clear(); - walk(curr->body); - }); - } - void visitCall(Call* curr) { - auto* target = module->getFunction(curr->target); - if (!visitedTargets.emplace(target->name).second) { - return; - } - std::cout << " \"" << currFunction->name << "\" -> \"" << target->name - << "\"; // call\n"; - } - }; - CallPrinter printer(module); - - // Indirect Targets - ElementUtils::iterAllElementFunctionNames(module, [&](Name name) { - auto* func = module->getFunction(name); - o << " \"" << func->name << "\" [style=\"filled, rounded\"];\n"; - }); - - o << "}\n"; - } -}; - -Pass* createPrintCallGraphPass() { return new PrintCallGraph(); } - -} // namespace wasm diff --git a/test/lit/passes/print-call-graph.wast b/test/lit/passes/print-call-graph.wast new file mode 100644 index 00000000000..58d6e40cdc2 --- /dev/null +++ b/test/lit/passes/print-call-graph.wast @@ -0,0 +1,88 @@ +;; RUN: foreach %s %t wasm-opt -all --print-call-graph | filecheck %s +;; RUN: foreach %s %t wasm-opt -all --print-call-graph --closed-world | filecheck %s --check-prefix CLOSED + +(module + (type $indirect-type (func (param i32))) + + (table 1 1 funcref) + (elem $indirect-1 (i32.const 0)) + + (func $indirect-1 (type $indirect-type) (param i32) + ) + + (func $indirect-2 (type $indirect-type) (param i32) + ) + + (func $A (param $ref (ref $indirect-type)) + (call_ref $indirect-type (i32.const 42) (local.get $ref)) + (call $B (local.get $ref)) + ) + + (func $B (param $ref (ref $indirect-type)) + (call_indirect (type $indirect-type) (i32.const 0) (i32.const 0)) + ) +) + +;; CHECK: digraph CallGraph { +;; CHECK-NEXT: "A" [kind="function"]; +;; CHECK-NEXT: "B" [kind="function"]; +;; CHECK-NEXT: "indirect-1" [kind="function"]; +;; CHECK-NEXT: "indirect-2" [kind="function"]; +;; CHECK-NEXT: "A" -> "B" [style="solid", color="black", kind="direct"]; +;; CHECK-NEXT: } + +;; CLOSED: digraph CallGraph { +;; CLOSED-NEXT: "(type $func.0 (func (param (ref $func.1))))" [kind="type"]; +;; CLOSED-NEXT: "(type $func.0 (func (param i32)))" [kind="type"]; +;; CLOSED-NEXT: "A" [kind="function"]; +;; CLOSED-NEXT: "B" [kind="function"]; +;; CLOSED-NEXT: "indirect-1" [kind="function"]; +;; CLOSED-NEXT: "indirect-2" [kind="function"]; +;; CLOSED-NEXT: "(type $func.0 (func (param (ref $func.1))))" -> "A" [style="dashed", color="green", kind="implementation"]; +;; CLOSED-NEXT: "(type $func.0 (func (param (ref $func.1))))" -> "B" [style="dashed", color="green", kind="implementation"]; +;; CLOSED-NEXT: "(type $func.0 (func (param i32)))" -> "indirect-1" [style="dashed", color="green", kind="implementation"]; +;; CLOSED-NEXT: "(type $func.0 (func (param i32)))" -> "indirect-2" [style="dashed", color="green", kind="implementation"]; +;; CLOSED-NEXT: "A" -> "(type $func.0 (func (param i32)))" [style="dotted", color="black", kind="indirect"]; +;; CLOSED-NEXT: "A" -> "B" [style="solid", color="black", kind="direct"]; +;; CLOSED-NEXT: "B" -> "(type $func.0 (func (param i32)))" [style="dotted", color="black", kind="indirect"]; +;; CLOSED-NEXT: } + +;; Test cycles +(module + (type $indirect-type (func (param i32))) + (table 1 1 funcref) + + (func $A + (call $B) + ) + (func $B + (call $A) + ) + + (func $indirect-cycle (type $indirect-type) (param $x i32) + (call_indirect (type $indirect-type) (local.get $x) (i32.const 0)) + ) + (elem $indirect-cycle (i32.const 0)) +) + +;; CHECK: digraph CallGraph { +;; CHECK-NEXT: "A" [kind="function"]; +;; CHECK-NEXT: "B" [kind="function"]; +;; CHECK-NEXT: "indirect-cycle" [kind="function"]; +;; CHECK-NEXT: "A" -> "B" [style="solid", color="black", kind="direct"]; +;; CHECK-NEXT: "B" -> "A" [style="solid", color="black", kind="direct"]; +;; CHECK-NEXT: } + +;; CLOSED: digraph CallGraph { +;; CLOSED-NEXT: "(type $func.0 (func (param i32)))" [kind="type"]; +;; CLOSED-NEXT: "(type $func.0 (func))" [kind="type"]; +;; CLOSED-NEXT: "A" [kind="function"]; +;; CLOSED-NEXT: "B" [kind="function"]; +;; CLOSED-NEXT: "indirect-cycle" [kind="function"]; +;; CLOSED-NEXT: "(type $func.0 (func (param i32)))" -> "indirect-cycle" [style="dashed", color="green", kind="implementation"]; +;; CLOSED-NEXT: "(type $func.0 (func))" -> "A" [style="dashed", color="green", kind="implementation"]; +;; CLOSED-NEXT: "(type $func.0 (func))" -> "B" [style="dashed", color="green", kind="implementation"]; +;; CLOSED-NEXT: "A" -> "B" [style="solid", color="black", kind="direct"]; +;; CLOSED-NEXT: "B" -> "A" [style="solid", color="black", kind="direct"]; +;; CLOSED-NEXT: "indirect-cycle" -> "(type $func.0 (func (param i32)))" [style="dotted", color="black", kind="indirect"]; +;; CLOSED-NEXT: } diff --git a/test/passes/print-call-graph.txt b/test/passes/print-call-graph.txt deleted file mode 100644 index b6ec339b79e..00000000000 --- a/test/passes/print-call-graph.txt +++ /dev/null @@ -1,1535 +0,0 @@ -digraph call { - rankdir = LR; - subgraph cluster_key { - node [shape=box, fontname=courier, fontsize=10]; - edge [fontname=courier, fontsize=10]; - label = "Key"; - "Import" [style="filled", fillcolor="turquoise"]; - "Export" [style="filled", fillcolor="gray"]; - "Indirect Target" [style="filled, rounded", fillcolor="white"]; - "A" -> "B" [style="filled, rounded", label = "Direct Call"]; - } - - node [shape=box, fontname=courier, fontsize=10]; - "stackAlloc" [style="filled", fillcolor="white"]; - "stackSave" [style="filled", fillcolor="white"]; - "stackRestore" [style="filled", fillcolor="white"]; - "establishStackSpace" [style="filled", fillcolor="white"]; - "setThrew" [style="filled", fillcolor="white"]; - "setTempRet0" [style="filled", fillcolor="white"]; - "getTempRet0" [style="filled", fillcolor="white"]; - "_malloc" [style="filled", fillcolor="white"]; - "_free" [style="filled", fillcolor="white"]; - "_main" [style="filled", fillcolor="white"]; - "___stdio_close" [style="filled", fillcolor="white"]; - "___stdio_write" [style="filled", fillcolor="white"]; - "___stdio_seek" [style="filled", fillcolor="white"]; - "___syscall_ret" [style="filled", fillcolor="white"]; - "___errno_location" [style="filled", fillcolor="white"]; - "_cleanup_387" [style="filled", fillcolor="white"]; - "___stdout_write" [style="filled", fillcolor="white"]; - "_fflush" [style="filled", fillcolor="white"]; - "___fflush_unlocked" [style="filled", fillcolor="white"]; - "__Znwj" [style="filled", fillcolor="white"]; - "__ZSt15get_new_handlerv" [style="filled", fillcolor="white"]; - "runPostSets" [style="filled", fillcolor="white"]; - "_memset" [style="filled", fillcolor="white"]; - "_memcpy" [style="filled", fillcolor="white"]; - "_pthread_self" [style="filled", fillcolor="white"]; - "dynCall_ii" [style="filled", fillcolor="white"]; - "dynCall_iiii" [style="filled", fillcolor="white"]; - "dynCall_vi" [style="filled", fillcolor="white"]; - "dynCall_v" [style="filled", fillcolor="white"]; - "b0" [style="filled", fillcolor="white"]; - "b1" [style="filled", fillcolor="white"]; - "b2" [style="filled", fillcolor="white"]; - "b3" [style="filled", fillcolor="white"]; - "abort" [style="filled", fillcolor="turquoise"]; - "_pthread_cleanup_pop" [style="filled", fillcolor="turquoise"]; - "___lock" [style="filled", fillcolor="turquoise"]; - "___syscall6" [style="filled", fillcolor="turquoise"]; - "_pthread_cleanup_push" [style="filled", fillcolor="turquoise"]; - "___syscall140" [style="filled", fillcolor="turquoise"]; - "_emscripten_memcpy_big" [style="filled", fillcolor="turquoise"]; - "___syscall54" [style="filled", fillcolor="turquoise"]; - "___unlock" [style="filled", fillcolor="turquoise"]; - "___syscall146" [style="filled", fillcolor="turquoise"]; - "_fflush" [style="filled", fillcolor="gray"]; - "_main" [style="filled", fillcolor="gray"]; - "_pthread_self" [style="filled", fillcolor="gray"]; - "_memset" [style="filled", fillcolor="gray"]; - "_malloc" [style="filled", fillcolor="gray"]; - "_memcpy" [style="filled", fillcolor="gray"]; - "_free" [style="filled", fillcolor="gray"]; - "___errno_location" [style="filled", fillcolor="gray"]; - "runPostSets" [style="filled", fillcolor="gray"]; - "stackAlloc" [style="filled", fillcolor="gray"]; - "stackSave" [style="filled", fillcolor="gray"]; - "stackRestore" [style="filled", fillcolor="gray"]; - "establishStackSpace" [style="filled", fillcolor="gray"]; - "setThrew" [style="filled", fillcolor="gray"]; - "setTempRet0" [style="filled", fillcolor="gray"]; - "getTempRet0" [style="filled", fillcolor="gray"]; - "dynCall_ii" [style="filled", fillcolor="gray"]; - "dynCall_iiii" [style="filled", fillcolor="gray"]; - "dynCall_vi" [style="filled", fillcolor="gray"]; - "dynCall_v" [style="filled", fillcolor="gray"]; - "_main" -> "__Znwj"; // call - "___stdio_close" -> "___syscall6"; // call - "___stdio_close" -> "___syscall_ret"; // call - "___stdio_write" -> "_pthread_cleanup_push"; // call - "___stdio_write" -> "___syscall146"; // call - "___stdio_write" -> "___syscall_ret"; // call - "___stdio_write" -> "_pthread_cleanup_pop"; // call - "___stdio_seek" -> "___syscall140"; // call - "___stdio_seek" -> "___syscall_ret"; // call - "___syscall_ret" -> "___errno_location"; // call - "___errno_location" -> "_pthread_self"; // call - "_cleanup_387" -> "_free"; // call - "___stdout_write" -> "___syscall54"; // call - "___stdout_write" -> "___stdio_write"; // call - "_fflush" -> "___fflush_unlocked"; // call - "_fflush" -> "_malloc"; // call - "_fflush" -> "_free"; // call - "_fflush" -> "_fflush"; // call - "_fflush" -> "___lock"; // call - "_fflush" -> "___unlock"; // call - "__Znwj" -> "_malloc"; // call - "__Znwj" -> "__ZSt15get_new_handlerv"; // call - "_memcpy" -> "_emscripten_memcpy_big"; // call - "b0" -> "abort"; // call - "b1" -> "abort"; // call - "b2" -> "abort"; // call - "b3" -> "abort"; // call - "b0" [style="filled, rounded"]; - "___stdio_close" [style="filled, rounded"]; - "b1" [style="filled, rounded"]; - "___stdout_write" [style="filled, rounded"]; - "___stdio_seek" [style="filled, rounded"]; - "___stdio_write" [style="filled, rounded"]; - "b2" [style="filled, rounded"]; - "_cleanup_387" [style="filled, rounded"]; - "b3" [style="filled, rounded"]; -} -(module - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $3 (func (result i32))) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$v (func)) - (type $7 (func (param i32 i32 i32 i32) (result i32))) - (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table $timport$0 9 9 funcref)) - (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) - (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) - (import "env" "ABORT" (global $ABORT$asm2wasm$import i32)) - (import "global" "NaN" (global $nan$asm2wasm$import f64)) - (import "global" "Infinity" (global $inf$asm2wasm$import f64)) - (import "env" "memoryBase" (global $memoryBase i32)) - (import "env" "tableBase" (global $tableBase i32)) - (import "env" "abort" (func $abort (param i32))) - (import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32))) - (import "env" "___lock" (func $___lock (param i32))) - (import "env" "___syscall6" (func $___syscall6 (param i32 i32) (result i32))) - (import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32))) - (import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32))) - (import "env" "_emscripten_memcpy_big" (func $_emscripten_memcpy_big (param i32 i32 i32) (result i32))) - (import "env" "___syscall54" (func $___syscall54 (param i32 i32) (result i32))) - (import "env" "___unlock" (func $___unlock (param i32))) - (import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32))) - (global $STACKTOP (mut i32) (global.get $STACKTOP$asm2wasm$import)) - (global $STACK_MAX (mut i32) (global.get $STACK_MAX$asm2wasm$import)) - (global $ABORT (mut i32) (global.get $ABORT$asm2wasm$import)) - (global $__THREW__ (mut i32) (i32.const 0)) - (global $threwValue (mut i32) (i32.const 0)) - (global $setjmpId (mut i32) (i32.const 0)) - (global $undef (mut i32) (i32.const 0)) - (global $nan (mut f64) (global.get $nan$asm2wasm$import)) - (global $inf (mut f64) (global.get $inf$asm2wasm$import)) - (global $tempInt (mut i32) (i32.const 0)) - (global $tempBigInt (mut i32) (i32.const 0)) - (global $tempBigIntP (mut i32) (i32.const 0)) - (global $tempBigIntS (mut i32) (i32.const 0)) - (global $tempBigIntR (mut f64) (f64.const 0)) - (global $tempBigIntI (mut i32) (i32.const 0)) - (global $tempBigIntD (mut i32) (i32.const 0)) - (global $tempValue (mut i32) (i32.const 0)) - (global $tempDouble (mut f64) (f64.const 0)) - (global $tempRet0 (mut i32) (i32.const 0)) - (global $tempFloat (mut f32) (f32.const 0)) - (global $f0 (mut f32) (f32.const 0)) - (data $0 (global.get $memoryBase) "\05\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00\b0\04\00\00\00\04\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\n\ff\ff\ff\ff\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\04") - (elem $0 (i32.const 0) $b0 $___stdio_close $b1 $___stdout_write $___stdio_seek $___stdio_write $b2 $_cleanup_387 $b3) - (export "_fflush" (func $_fflush)) - (export "_main" (func $_main)) - (export "_pthread_self" (func $_pthread_self)) - (export "_memset" (func $_memset)) - (export "_malloc" (func $_malloc)) - (export "_memcpy" (func $_memcpy)) - (export "_free" (func $_free)) - (export "___errno_location" (func $___errno_location)) - (export "runPostSets" (func $runPostSets)) - (export "stackAlloc" (func $stackAlloc)) - (export "stackSave" (func $stackSave)) - (export "stackRestore" (func $stackRestore)) - (export "establishStackSpace" (func $establishStackSpace)) - (export "setThrew" (func $setThrew)) - (export "setTempRet0" (func $setTempRet0)) - (export "getTempRet0" (func $getTempRet0)) - (export "dynCall_ii" (func $dynCall_ii)) - (export "dynCall_iiii" (func $dynCall_iiii)) - (export "dynCall_vi" (func $dynCall_vi)) - (export "dynCall_v" (func $dynCall_v)) - (func $stackAlloc (param $0 i32) (result i32) - (local $1 i32) - (local.set $1 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (local.get $0) - ) - ) - (global.set $STACKTOP - (i32.and - (i32.add - (global.get $STACKTOP) - (i32.const 15) - ) - (i32.const -16) - ) - ) - (local.get $1) - ) - (func $stackSave (result i32) - (global.get $STACKTOP) - ) - (func $stackRestore (param $0 i32) - (global.set $STACKTOP - (local.get $0) - ) - ) - (func $establishStackSpace (param $0 i32) (param $1 i32) - (global.set $STACKTOP - (local.get $0) - ) - (global.set $STACK_MAX - (local.get $1) - ) - ) - (func $setThrew (param $0 i32) (param $1 i32) - (if - (i32.eqz - (global.get $__THREW__) - ) - (then - (global.set $__THREW__ - (local.get $0) - ) - (global.set $threwValue - (local.get $1) - ) - ) - ) - ) - (func $setTempRet0 (param $0 i32) - (global.set $tempRet0 - (local.get $0) - ) - ) - (func $getTempRet0 (result i32) - (global.get $tempRet0) - ) - (func $_malloc (param $0 i32) (result i32) - (i32.const 0) - ) - (func $_free (param $0 i32) - (nop) - ) - (func $_main (result i32) - (local $0 i32) - (i64.store align=4 - (local.tee $0 - (call $__Znwj - (i32.const 8) - ) - ) - (i64.const 0) - ) - (local.get $0) - ) - (func $___stdio_close (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local.set $1 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (i32.const 16) - ) - ) - (i32.store - (local.tee $2 - (local.get $1) - ) - (i32.load offset=60 - (local.get $0) - ) - ) - (local.set $0 - (call $___syscall_ret - (call $___syscall6 - (i32.const 6) - (local.get $2) - ) - ) - ) - (global.set $STACKTOP - (local.get $1) - ) - (local.get $0) - ) - (func $___stdio_write (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local.set $7 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (i32.const 48) - ) - ) - (local.set $8 - (i32.add - (local.get $7) - (i32.const 16) - ) - ) - (local.set $9 - (local.get $7) - ) - (i32.store - (local.tee $3 - (i32.add - (local.get $7) - (i32.const 32) - ) - ) - (local.tee $5 - (i32.load - (local.tee $6 - (i32.add - (local.get $0) - (i32.const 28) - ) - ) - ) - ) - ) - (i32.store offset=4 - (local.get $3) - (local.tee $4 - (i32.sub - (i32.load - (local.tee $10 - (i32.add - (local.get $0) - (i32.const 20) - ) - ) - ) - (local.get $5) - ) - ) - ) - (i32.store offset=8 - (local.get $3) - (local.get $1) - ) - (i32.store offset=12 - (local.get $3) - (local.get $2) - ) - (local.set $13 - (i32.add - (local.get $0) - (i32.const 60) - ) - ) - (local.set $14 - (i32.add - (local.get $0) - (i32.const 44) - ) - ) - (local.set $1 - (local.get $3) - ) - (local.set $5 - (i32.const 2) - ) - (local.set $11 - (i32.add - (local.get $4) - (local.get $2) - ) - ) - (local.set $0 - (block $jumpthreading$outer$1 (result i32) - (block $jumpthreading$inner$1 - (block $jumpthreading$inner$0 - (loop $while-in - (br_if $jumpthreading$inner$0 - (i32.eq - (local.get $11) - (local.tee $4 - (if (result i32) - (i32.load - (i32.const 1140) - ) - (then - (call $_pthread_cleanup_push - (i32.const 1) - (local.get $0) - ) - (i32.store - (local.get $9) - (i32.load - (local.get $13) - ) - ) - (i32.store offset=4 - (local.get $9) - (local.get $1) - ) - (i32.store offset=8 - (local.get $9) - (local.get $5) - ) - (local.set $3 - (call $___syscall_ret - (call $___syscall146 - (i32.const 146) - (local.get $9) - ) - ) - ) - (call $_pthread_cleanup_pop - (i32.const 0) - ) - (local.get $3) - ) - (else - (i32.store - (local.get $8) - (i32.load - (local.get $13) - ) - ) - (i32.store offset=4 - (local.get $8) - (local.get $1) - ) - (i32.store offset=8 - (local.get $8) - (local.get $5) - ) - (call $___syscall_ret - (call $___syscall146 - (i32.const 146) - (local.get $8) - ) - ) - ) - ) - ) - ) - ) - (br_if $jumpthreading$inner$1 - (i32.lt_s - (local.get $4) - (i32.const 0) - ) - ) - (local.set $11 - (i32.sub - (local.get $11) - (local.get $4) - ) - ) - (local.set $1 - (if (result i32) - (i32.gt_u - (local.get $4) - (local.tee $12 - (i32.load offset=4 - (local.get $1) - ) - ) - ) - (then - (i32.store - (local.get $6) - (local.tee $3 - (i32.load - (local.get $14) - ) - ) - ) - (i32.store - (local.get $10) - (local.get $3) - ) - (local.set $4 - (i32.sub - (local.get $4) - (local.get $12) - ) - ) - (local.set $3 - (i32.add - (local.get $1) - (i32.const 8) - ) - ) - (local.set $5 - (i32.add - (local.get $5) - (i32.const -1) - ) - ) - (i32.load offset=12 - (local.get $1) - ) - ) - (else - (if (result i32) - (i32.eq - (local.get $5) - (i32.const 2) - ) - (then - (i32.store - (local.get $6) - (i32.add - (i32.load - (local.get $6) - ) - (local.get $4) - ) - ) - (local.set $3 - (local.get $1) - ) - (local.set $5 - (i32.const 2) - ) - (local.get $12) - ) - (else - (local.set $3 - (local.get $1) - ) - (local.get $12) - ) - ) - ) - ) - ) - (i32.store - (local.get $3) - (i32.add - (i32.load - (local.get $3) - ) - (local.get $4) - ) - ) - (i32.store offset=4 - (local.get $3) - (i32.sub - (local.get $1) - (local.get $4) - ) - ) - (local.set $1 - (local.get $3) - ) - (br $while-in) - ) - ) - (i32.store offset=16 - (local.get $0) - (i32.add - (local.tee $1 - (i32.load - (local.get $14) - ) - ) - (i32.load offset=48 - (local.get $0) - ) - ) - ) - (i32.store - (local.get $6) - (local.tee $0 - (local.get $1) - ) - ) - (i32.store - (local.get $10) - (local.get $0) - ) - (br $jumpthreading$outer$1 - (local.get $2) - ) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (i32.store - (local.get $6) - (i32.const 0) - ) - (i32.store - (local.get $10) - (i32.const 0) - ) - (i32.store - (local.get $0) - (i32.or - (i32.load - (local.get $0) - ) - (i32.const 32) - ) - ) - (select - (i32.const 0) - (i32.sub - (local.get $2) - (i32.load offset=4 - (local.get $1) - ) - ) - (i32.eq - (local.get $5) - (i32.const 2) - ) - ) - ) - ) - (global.set $STACKTOP - (local.get $7) - ) - (local.get $0) - ) - (func $___stdio_seek (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local.set $4 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (i32.const 32) - ) - ) - (i32.store - (local.tee $3 - (local.get $4) - ) - (i32.load offset=60 - (local.get $0) - ) - ) - (i32.store offset=4 - (local.get $3) - (i32.const 0) - ) - (i32.store offset=8 - (local.get $3) - (local.get $1) - ) - (i32.store offset=12 - (local.get $3) - (local.tee $0 - (i32.add - (local.get $4) - (i32.const 20) - ) - ) - ) - (i32.store offset=16 - (local.get $3) - (local.get $2) - ) - (local.set $0 - (if (result i32) - (i32.lt_s - (call $___syscall_ret - (call $___syscall140 - (i32.const 140) - (local.get $3) - ) - ) - (i32.const 0) - ) - (then - (i32.store - (local.get $0) - (i32.const -1) - ) - (i32.const -1) - ) - (else - (i32.load - (local.get $0) - ) - ) - ) - ) - (global.set $STACKTOP - (local.get $4) - ) - (local.get $0) - ) - (func $___syscall_ret (param $0 i32) (result i32) - (if (result i32) - (i32.gt_u - (local.get $0) - (i32.const -4096) - ) - (then - (i32.store - (call $___errno_location) - (i32.sub - (i32.const 0) - (local.get $0) - ) - ) - (i32.const -1) - ) - (else - (local.get $0) - ) - ) - ) - (func $___errno_location (result i32) - (if (result i32) - (i32.load - (i32.const 1140) - ) - (then - (i32.load offset=64 - (call $_pthread_self) - ) - ) - (else - (i32.const 1184) - ) - ) - ) - (func $_cleanup_387 (param $0 i32) - (if - (i32.eqz - (i32.load offset=68 - (local.get $0) - ) - ) - (then - (call $_free - (local.get $0) - ) - ) - ) - ) - (func $___stdout_write (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local.set $4 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (i32.const 80) - ) - ) - (local.set $3 - (local.get $4) - ) - (local.set $5 - (i32.add - (local.get $4) - (i32.const 12) - ) - ) - (i32.store offset=36 - (local.get $0) - (i32.const 3) - ) - (if - (i32.eqz - (i32.and - (i32.load - (local.get $0) - ) - (i32.const 64) - ) - ) - (then - (i32.store - (local.get $3) - (i32.load offset=60 - (local.get $0) - ) - ) - (i32.store offset=4 - (local.get $3) - (i32.const 21505) - ) - (i32.store offset=8 - (local.get $3) - (local.get $5) - ) - (if - (call $___syscall54 - (i32.const 54) - (local.get $3) - ) - (then - (i32.store8 offset=75 - (local.get $0) - (i32.const -1) - ) - ) - ) - ) - ) - (local.set $0 - (call $___stdio_write - (local.get $0) - (local.get $1) - (local.get $2) - ) - ) - (global.set $STACKTOP - (local.get $4) - ) - (local.get $0) - ) - (func $_fflush (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (block $do-once (result i32) - (if (result i32) - (local.get $0) - (then - (if - (i32.le_s - (i32.load offset=76 - (local.get $0) - ) - (i32.const -1) - ) - (then - (br $do-once - (call $___fflush_unlocked - (local.get $0) - ) - ) - ) - ) - (local.set $2 - (i32.eqz - (call $_malloc - (local.get $0) - ) - ) - ) - (local.set $1 - (call $___fflush_unlocked - (local.get $0) - ) - ) - (if (result i32) - (local.get $2) - (then - (local.get $1) - ) - (else - (call $_free - (local.get $0) - ) - (local.get $1) - ) - ) - ) - (else - (local.set $0 - (if (result i32) - (i32.load - (i32.const 1136) - ) - (then - (call $_fflush - (i32.load - (i32.const 1136) - ) - ) - ) - (else - (i32.const 0) - ) - ) - ) - (call $___lock - (i32.const 1168) - ) - (if - (local.tee $1 - (i32.load - (i32.const 1164) - ) - ) - (then - (loop $while-in - (local.set $2 - (if (result i32) - (i32.gt_s - (i32.load offset=76 - (local.get $1) - ) - (i32.const -1) - ) - (then - (call $_malloc - (local.get $1) - ) - ) - (else - (i32.const 0) - ) - ) - ) - (local.set $0 - (if (result i32) - (i32.gt_u - (i32.load offset=20 - (local.get $1) - ) - (i32.load offset=28 - (local.get $1) - ) - ) - (then - (i32.or - (call $___fflush_unlocked - (local.get $1) - ) - (local.get $0) - ) - ) - (else - (local.get $0) - ) - ) - ) - (if - (local.get $2) - (then - (call $_free - (local.get $1) - ) - ) - ) - (br_if $while-in - (local.tee $1 - (i32.load offset=56 - (local.get $1) - ) - ) - ) - ) - ) - ) - (call $___unlock - (i32.const 1168) - ) - (local.get $0) - ) - ) - ) - ) - (func $___fflush_unlocked (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (block $jumpthreading$outer$0 (result i32) - (block $jumpthreading$inner$0 - (br_if $jumpthreading$inner$0 - (i32.le_u - (i32.load - (local.tee $1 - (i32.add - (local.get $0) - (i32.const 20) - ) - ) - ) - (i32.load - (local.tee $2 - (i32.add - (local.get $0) - (i32.const 28) - ) - ) - ) - ) - ) - (drop - (call_indirect (type $FUNCSIG$iiii) - (local.get $0) - (i32.const 0) - (i32.const 0) - (i32.add - (i32.and - (i32.load offset=36 - (local.get $0) - ) - (i32.const 3) - ) - (i32.const 2) - ) - ) - ) - (br_if $jumpthreading$inner$0 - (i32.load - (local.get $1) - ) - ) - (br $jumpthreading$outer$0 - (i32.const -1) - ) - ) - (if - (i32.lt_u - (local.tee $4 - (i32.load - (local.tee $3 - (i32.add - (local.get $0) - (i32.const 4) - ) - ) - ) - ) - (local.tee $6 - (i32.load - (local.tee $5 - (i32.add - (local.get $0) - (i32.const 8) - ) - ) - ) - ) - ) - (then - (drop - (call_indirect (type $FUNCSIG$iiii) - (local.get $0) - (i32.sub - (local.get $4) - (local.get $6) - ) - (i32.const 1) - (i32.add - (i32.and - (i32.load offset=40 - (local.get $0) - ) - (i32.const 3) - ) - (i32.const 2) - ) - ) - ) - ) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (i32.store - (local.get $2) - (i32.const 0) - ) - (i32.store - (local.get $1) - (i32.const 0) - ) - (i32.store - (local.get $5) - (i32.const 0) - ) - (i32.store - (local.get $3) - (i32.const 0) - ) - (i32.const 0) - ) - ) - (func $__Znwj (param $0 i32) (result i32) - (local $1 i32) - (local.set $1 - (select - (local.get $0) - (i32.const 1) - (local.get $0) - ) - ) - (loop $while-in - (block $while-out - (br_if $while-out - (local.tee $0 - (call $_malloc - (local.get $1) - ) - ) - ) - (if - (local.tee $0 - (call $__ZSt15get_new_handlerv) - ) - (then - (call_indirect (type $FUNCSIG$v) - (i32.add - (i32.and - (local.get $0) - (i32.const 0) - ) - (i32.const 8) - ) - ) - (br $while-in) - ) - (else - (local.set $0 - (i32.const 0) - ) - ) - ) - ) - ) - (local.get $0) - ) - (func $__ZSt15get_new_handlerv (result i32) - (local $0 i32) - (i32.store - (i32.const 1188) - (i32.add - (local.tee $0 - (i32.load - (i32.const 1188) - ) - ) - (i32.const 0) - ) - ) - (local.get $0) - ) - (func $runPostSets - (nop) - ) - (func $_memset (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local.set $4 - (i32.add - (local.get $0) - (local.get $2) - ) - ) - (if - (i32.ge_s - (local.get $2) - (i32.const 20) - ) - (then - (local.set $5 - (i32.or - (i32.or - (i32.or - (local.tee $1 - (i32.and - (local.get $1) - (i32.const 255) - ) - ) - (i32.shl - (local.get $1) - (i32.const 8) - ) - ) - (i32.shl - (local.get $1) - (i32.const 16) - ) - ) - (i32.shl - (local.get $1) - (i32.const 24) - ) - ) - ) - (local.set $6 - (i32.and - (local.get $4) - (i32.const -4) - ) - ) - (if - (local.tee $3 - (i32.and - (local.get $0) - (i32.const 3) - ) - ) - (then - (local.set $3 - (i32.sub - (i32.add - (local.get $0) - (i32.const 4) - ) - (local.get $3) - ) - ) - (loop $while-in - (if - (i32.lt_s - (local.get $0) - (local.get $3) - ) - (then - (i32.store8 - (local.get $0) - (local.get $1) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (br $while-in) - ) - ) - ) - ) - ) - (loop $while-in1 - (if - (i32.lt_s - (local.get $0) - (local.get $6) - ) - (then - (i32.store - (local.get $0) - (local.get $5) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 4) - ) - ) - (br $while-in1) - ) - ) - ) - ) - ) - (loop $while-in3 - (if - (i32.lt_s - (local.get $0) - (local.get $4) - ) - (then - (i32.store8 - (local.get $0) - (local.get $1) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (br $while-in3) - ) - ) - ) - (i32.sub - (local.get $0) - (local.get $2) - ) - ) - (func $_memcpy (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (if - (i32.ge_s - (local.get $2) - (i32.const 4096) - ) - (then - (return - (call $_emscripten_memcpy_big - (local.get $0) - (local.get $1) - (local.get $2) - ) - ) - ) - ) - (local.set $3 - (local.get $0) - ) - (if - (i32.eq - (i32.and - (local.get $0) - (i32.const 3) - ) - (i32.and - (local.get $1) - (i32.const 3) - ) - ) - (then - (loop $while-in - (block $while-out - (br_if $while-out - (i32.eqz - (i32.and - (local.get $0) - (i32.const 3) - ) - ) - ) - (if - (i32.eqz - (local.get $2) - ) - (then - (return - (local.get $3) - ) - ) - ) - (i32.store8 - (local.get $0) - (i32.load8_s - (local.get $1) - ) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.const 1) - ) - ) - (local.set $2 - (i32.sub - (local.get $2) - (i32.const 1) - ) - ) - (br $while-in) - ) - ) - (loop $while-in1 - (if - (i32.ge_s - (local.get $2) - (i32.const 4) - ) - (then - (i32.store - (local.get $0) - (i32.load - (local.get $1) - ) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 4) - ) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.const 4) - ) - ) - (local.set $2 - (i32.sub - (local.get $2) - (i32.const 4) - ) - ) - (br $while-in1) - ) - ) - ) - ) - ) - (loop $while-in3 - (if - (i32.gt_s - (local.get $2) - (i32.const 0) - ) - (then - (i32.store8 - (local.get $0) - (i32.load8_s - (local.get $1) - ) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.const 1) - ) - ) - (local.set $2 - (i32.sub - (local.get $2) - (i32.const 1) - ) - ) - (br $while-in3) - ) - ) - ) - (local.get $3) - ) - (func $_pthread_self (result i32) - (i32.const 0) - ) - (func $dynCall_ii (param $0 i32) (param $1 i32) (result i32) - (call_indirect (type $FUNCSIG$ii) - (local.get $1) - (i32.add - (i32.and - (local.get $0) - (i32.const 1) - ) - (i32.const 0) - ) - ) - ) - (func $dynCall_iiii (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) - (call_indirect (type $FUNCSIG$iiii) - (local.get $1) - (local.get $2) - (local.get $3) - (i32.add - (i32.and - (local.get $0) - (i32.const 3) - ) - (i32.const 2) - ) - ) - ) - (func $dynCall_vi (param $0 i32) (param $1 i32) - (call_indirect (type $FUNCSIG$vi) - (local.get $1) - (i32.add - (i32.and - (local.get $0) - (i32.const 1) - ) - (i32.const 6) - ) - ) - ) - (func $dynCall_v (param $0 i32) - (call_indirect (type $FUNCSIG$v) - (i32.add - (i32.and - (local.get $0) - (i32.const 0) - ) - (i32.const 8) - ) - ) - ) - (func $b0 (param $0 i32) (result i32) - (call $abort - (i32.const 0) - ) - (i32.const 0) - ) - (func $b1 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (call $abort - (i32.const 1) - ) - (i32.const 0) - ) - (func $b2 (param $0 i32) - (call $abort - (i32.const 2) - ) - ) - (func $b3 - (call $abort - (i32.const 3) - ) - ) -) diff --git a/test/passes/print-call-graph.wast b/test/passes/print-call-graph.wast deleted file mode 100644 index 9d6371b4bf3..00000000000 --- a/test/passes/print-call-graph.wast +++ /dev/null @@ -1,1462 +0,0 @@ -(module - (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) - (type $FUNCSIG$v (func)) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) - (import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) - (import "env" "ABORT" (global $ABORT$asm2wasm$import i32)) - (import "global" "NaN" (global $nan$asm2wasm$import f64)) - (import "global" "Infinity" (global $inf$asm2wasm$import f64)) - (import "env" "abort" (func $abort (param i32))) - (import "env" "_pthread_cleanup_pop" (func $_pthread_cleanup_pop (param i32))) - (import "env" "___lock" (func $___lock (param i32))) - (import "env" "___syscall6" (func $___syscall6 (param i32 i32) (result i32))) - (import "env" "_pthread_cleanup_push" (func $_pthread_cleanup_push (param i32 i32))) - (import "env" "___syscall140" (func $___syscall140 (param i32 i32) (result i32))) - (import "env" "_emscripten_memcpy_big" (func $_emscripten_memcpy_big (param i32 i32 i32) (result i32))) - (import "env" "___syscall54" (func $___syscall54 (param i32 i32) (result i32))) - (import "env" "___unlock" (func $___unlock (param i32))) - (import "env" "___syscall146" (func $___syscall146 (param i32 i32) (result i32))) - (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 9 9 funcref)) - (import "env" "memoryBase" (global $memoryBase i32)) - (import "env" "tableBase" (global $tableBase i32)) - (elem (i32.const 0) $b0 $___stdio_close $b1 $___stdout_write $___stdio_seek $___stdio_write $b2 $_cleanup_387 $b3) - (data (global.get $memoryBase) "\05\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00\b0\04\00\00\00\04\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\n\ff\ff\ff\ff\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\04") - (global $STACKTOP (mut i32) (global.get $STACKTOP$asm2wasm$import)) - (global $STACK_MAX (mut i32) (global.get $STACK_MAX$asm2wasm$import)) - (global $ABORT (mut i32) (global.get $ABORT$asm2wasm$import)) - (global $__THREW__ (mut i32) (i32.const 0)) - (global $threwValue (mut i32) (i32.const 0)) - (global $setjmpId (mut i32) (i32.const 0)) - (global $undef (mut i32) (i32.const 0)) - (global $nan (mut f64) (global.get $nan$asm2wasm$import)) - (global $inf (mut f64) (global.get $inf$asm2wasm$import)) - (global $tempInt (mut i32) (i32.const 0)) - (global $tempBigInt (mut i32) (i32.const 0)) - (global $tempBigIntP (mut i32) (i32.const 0)) - (global $tempBigIntS (mut i32) (i32.const 0)) - (global $tempBigIntR (mut f64) (f64.const 0)) - (global $tempBigIntI (mut i32) (i32.const 0)) - (global $tempBigIntD (mut i32) (i32.const 0)) - (global $tempValue (mut i32) (i32.const 0)) - (global $tempDouble (mut f64) (f64.const 0)) - (global $tempRet0 (mut i32) (i32.const 0)) - (global $tempFloat (mut f32) (f32.const 0)) - (global $f0 (mut f32) (f32.const 0)) - (export "_fflush" (func $_fflush)) - (export "_main" (func $_main)) - (export "_pthread_self" (func $_pthread_self)) - (export "_memset" (func $_memset)) - (export "_malloc" (func $_malloc)) - (export "_memcpy" (func $_memcpy)) - (export "_free" (func $_free)) - (export "___errno_location" (func $___errno_location)) - (export "runPostSets" (func $runPostSets)) - (export "stackAlloc" (func $stackAlloc)) - (export "stackSave" (func $stackSave)) - (export "stackRestore" (func $stackRestore)) - (export "establishStackSpace" (func $establishStackSpace)) - (export "setThrew" (func $setThrew)) - (export "setTempRet0" (func $setTempRet0)) - (export "getTempRet0" (func $getTempRet0)) - (export "dynCall_ii" (func $dynCall_ii)) - (export "dynCall_iiii" (func $dynCall_iiii)) - (export "dynCall_vi" (func $dynCall_vi)) - (export "dynCall_v" (func $dynCall_v)) - (func $stackAlloc (param $0 i32) (result i32) - (local $1 i32) - (local.set $1 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (local.get $0) - ) - ) - (global.set $STACKTOP - (i32.and - (i32.add - (global.get $STACKTOP) - (i32.const 15) - ) - (i32.const -16) - ) - ) - (local.get $1) - ) - (func $stackSave (result i32) - (global.get $STACKTOP) - ) - (func $stackRestore (param $0 i32) - (global.set $STACKTOP - (local.get $0) - ) - ) - (func $establishStackSpace (param $0 i32) (param $1 i32) - (global.set $STACKTOP - (local.get $0) - ) - (global.set $STACK_MAX - (local.get $1) - ) - ) - (func $setThrew (param $0 i32) (param $1 i32) - (if - (i32.eqz - (global.get $__THREW__) - ) - (then - (block - (global.set $__THREW__ - (local.get $0) - ) - (global.set $threwValue - (local.get $1) - ) - ) - ) - ) - ) - (func $setTempRet0 (param $0 i32) - (global.set $tempRet0 - (local.get $0) - ) - ) - (func $getTempRet0 (result i32) - (global.get $tempRet0) - ) - (func $_malloc (param $0 i32) (result i32) - (i32.const 0) - ) - (func $_free (param $0 i32) - (nop) - ) - (func $_main (result i32) - (local $0 i32) - (i64.store align=4 - (local.tee $0 - (call $__Znwj - (i32.const 8) - ) - ) - (i64.const 0) - ) - (local.get $0) - ) - (func $___stdio_close (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local.set $1 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (i32.const 16) - ) - ) - (i32.store - (local.tee $2 - (local.get $1) - ) - (i32.load offset=60 - (local.get $0) - ) - ) - (local.set $0 - (call $___syscall_ret - (call $___syscall6 - (i32.const 6) - (local.get $2) - ) - ) - ) - (global.set $STACKTOP - (local.get $1) - ) - (local.get $0) - ) - (func $___stdio_write (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local.set $7 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (i32.const 48) - ) - ) - (local.set $8 - (i32.add - (local.get $7) - (i32.const 16) - ) - ) - (local.set $9 - (local.get $7) - ) - (i32.store - (local.tee $3 - (i32.add - (local.get $7) - (i32.const 32) - ) - ) - (local.tee $5 - (i32.load - (local.tee $6 - (i32.add - (local.get $0) - (i32.const 28) - ) - ) - ) - ) - ) - (i32.store offset=4 - (local.get $3) - (local.tee $4 - (i32.sub - (i32.load - (local.tee $10 - (i32.add - (local.get $0) - (i32.const 20) - ) - ) - ) - (local.get $5) - ) - ) - ) - (i32.store offset=8 - (local.get $3) - (local.get $1) - ) - (i32.store offset=12 - (local.get $3) - (local.get $2) - ) - (local.set $13 - (i32.add - (local.get $0) - (i32.const 60) - ) - ) - (local.set $14 - (i32.add - (local.get $0) - (i32.const 44) - ) - ) - (local.set $1 - (local.get $3) - ) - (local.set $5 - (i32.const 2) - ) - (local.set $11 - (i32.add - (local.get $4) - (local.get $2) - ) - ) - (local.set $0 - (block $jumpthreading$outer$1 (result i32) - (block $jumpthreading$inner$1 - (block $jumpthreading$inner$0 - (loop $while-in - (br_if $jumpthreading$inner$0 - (i32.eq - (local.get $11) - (local.tee $4 - (if (result i32) - (i32.load - (i32.const 1140) - ) - (then - (block (result i32) - (call $_pthread_cleanup_push - (i32.const 1) - (local.get $0) - ) - (i32.store - (local.get $9) - (i32.load - (local.get $13) - ) - ) - (i32.store offset=4 - (local.get $9) - (local.get $1) - ) - (i32.store offset=8 - (local.get $9) - (local.get $5) - ) - (local.set $3 - (call $___syscall_ret - (call $___syscall146 - (i32.const 146) - (local.get $9) - ) - ) - ) - (call $_pthread_cleanup_pop - (i32.const 0) - ) - (local.get $3) - ) - ) - (else - (block (result i32) - (i32.store - (local.get $8) - (i32.load - (local.get $13) - ) - ) - (i32.store offset=4 - (local.get $8) - (local.get $1) - ) - (i32.store offset=8 - (local.get $8) - (local.get $5) - ) - (call $___syscall_ret - (call $___syscall146 - (i32.const 146) - (local.get $8) - ) - ) - ) - ) - ) - ) - ) - ) - (br_if $jumpthreading$inner$1 - (i32.lt_s - (local.get $4) - (i32.const 0) - ) - ) - (local.set $11 - (i32.sub - (local.get $11) - (local.get $4) - ) - ) - (local.set $1 - (if (result i32) - (i32.gt_u - (local.get $4) - (local.tee $12 - (i32.load offset=4 - (local.get $1) - ) - ) - ) - (then - (block (result i32) - (i32.store - (local.get $6) - (local.tee $3 - (i32.load - (local.get $14) - ) - ) - ) - (i32.store - (local.get $10) - (local.get $3) - ) - (local.set $4 - (i32.sub - (local.get $4) - (local.get $12) - ) - ) - (local.set $3 - (i32.add - (local.get $1) - (i32.const 8) - ) - ) - (local.set $5 - (i32.add - (local.get $5) - (i32.const -1) - ) - ) - (i32.load offset=12 - (local.get $1) - ) - ) - ) - (else - (if (result i32) - (i32.eq - (local.get $5) - (i32.const 2) - ) - (then - (block (result i32) - (i32.store - (local.get $6) - (i32.add - (i32.load - (local.get $6) - ) - (local.get $4) - ) - ) - (local.set $3 - (local.get $1) - ) - (local.set $5 - (i32.const 2) - ) - (local.get $12) - ) - ) - (else - (block (result i32) - (local.set $3 - (local.get $1) - ) - (local.get $12) - ) - ) - ) - ) - ) - ) - (i32.store - (local.get $3) - (i32.add - (i32.load - (local.get $3) - ) - (local.get $4) - ) - ) - (i32.store offset=4 - (local.get $3) - (i32.sub - (local.get $1) - (local.get $4) - ) - ) - (local.set $1 - (local.get $3) - ) - (br $while-in) - ) - ) - (i32.store offset=16 - (local.get $0) - (i32.add - (local.tee $1 - (i32.load - (local.get $14) - ) - ) - (i32.load offset=48 - (local.get $0) - ) - ) - ) - (i32.store - (local.get $6) - (local.tee $0 - (local.get $1) - ) - ) - (i32.store - (local.get $10) - (local.get $0) - ) - (br $jumpthreading$outer$1 - (local.get $2) - ) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (i32.store - (local.get $6) - (i32.const 0) - ) - (i32.store - (local.get $10) - (i32.const 0) - ) - (i32.store - (local.get $0) - (i32.or - (i32.load - (local.get $0) - ) - (i32.const 32) - ) - ) - (select - (i32.const 0) - (i32.sub - (local.get $2) - (i32.load offset=4 - (local.get $1) - ) - ) - (i32.eq - (local.get $5) - (i32.const 2) - ) - ) - ) - ) - (global.set $STACKTOP - (local.get $7) - ) - (local.get $0) - ) - (func $___stdio_seek (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local.set $4 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (i32.const 32) - ) - ) - (i32.store - (local.tee $3 - (local.get $4) - ) - (i32.load offset=60 - (local.get $0) - ) - ) - (i32.store offset=4 - (local.get $3) - (i32.const 0) - ) - (i32.store offset=8 - (local.get $3) - (local.get $1) - ) - (i32.store offset=12 - (local.get $3) - (local.tee $0 - (i32.add - (local.get $4) - (i32.const 20) - ) - ) - ) - (i32.store offset=16 - (local.get $3) - (local.get $2) - ) - (local.set $0 - (if (result i32) - (i32.lt_s - (call $___syscall_ret - (call $___syscall140 - (i32.const 140) - (local.get $3) - ) - ) - (i32.const 0) - ) - (then - (block (result i32) - (i32.store - (local.get $0) - (i32.const -1) - ) - (i32.const -1) - ) - ) - (else - (i32.load - (local.get $0) - ) - ) - ) - ) - (global.set $STACKTOP - (local.get $4) - ) - (local.get $0) - ) - (func $___syscall_ret (param $0 i32) (result i32) - (if (result i32) - (i32.gt_u - (local.get $0) - (i32.const -4096) - ) - (then - (block (result i32) - (i32.store - (call $___errno_location) - (i32.sub - (i32.const 0) - (local.get $0) - ) - ) - (i32.const -1) - ) - ) - (else - (local.get $0) - ) - ) - ) - (func $___errno_location (result i32) - (if (result i32) - (i32.load - (i32.const 1140) - ) - (then - (i32.load offset=64 - (call $_pthread_self) - ) - ) - (else - (i32.const 1184) - ) - ) - ) - (func $_cleanup_387 (param $0 i32) - (if - (i32.eqz - (i32.load offset=68 - (local.get $0) - ) - ) - (then - (call $_free - (local.get $0) - ) - ) - ) - ) - (func $___stdout_write (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local.set $4 - (global.get $STACKTOP) - ) - (global.set $STACKTOP - (i32.add - (global.get $STACKTOP) - (i32.const 80) - ) - ) - (local.set $3 - (local.get $4) - ) - (local.set $5 - (i32.add - (local.get $4) - (i32.const 12) - ) - ) - (i32.store offset=36 - (local.get $0) - (i32.const 3) - ) - (if - (i32.eqz - (i32.and - (i32.load - (local.get $0) - ) - (i32.const 64) - ) - ) - (then - (block - (i32.store - (local.get $3) - (i32.load offset=60 - (local.get $0) - ) - ) - (i32.store offset=4 - (local.get $3) - (i32.const 21505) - ) - (i32.store offset=8 - (local.get $3) - (local.get $5) - ) - (if - (call $___syscall54 - (i32.const 54) - (local.get $3) - ) - (then - (i32.store8 offset=75 - (local.get $0) - (i32.const -1) - ) - ) - ) - ) - ) - ) - (local.set $0 - (call $___stdio_write - (local.get $0) - (local.get $1) - (local.get $2) - ) - ) - (global.set $STACKTOP - (local.get $4) - ) - (local.get $0) - ) - (func $_fflush (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (block $do-once (result i32) - (if (result i32) - (local.get $0) - (then - (block (result i32) - (if - (i32.le_s - (i32.load offset=76 - (local.get $0) - ) - (i32.const -1) - ) - (then - (br $do-once - (call $___fflush_unlocked - (local.get $0) - ) - ) - ) - ) - (local.set $2 - (i32.eqz - (call $_malloc - (local.get $0) - ) - ) - ) - (local.set $1 - (call $___fflush_unlocked - (local.get $0) - ) - ) - (if (result i32) - (local.get $2) - (then - (local.get $1) - ) - (else - (block (result i32) - (call $_free - (local.get $0) - ) - (local.get $1) - ) - ) - ) - ) - ) - (else - (block (result i32) - (local.set $0 - (if (result i32) - (i32.load - (i32.const 1136) - ) - (then - (call $_fflush - (i32.load - (i32.const 1136) - ) - ) - ) - (else - (i32.const 0) - ) - ) - ) - (call $___lock - (i32.const 1168) - ) - (if - (local.tee $1 - (i32.load - (i32.const 1164) - ) - ) - (then - (loop $while-in - (local.set $2 - (if (result i32) - (i32.gt_s - (i32.load offset=76 - (local.get $1) - ) - (i32.const -1) - ) - (then - (call $_malloc - (local.get $1) - ) - ) - (else - (i32.const 0) - ) - ) - ) - (local.set $0 - (if (result i32) - (i32.gt_u - (i32.load offset=20 - (local.get $1) - ) - (i32.load offset=28 - (local.get $1) - ) - ) - (then - (i32.or - (call $___fflush_unlocked - (local.get $1) - ) - (local.get $0) - ) - ) - (else - (local.get $0) - ) - ) - ) - (if - (local.get $2) - (then - (call $_free - (local.get $1) - ) - ) - ) - (br_if $while-in - (local.tee $1 - (i32.load offset=56 - (local.get $1) - ) - ) - ) - ) - ) - ) - (call $___unlock - (i32.const 1168) - ) - (local.get $0) - ) - ) - ) - ) - ) - (func $___fflush_unlocked (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (block $jumpthreading$outer$0 (result i32) - (block $jumpthreading$inner$0 - (br_if $jumpthreading$inner$0 - (i32.le_u - (i32.load - (local.tee $1 - (i32.add - (local.get $0) - (i32.const 20) - ) - ) - ) - (i32.load - (local.tee $2 - (i32.add - (local.get $0) - (i32.const 28) - ) - ) - ) - ) - ) - (drop - (call_indirect (type $FUNCSIG$iiii) - (local.get $0) - (i32.const 0) - (i32.const 0) - (i32.add - (i32.and - (i32.load offset=36 - (local.get $0) - ) - (i32.const 3) - ) - (i32.const 2) - ) - ) - ) - (br_if $jumpthreading$inner$0 - (i32.load - (local.get $1) - ) - ) - (br $jumpthreading$outer$0 - (i32.const -1) - ) - ) - (if - (i32.lt_u - (local.tee $4 - (i32.load - (local.tee $3 - (i32.add - (local.get $0) - (i32.const 4) - ) - ) - ) - ) - (local.tee $6 - (i32.load - (local.tee $5 - (i32.add - (local.get $0) - (i32.const 8) - ) - ) - ) - ) - ) - (then - (drop - (call_indirect (type $FUNCSIG$iiii) - (local.get $0) - (i32.sub - (local.get $4) - (local.get $6) - ) - (i32.const 1) - (i32.add - (i32.and - (i32.load offset=40 - (local.get $0) - ) - (i32.const 3) - ) - (i32.const 2) - ) - ) - ) - ) - ) - (i32.store offset=16 - (local.get $0) - (i32.const 0) - ) - (i32.store - (local.get $2) - (i32.const 0) - ) - (i32.store - (local.get $1) - (i32.const 0) - ) - (i32.store - (local.get $5) - (i32.const 0) - ) - (i32.store - (local.get $3) - (i32.const 0) - ) - (i32.const 0) - ) - ) - (func $__Znwj (param $0 i32) (result i32) - (local $1 i32) - (local.set $1 - (select - (local.get $0) - (i32.const 1) - (local.get $0) - ) - ) - (loop $while-in - (block $while-out - (br_if $while-out - (local.tee $0 - (call $_malloc - (local.get $1) - ) - ) - ) - (if - (local.tee $0 - (call $__ZSt15get_new_handlerv) - ) - (then - (block - (call_indirect (type $FUNCSIG$v) - (i32.add - (i32.and - (local.get $0) - (i32.const 0) - ) - (i32.const 8) - ) - ) - (br $while-in) - ) - ) - (else - (local.set $0 - (i32.const 0) - ) - ) - ) - ) - ) - (local.get $0) - ) - (func $__ZSt15get_new_handlerv (result i32) - (local $0 i32) - (i32.store - (i32.const 1188) - (i32.add - (local.tee $0 - (i32.load - (i32.const 1188) - ) - ) - (i32.const 0) - ) - ) - (local.get $0) - ) - (func $runPostSets - (nop) - ) - (func $_memset (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local.set $4 - (i32.add - (local.get $0) - (local.get $2) - ) - ) - (if - (i32.ge_s - (local.get $2) - (i32.const 20) - ) - (then - (block - (local.set $5 - (i32.or - (i32.or - (i32.or - (local.tee $1 - (i32.and - (local.get $1) - (i32.const 255) - ) - ) - (i32.shl - (local.get $1) - (i32.const 8) - ) - ) - (i32.shl - (local.get $1) - (i32.const 16) - ) - ) - (i32.shl - (local.get $1) - (i32.const 24) - ) - ) - ) - (local.set $6 - (i32.and - (local.get $4) - (i32.const -4) - ) - ) - (if - (local.tee $3 - (i32.and - (local.get $0) - (i32.const 3) - ) - ) - (then - (block - (local.set $3 - (i32.sub - (i32.add - (local.get $0) - (i32.const 4) - ) - (local.get $3) - ) - ) - (loop $while-in - (if - (i32.lt_s - (local.get $0) - (local.get $3) - ) - (then - (block - (i32.store8 - (local.get $0) - (local.get $1) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (br $while-in) - ) - ) - ) - ) - ) - ) - ) - (loop $while-in1 - (if - (i32.lt_s - (local.get $0) - (local.get $6) - ) - (then - (block - (i32.store - (local.get $0) - (local.get $5) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 4) - ) - ) - (br $while-in1) - ) - ) - ) - ) - ) - ) - ) - (loop $while-in3 - (if - (i32.lt_s - (local.get $0) - (local.get $4) - ) - (then - (block - (i32.store8 - (local.get $0) - (local.get $1) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (br $while-in3) - ) - ) - ) - ) - (i32.sub - (local.get $0) - (local.get $2) - ) - ) - (func $_memcpy (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (if - (i32.ge_s - (local.get $2) - (i32.const 4096) - ) - (then - (return - (call $_emscripten_memcpy_big - (local.get $0) - (local.get $1) - (local.get $2) - ) - ) - ) - ) - (local.set $3 - (local.get $0) - ) - (if - (i32.eq - (i32.and - (local.get $0) - (i32.const 3) - ) - (i32.and - (local.get $1) - (i32.const 3) - ) - ) - (then - (block - (loop $while-in - (block $while-out - (br_if $while-out - (i32.eqz - (i32.and - (local.get $0) - (i32.const 3) - ) - ) - ) - (if - (i32.eqz - (local.get $2) - ) - (then - (return - (local.get $3) - ) - ) - ) - (i32.store8 - (local.get $0) - (i32.load8_s - (local.get $1) - ) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.const 1) - ) - ) - (local.set $2 - (i32.sub - (local.get $2) - (i32.const 1) - ) - ) - (br $while-in) - ) - ) - (loop $while-in1 - (if - (i32.ge_s - (local.get $2) - (i32.const 4) - ) - (then - (block - (i32.store - (local.get $0) - (i32.load - (local.get $1) - ) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 4) - ) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.const 4) - ) - ) - (local.set $2 - (i32.sub - (local.get $2) - (i32.const 4) - ) - ) - (br $while-in1) - ) - ) - ) - ) - ) - ) - ) - (loop $while-in3 - (if - (i32.gt_s - (local.get $2) - (i32.const 0) - ) - (then - (block - (i32.store8 - (local.get $0) - (i32.load8_s - (local.get $1) - ) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (local.set $1 - (i32.add - (local.get $1) - (i32.const 1) - ) - ) - (local.set $2 - (i32.sub - (local.get $2) - (i32.const 1) - ) - ) - (br $while-in3) - ) - ) - ) - ) - (local.get $3) - ) - (func $_pthread_self (result i32) - (i32.const 0) - ) - (func $dynCall_ii (param $0 i32) (param $1 i32) (result i32) - (call_indirect (type $FUNCSIG$ii) - (local.get $1) - (i32.add - (i32.and - (local.get $0) - (i32.const 1) - ) - (i32.const 0) - ) - ) - ) - (func $dynCall_iiii (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) - (call_indirect (type $FUNCSIG$iiii) - (local.get $1) - (local.get $2) - (local.get $3) - (i32.add - (i32.and - (local.get $0) - (i32.const 3) - ) - (i32.const 2) - ) - ) - ) - (func $dynCall_vi (param $0 i32) (param $1 i32) - (call_indirect (type $FUNCSIG$vi) - (local.get $1) - (i32.add - (i32.and - (local.get $0) - (i32.const 1) - ) - (i32.const 6) - ) - ) - ) - (func $dynCall_v (param $0 i32) - (call_indirect (type $FUNCSIG$v) - (i32.add - (i32.and - (local.get $0) - (i32.const 0) - ) - (i32.const 8) - ) - ) - ) - (func $b0 (param $0 i32) (result i32) - (call $abort - (i32.const 0) - ) - (i32.const 0) - ) - (func $b1 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (call $abort - (i32.const 1) - ) - (i32.const 0) - ) - (func $b2 (param $0 i32) - (call $abort - (i32.const 2) - ) - ) - (func $b3 - (call $abort - (i32.const 3) - ) - ) -)