summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/Inlining.cpp65
-rw-r--r--src/passes/pass.cpp4
-rw-r--r--test/passes/inlining-optimizing.txt20
-rw-r--r--test/passes/inlining-optimizing.wast24
-rw-r--r--test/passes/inlining-optimizing_optimize-level=3.txt329
-rw-r--r--test/passes/inlining.txt27
-rw-r--r--test/passes/inlining_optimize-level=3.txt76
-rw-r--r--test/wasm-only.fromasm85
-rw-r--r--test/wasm-only.fromasm.clamp85
-rw-r--r--test/wasm-only.fromasm.imprecise73
10 files changed, 434 insertions, 354 deletions
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index 3a244948a..0c211e786 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -17,14 +17,17 @@
//
// Inlining.
//
-// By default, this does a conservative inlining of all functions that have
-// exactly one use, and are fairly small. That should not increase code
-// size, and may have speed benefits.
+// This uses some simple heuristics to decide when to inline.
//
-// When opt level is 3+ (-O3 or above), we more aggressively inline
-// even functions with more than one use, that seem to be "lightweight"
-// (no loops or calls etc.), so inlining them may get rid of call overhead
-// that would be noticeable otherwise
+// Two versions are provided: inlining and inlining-optimizing. You
+// probably want the optimizing version, which will optimize locations
+// we inlined into, as inlining by itself creates a block to house the
+// inlined code, some temp locals, etc., which can usually be removed
+// by optimizations. Note that the two versions use the same heuristics,
+// so we don't take into account the overhead if you don't optimize
+// afterwards. The non-optimizing version is mainly useful for debugging,
+// or if you intend to run a full set of optimizations anyhow on
+// everything later.
//
#include <atomic>
@@ -47,8 +50,16 @@ static const int CAREFUL_SIZE_LIMIT = 15;
static const int FLEXIBLE_SIZE_LIMIT = 20;
// A size so small that after optimizations, the inlined code will be
-// smaller than the call instruction itself.
-static const int INLINING_OPTIMIZING_WILL_DECREASE_SIZE_LIMIT = 1;
+// smaller than the call instruction itself. 2 is a safe number because
+// there is no risk of things like
+// (func $reverse (param $x i32) (param $y i32)
+// (call $something (get_local $y) (get_local $x))
+// )
+// in which case the reversing of the params means we'll possibly need
+// a block and a temp local. But that takes at least 3 nodes, and 2 < 3.
+// More generally, with 2 items we may have a get_local, but no way to
+// require it to be saved instead of directly consumed.
+static const int INLINING_OPTIMIZING_WILL_DECREASE_SIZE_LIMIT = 2;
// Useful into on a function, helping us decide if we can inline it
struct FunctionInfo {
@@ -64,23 +75,20 @@ struct FunctionInfo {
usedGlobally = false;
}
- bool worthInlining(PassOptions& options,
- bool allowMultipleInliningsPerFunction,
- bool optimizing) {
+ bool worthInlining(PassOptions& options) {
// if it's big, it's just not worth doing (TODO: investigate more)
if (size > FLEXIBLE_SIZE_LIMIT) return false;
// if it's so small we have a guarantee that after we optimize the
// size will not increase, inline it
- if (optimizing && size <= INLINING_OPTIMIZING_WILL_DECREASE_SIZE_LIMIT) return true;
+ if (size <= INLINING_OPTIMIZING_WILL_DECREASE_SIZE_LIMIT) return true;
// if it has one use, then inlining it would likely reduce code size
// since we are just moving code around, + optimizing, so worth it
// if small enough that we are pretty sure its ok
if (calls == 1 && !usedGlobally && size <= CAREFUL_SIZE_LIMIT) return true;
- if (!allowMultipleInliningsPerFunction) return false;
// more than one use, so we can't eliminate it after inlining,
// so only worth it if we really care about speed and don't care
// about size, and if it's lightweight so a good candidate for
- // speeding us up
+ // speeding us up.
return options.optimizeLevel >= 3 && options.shrinkLevel == 0 && lightweight;
}
};
@@ -221,19 +229,28 @@ struct Inlining : public Pass {
// whether to optimize where we inline
bool optimize = false;
+ // the information for each function. recomputed in each iteraction
NameInfoMap infos;
- bool firstIteration;
+ Index iterationNumber;
void run(PassRunner* runner, Module* module) override {
+ Index numFunctions = module->functions.size();
// keep going while we inline, to handle nesting. TODO: optimize
- firstIteration = true;
- while (1) {
+ iterationNumber = 0;
+ // no point to do more iterations than the number of functions, as
+ // it means we infinitely recursing (which should
+ // be very rare in practice, but it is possible that a recursive call
+ // can look like it is worth inlining)
+ while (iterationNumber <= numFunctions) {
+#ifdef INLINING_DEBUG
+ std::cout << "inlining loop iter " << iterationNumber << " (numFunctions: " << numFunctions << ")\n";
+#endif
calculateInfos(module);
if (!iteration(runner, module)) {
return;
}
- firstIteration = false;
+ iterationNumber++;
}
}
@@ -268,9 +285,7 @@ struct Inlining : public Pass {
InliningState state;
for (auto& func : module->functions) {
// on the first iteration, allow multiple inlinings per function
- if (infos[func->name].worthInlining(runner->options,
- firstIteration /* allowMultipleInliningsPerFunction */,
- optimize)) {
+ if (infos[func->name].worthInlining(runner->options)) {
state.worthInlining.insert(func->name);
}
}
@@ -291,14 +306,14 @@ struct Inlining : public Pass {
std::unordered_set<Function*> inlinedInto; // which functions were inlined into
for (auto& func : module->functions) {
// if we've inlined a function, don't inline into it in this iteration,
- // avoid risk of loops
+ // avoid risk of races
// note that we do not risk stalling progress, as each iteration() will
// inline at least one call before hitting this
if (inlinedUses.count(func->name)) continue;
for (auto& action : state.actionsForFunction[func->name]) {
auto* inlinedFunction = action.contents;
// if we've inlined into a function, don't inline it in this iteration,
- // avoid risk of loops
+ // avoid risk of races
// note that we do not risk stalling progress, as each iteration() will
// inline at least one call before hitting this
if (inlinedInto.count(inlinedFunction)) continue;
@@ -326,7 +341,7 @@ struct Inlining : public Pass {
auto& info = infos[name];
bool canRemove = inlinedUses.count(name) && inlinedUses[name] == info.calls && !info.usedGlobally;
#ifdef INLINING_DEBUG
- std::cout << "removing " << name << '\n';
+ if (canRemove) std::cout << "removing " << name << '\n';
#endif
return canRemove;
}), funcs.end());
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index 11575b1df..c9fc7c40e 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -74,8 +74,8 @@ void PassRegistry::registerPasses() {
registerPass("extract-function", "leaves just one function (useful for debugging)", createExtractFunctionPass);
registerPass("flatten", "flattens out code, removing nesting", createFlattenPass);
registerPass("func-metrics", "reports function metrics", createFunctionMetricsPass);
- registerPass("inlining", "inlines functions", createInliningPass);
- registerPass("inlining-optimizing", "inlines functions and optimizes where we inlined", createInliningOptimizingPass);
+ registerPass("inlining", "inline functions (you probably want inlining-optimizing)", createInliningPass);
+ registerPass("inlining-optimizing", "inline functions and optimizes where we inlined", createInliningOptimizingPass);
registerPass("legalize-js-interface", "legalizes i64 types on the import/export boundary", createLegalizeJSInterfacePass);
registerPass("local-cse", "common subexpression elimination inside basic blocks", createLocalCSEPass);
registerPass("log-execution", "instrument the build with logging of where execution goes", createLogExecutionPass);
diff --git a/test/passes/inlining-optimizing.txt b/test/passes/inlining-optimizing.txt
index eab52a9de..27f75006a 100644
--- a/test/passes/inlining-optimizing.txt
+++ b/test/passes/inlining-optimizing.txt
@@ -55,3 +55,23 @@
(i64.const 0)
)
)
+(module
+ (type $0 (func))
+ (func $main (; 0 ;) (type $0)
+ (call $one)
+ (call $one)
+ )
+ (func $one (; 1 ;) (type $0)
+ (call $one)
+ )
+)
+(module
+ (type $0 (func))
+ (func $main (; 0 ;) (type $0)
+ (call $two)
+ (call $two)
+ )
+ (func $two (; 1 ;) (type $0)
+ (call $two)
+ )
+)
diff --git a/test/passes/inlining-optimizing.wast b/test/passes/inlining-optimizing.wast
index dbe511b1f..86fbba559 100644
--- a/test/passes/inlining-optimizing.wast
+++ b/test/passes/inlining-optimizing.wast
@@ -117,3 +117,27 @@
(i64.const 0)
)
)
+;; potential infinite recursion
+(module
+ (func $main
+ (call $one)
+ (call $one)
+ )
+ (func $one
+ (call $one)
+ )
+)
+;; potential infinite cycling recursion
+(module
+ (func $main
+ (call $one)
+ (call $one)
+ )
+ (func $one
+ (call $two)
+ )
+ (func $two
+ (call $one)
+ )
+)
+
diff --git a/test/passes/inlining-optimizing_optimize-level=3.txt b/test/passes/inlining-optimizing_optimize-level=3.txt
index b742b1596..2b6decaf6 100644
--- a/test/passes/inlining-optimizing_optimize-level=3.txt
+++ b/test/passes/inlining-optimizing_optimize-level=3.txt
@@ -382,11 +382,35 @@
)
)
(set_local $0
- (call $___syscall_ret
- (call $___syscall6
- (i32.const 6)
- (get_local $2)
+ (if (result i32)
+ (i32.gt_u
+ (tee_local $0
+ (call $___syscall6
+ (i32.const 6)
+ (get_local $2)
+ )
+ )
+ (i32.const -4096)
)
+ (block (result i32)
+ (i32.store
+ (if (result i32)
+ (i32.load
+ (i32.const 16)
+ )
+ (i32.load offset=60
+ (call $_pthread_self)
+ )
+ (i32.const 60)
+ )
+ (i32.sub
+ (i32.const 0)
+ (get_local $0)
+ )
+ )
+ (i32.const -1)
+ )
+ (get_local $0)
)
)
(set_global $STACKTOP
@@ -526,15 +550,39 @@
(set_local $0
(if (result i32)
(i32.lt_s
- (call $___syscall_ret
- (call $___syscall140
- (i32.const 140)
- (get_local $3)
+ (if (result i32)
+ (i32.gt_u
+ (tee_local $1
+ (call $___syscall140
+ (i32.const 140)
+ (get_local $3)
+ )
+ )
+ (i32.const -4096)
+ )
+ (block (result i32)
+ (i32.store
+ (if (result i32)
+ (i32.load
+ (i32.const 16)
+ )
+ (i32.load offset=60
+ (call $_pthread_self)
+ )
+ (i32.const 60)
+ )
+ (i32.sub
+ (i32.const 0)
+ (get_local $1)
+ )
+ )
+ (i32.const -1)
)
+ (get_local $1)
)
(i32.const 0)
)
- (block $block (result i32)
+ (block (result i32)
(i32.store
(get_local $0)
(i32.const -1)
@@ -714,7 +762,7 @@
(local $12 i32)
(local $13 i32)
(local $14 i32)
- (set_local $8
+ (set_local $7
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -730,23 +778,23 @@
)
(call $abort)
)
- (set_local $9
+ (set_local $8
(i32.add
- (get_local $8)
+ (get_local $7)
(i32.const 16)
)
)
- (set_local $10
- (get_local $8)
+ (set_local $9
+ (get_local $7)
)
(i32.store
- (tee_local $4
+ (tee_local $3
(i32.add
- (get_local $8)
+ (get_local $7)
(i32.const 32)
)
)
- (tee_local $3
+ (tee_local $4
(i32.load
(tee_local $6
(i32.add
@@ -758,8 +806,8 @@
)
)
(i32.store offset=4
- (get_local $4)
- (tee_local $3
+ (get_local $3)
+ (tee_local $4
(i32.sub
(i32.load
(tee_local $11
@@ -769,16 +817,16 @@
)
)
)
- (get_local $3)
+ (get_local $4)
)
)
)
(i32.store offset=8
- (get_local $4)
+ (get_local $3)
(get_local $1)
)
(i32.store offset=12
- (get_local $4)
+ (get_local $3)
(get_local $2)
)
(set_local $13
@@ -794,14 +842,14 @@
)
)
(set_local $1
- (get_local $4)
+ (get_local $3)
)
- (set_local $4
+ (set_local $3
(i32.const 2)
)
(set_local $12
(i32.add
- (get_local $3)
+ (get_local $4)
(get_local $2)
)
)
@@ -813,58 +861,106 @@
(i32.load
(i32.const 16)
)
- (block $block
+ (block
(call $_pthread_cleanup_push
(i32.const 5)
(get_local $0)
)
(i32.store
- (get_local $10)
+ (get_local $9)
(i32.load
(get_local $13)
)
)
(i32.store offset=4
- (get_local $10)
+ (get_local $9)
(get_local $1)
)
(i32.store offset=8
- (get_local $10)
- (get_local $4)
+ (get_local $9)
+ (get_local $3)
)
- (set_local $3
- (call $___syscall_ret
- (call $___syscall146
- (i32.const 146)
- (get_local $10)
+ (set_local $4
+ (if (result i32)
+ (i32.gt_u
+ (tee_local $5
+ (call $___syscall146
+ (i32.const 146)
+ (get_local $9)
+ )
+ )
+ (i32.const -4096)
+ )
+ (block (result i32)
+ (i32.store
+ (if (result i32)
+ (i32.load
+ (i32.const 16)
+ )
+ (i32.load offset=60
+ (call $_pthread_self)
+ )
+ (i32.const 60)
+ )
+ (i32.sub
+ (i32.const 0)
+ (get_local $5)
+ )
+ )
+ (i32.const -1)
)
+ (get_local $5)
)
)
(call $_pthread_cleanup_pop
(i32.const 0)
)
)
- (block $block14
+ (block
(i32.store
- (get_local $9)
+ (get_local $8)
(i32.load
(get_local $13)
)
)
(i32.store offset=4
- (get_local $9)
+ (get_local $8)
(get_local $1)
)
(i32.store offset=8
- (get_local $9)
- (get_local $4)
+ (get_local $8)
+ (get_local $3)
)
- (set_local $3
- (call $___syscall_ret
- (call $___syscall146
- (i32.const 146)
- (get_local $9)
+ (set_local $4
+ (if (result i32)
+ (i32.gt_u
+ (tee_local $5
+ (call $___syscall146
+ (i32.const 146)
+ (get_local $8)
+ )
+ )
+ (i32.const -4096)
)
+ (block (result i32)
+ (i32.store
+ (if (result i32)
+ (i32.load
+ (i32.const 16)
+ )
+ (i32.load offset=60
+ (call $_pthread_self)
+ )
+ (i32.const 60)
+ )
+ (i32.sub
+ (i32.const 0)
+ (get_local $5)
+ )
+ )
+ (i32.const -1)
+ )
+ (get_local $5)
)
)
)
@@ -872,29 +968,29 @@
(br_if $__rjti$0
(i32.eq
(get_local $12)
- (get_local $3)
+ (get_local $4)
)
)
(br_if $__rjti$1
(i32.lt_s
- (get_local $3)
+ (get_local $4)
(i32.const 0)
)
)
(set_local $5
(if (result i32)
(i32.gt_u
- (get_local $3)
+ (get_local $4)
(tee_local $5
(i32.load offset=4
(get_local $1)
)
)
)
- (block $block16 (result i32)
+ (block (result i32)
(i32.store
(get_local $6)
- (tee_local $7
+ (tee_local $10
(i32.load
(get_local $14)
)
@@ -902,9 +998,9 @@
)
(i32.store
(get_local $11)
- (get_local $7)
+ (get_local $10)
)
- (set_local $7
+ (set_local $10
(i32.load offset=12
(get_local $1)
)
@@ -915,45 +1011,43 @@
(i32.const 8)
)
)
- (set_local $4
+ (set_local $3
(i32.add
- (get_local $4)
+ (get_local $3)
(i32.const -1)
)
)
(i32.sub
- (get_local $3)
+ (get_local $4)
(get_local $5)
)
)
- (block $block17 (result i32)
- (if
- (i32.eq
- (get_local $4)
- (i32.const 2)
- )
- (block $block19
- (i32.store
- (get_local $6)
- (i32.add
- (i32.load
- (get_local $6)
+ (block (result i32)
+ (set_local $10
+ (if (result i32)
+ (i32.eq
+ (get_local $3)
+ (i32.const 2)
+ )
+ (block (result i32)
+ (i32.store
+ (get_local $6)
+ (i32.add
+ (i32.load
+ (get_local $6)
+ )
+ (get_local $4)
)
- (get_local $3)
)
- )
- (set_local $7
+ (set_local $3
+ (i32.const 2)
+ )
(get_local $5)
)
- (set_local $4
- (i32.const 2)
- )
- )
- (set_local $7
(get_local $5)
)
)
- (get_local $3)
+ (get_local $4)
)
)
)
@@ -969,14 +1063,14 @@
(i32.store offset=4
(get_local $1)
(i32.sub
- (get_local $7)
+ (get_local $10)
(get_local $5)
)
)
(set_local $12
(i32.sub
(get_local $12)
- (get_local $3)
+ (get_local $4)
)
)
(br $while-in)
@@ -1029,7 +1123,7 @@
(set_local $2
(if (result i32)
(i32.eq
- (get_local $4)
+ (get_local $3)
(i32.const 2)
)
(i32.const 0)
@@ -1043,7 +1137,7 @@
)
)
(set_global $STACKTOP
- (get_local $8)
+ (get_local $7)
)
(get_local $2)
)
@@ -2019,34 +2113,7 @@
(get_local $0)
)
)
- (func $___syscall_ret (; 41 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
- (if (result i32)
- (i32.gt_u
- (get_local $0)
- (i32.const -4096)
- )
- (block (result i32)
- (i32.store
- (if (result i32)
- (i32.load
- (i32.const 16)
- )
- (i32.load offset=60
- (call $_pthread_self)
- )
- (i32.const 60)
- )
- (i32.sub
- (i32.const 0)
- (get_local $0)
- )
- )
- (i32.const -1)
- )
- (get_local $0)
- )
- )
- (func $___fflush_unlocked (; 42 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
+ (func $___fflush_unlocked (; 41 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@@ -2168,14 +2235,14 @@
)
)
)
- (func $_cleanup (; 43 ;) (type $FUNCSIG$vi) (param $0 i32)
+ (func $_cleanup (; 42 ;) (type $FUNCSIG$vi) (param $0 i32)
(drop
(i32.load offset=68
(get_local $0)
)
)
)
- (func $_printf_core (; 44 ;) (type $9) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32)
+ (func $_printf_core (; 43 ;) (type $9) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
@@ -7249,7 +7316,7 @@
)
(get_local $16)
)
- (func $_pop_arg_336 (; 45 ;) (type $10) (param $0 i32) (param $1 i32) (param $2 i32)
+ (func $_pop_arg_336 (; 44 ;) (type $10) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 f64)
(local $5 i32)
@@ -7649,7 +7716,7 @@
)
)
)
- (func $_fmt_u (; 46 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_fmt_u (; 45 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(if
@@ -7775,7 +7842,7 @@
)
(get_local $2)
)
- (func $_pad (; 47 ;) (type $11) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32)
+ (func $_pad (; 46 ;) (type $11) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
@@ -7923,7 +7990,7 @@
(get_local $7)
)
)
- (func $_malloc (; 48 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
+ (func $_malloc (; 47 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@@ -13407,7 +13474,7 @@
(i32.const 8)
)
)
- (func $_free (; 49 ;) (type $FUNCSIG$vi) (param $0 i32)
+ (func $_free (; 48 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@@ -15197,10 +15264,10 @@
(i32.const -1)
)
)
- (func $runPostSets (; 50 ;) (type $FUNCSIG$v)
+ (func $runPostSets (; 49 ;) (type $FUNCSIG$v)
(nop)
)
- (func $_i64Subtract (; 51 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $_i64Subtract (; 50 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(set_global $tempRet0
(i32.sub
(i32.sub
@@ -15218,7 +15285,7 @@
(get_local $2)
)
)
- (func $_i64Add (; 52 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $_i64Add (; 51 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(local $4 i32)
(set_global $tempRet0
(i32.add
@@ -15239,7 +15306,7 @@
)
(get_local $4)
)
- (func $_memset (; 53 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memset (; 52 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@@ -15377,7 +15444,7 @@
(get_local $2)
)
)
- (func $_bitshift64Lshr (; 54 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_bitshift64Lshr (; 53 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(if
(i32.lt_s
(get_local $2)
@@ -15427,7 +15494,7 @@
)
)
)
- (func $_bitshift64Shl (; 55 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_bitshift64Shl (; 54 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(if
(i32.lt_s
(get_local $2)
@@ -15483,7 +15550,7 @@
)
(i32.const 0)
)
- (func $_memcpy (; 56 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memcpy (; 55 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(if
(i32.ge_s
@@ -15630,7 +15697,7 @@
)
(get_local $3)
)
- (func $___udivdi3 (; 57 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $___udivdi3 (; 56 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(call $___udivmoddi4
(get_local $0)
(get_local $1)
@@ -15639,7 +15706,7 @@
(i32.const 0)
)
)
- (func $___uremdi3 (; 58 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $___uremdi3 (; 57 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(local $4 i32)
(set_local $4
(get_global $STACKTOP)
@@ -15673,7 +15740,7 @@
(get_local $0)
)
)
- (func $___udivmoddi4 (; 59 ;) (type $9) (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (param $r i32) (result i32)
+ (func $___udivmoddi4 (; 58 ;) (type $9) (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (param $r i32) (result i32)
(local $x64 i64)
(local $y64 i64)
(set_local $x64
@@ -15730,7 +15797,7 @@
(get_local $x64)
)
)
- (func $dynCall_ii (; 60 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
+ (func $dynCall_ii (; 59 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(call_indirect (type $FUNCSIG$ii)
(get_local $1)
(i32.and
@@ -15739,7 +15806,7 @@
)
)
)
- (func $dynCall_iiii (; 61 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $dynCall_iiii (; 60 ;) (type $12) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(call_indirect (type $FUNCSIG$iiii)
(get_local $1)
(get_local $2)
@@ -15753,7 +15820,7 @@
)
)
)
- (func $dynCall_vi (; 62 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
+ (func $dynCall_vi (; 61 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(call_indirect (type $FUNCSIG$vi)
(get_local $1)
(i32.add
@@ -15765,19 +15832,19 @@
)
)
)
- (func $b0 (; 63 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
+ (func $b0 (; 62 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(call $nullFunc_ii
(i32.const 0)
)
(i32.const 0)
)
- (func $b1 (; 64 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $b1 (; 63 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(call $nullFunc_iiii
(i32.const 1)
)
(i32.const 0)
)
- (func $b2 (; 65 ;) (type $FUNCSIG$vi) (param $0 i32)
+ (func $b2 (; 64 ;) (type $FUNCSIG$vi) (param $0 i32)
(call $nullFunc_vi
(i32.const 2)
)
diff --git a/test/passes/inlining.txt b/test/passes/inlining.txt
index 9ce569da7..2076d078f 100644
--- a/test/passes/inlining.txt
+++ b/test/passes/inlining.txt
@@ -15,10 +15,26 @@
(local $4 f32)
(local $5 i64)
(local $6 f32)
- (call $exported)
- (call $tabled)
- (call $multi)
- (call $multi)
+ (block
+ (block $__inlined_func$exported
+ (nop)
+ )
+ )
+ (block
+ (block $__inlined_func$tabled
+ (nop)
+ )
+ )
+ (block
+ (block $__inlined_func$multi
+ (nop)
+ )
+ )
+ (block
+ (block $__inlined_func$multi0
+ (nop)
+ )
+ )
(block
(block $__inlined_func$ok
(drop
@@ -137,9 +153,6 @@
)
)
)
- (func $multi (; 5 ;) (type $0)
- (nop)
- )
)
(module
(type $0 (func (param i32) (result i32)))
diff --git a/test/passes/inlining_optimize-level=3.txt b/test/passes/inlining_optimize-level=3.txt
index 06486e401..cbdb90e3e 100644
--- a/test/passes/inlining_optimize-level=3.txt
+++ b/test/passes/inlining_optimize-level=3.txt
@@ -47,27 +47,17 @@
(nop)
(i32.const 1)
)
- (func $no-calls (; 2 ;) (type $0) (result i32)
- (block $__inlined_func$yes (result i32)
- (i32.const 1)
- )
- )
- (func $no-loops (; 3 ;) (type $0) (result i32)
- (loop $loop-in (result i32)
- (i32.const 1)
- )
- )
- (func $no-loops-but-one-use-but-exported (; 4 ;) (type $0) (result i32)
+ (func $no-loops-but-one-use-but-exported (; 2 ;) (type $0) (result i32)
(loop $loop-in (result i32)
(i32.const 1)
)
)
- (func $no-loops-but-one-use-but-tabled (; 5 ;) (type $0) (result i32)
+ (func $no-loops-but-one-use-but-tabled (; 3 ;) (type $0) (result i32)
(loop $loop-in (result i32)
(i32.const 1)
)
)
- (func $intoHere (; 6 ;) (type $1)
+ (func $intoHere (; 4 ;) (type $1)
(drop
(block (result i32)
(block $__inlined_func$yes (result i32)
@@ -79,17 +69,37 @@
(call $no-tooBig)
)
(drop
- (call $no-calls)
+ (block (result i32)
+ (block (result i32)
+ (block $__inlined_func$no-calls (result i32)
+ (block (result i32)
+ (block $__inlined_func$yes0 (result i32)
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ )
)
(drop
- (call $no-calls)
+ (block (result i32)
+ (block (result i32)
+ (block $__inlined_func$no-calls1 (result i32)
+ (block (result i32)
+ (block $__inlined_func$yes2 (result i32)
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ )
)
(drop
(block (result i32)
(block (result i32)
(block $__inlined_func$yes-calls-but-one-use (result i32)
(block (result i32)
- (block $__inlined_func$yes0 (result i32)
+ (block $__inlined_func$yes3 (result i32)
(i32.const 1)
)
)
@@ -98,25 +108,49 @@
)
)
(drop
- (call $no-loops)
+ (block (result i32)
+ (block $__inlined_func$no-loops (result i32)
+ (loop $loop-in (result i32)
+ (i32.const 1)
+ )
+ )
+ )
)
(drop
- (call $no-loops)
+ (block (result i32)
+ (block $__inlined_func$no-loops0 (result i32)
+ (loop $loop-in1 (result i32)
+ (i32.const 1)
+ )
+ )
+ )
)
(drop
(block (result i32)
(block $__inlined_func$yes-loops-but-one-use (result i32)
- (loop $loop-in (result i32)
+ (loop $loop-in2 (result i32)
(i32.const 1)
)
)
)
)
(drop
- (call $no-loops-but-one-use-but-exported)
+ (block (result i32)
+ (block $__inlined_func$no-loops-but-one-use-but-exported (result i32)
+ (loop $loop-in3 (result i32)
+ (i32.const 1)
+ )
+ )
+ )
)
(drop
- (call $no-loops-but-one-use-but-tabled)
+ (block (result i32)
+ (block $__inlined_func$no-loops-but-one-use-but-tabled (result i32)
+ (loop $loop-in4 (result i32)
+ (i32.const 1)
+ )
+ )
+ )
)
)
)
diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm
index 784edcf4c..46a388b48 100644
--- a/test/wasm-only.fromasm
+++ b/test/wasm-only.fromasm
@@ -1,5 +1,4 @@
(module
- (type $FUNCSIG$v (func))
(type $legaltype$illegalImport (func (param f64 i32 i32 i32)))
(type $legaltype$illegalImportResult (func (result i32)))
(type $legaltype$_fabsf (func (param f64) (result f64)))
@@ -7,7 +6,6 @@
(import "env" "table" (table 3 3 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (import "env" "abort" (func $abort))
(import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32)))
(import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32)))
(import "env" "_fabsf" (func $legalimport$_fabsf (param f64) (result f64)))
@@ -19,7 +17,7 @@
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$illegalResult))
(export "keepAlive" (func $keepAlive))
- (func $loads (; 5 ;)
+ (func $loads (; 4 ;)
(drop
(i32.load8_s
(i32.const 100)
@@ -131,7 +129,7 @@
)
)
)
- (func $stores (; 6 ;)
+ (func $stores (; 5 ;)
(local $0 i32)
(local $1 f64)
(local $2 f32)
@@ -224,7 +222,7 @@
(get_local $1)
)
)
- (func $test (; 7 ;)
+ (func $test (; 6 ;)
(local $0 f32)
(local $1 i32)
(set_local $1
@@ -233,7 +231,7 @@
)
)
)
- (func $i64s-div (; 8 ;) (param $0 i64) (param $1 i64) (result i64)
+ (func $i64s-div (; 7 ;) (param $0 i64) (param $1 i64) (result i64)
(if (result i64)
(i64.eqz
(get_local $1)
@@ -258,7 +256,7 @@
)
)
)
- (func $f32-to-int64 (; 9 ;) (param $0 f32) (result i64)
+ (func $f32-to-int64 (; 8 ;) (param $0 f32) (result i64)
(if (result i64)
(f32.ne
(get_local $0)
@@ -284,7 +282,7 @@
)
)
)
- (func $f64-to-int64 (; 10 ;) (param $0 f64) (result i64)
+ (func $f64-to-int64 (; 9 ;) (param $0 f64) (result i64)
(if (result i64)
(f64.ne
(get_local $0)
@@ -310,7 +308,7 @@
)
)
)
- (func $f32-to-uint64 (; 11 ;) (param $0 f32) (result i64)
+ (func $f32-to-uint64 (; 10 ;) (param $0 f32) (result i64)
(if (result i64)
(f32.ne
(get_local $0)
@@ -336,7 +334,7 @@
)
)
)
- (func $f64-to-uint64 (; 12 ;) (param $0 f64) (result i64)
+ (func $f64-to-uint64 (; 11 ;) (param $0 f64) (result i64)
(if (result i64)
(f64.ne
(get_local $0)
@@ -362,7 +360,7 @@
)
)
)
- (func $test64 (; 13 ;)
+ (func $test64 (; 12 ;)
(local $0 i64)
(local $1 f32)
(local $2 f64)
@@ -480,7 +478,7 @@
)
)
)
- (func $imports (; 14 ;) (result i64)
+ (func $imports (; 13 ;) (result i64)
(call $legalfunc$illegalImport
(f64.const -3.13159)
(i64.const 94489280523)
@@ -498,7 +496,7 @@
)
)
)
- (func $arg (; 15 ;) (param $0 i64)
+ (func $arg (; 14 ;) (param $0 i64)
(i64.store
(i32.const 100)
(get_local $0)
@@ -507,7 +505,7 @@
(get_local $0)
)
)
- (func $illegalParam (; 16 ;) (param $0 i32) (param $1 i64) (param $2 f64)
+ (func $illegalParam (; 15 ;) (param $0 i32) (param $1 i64) (param $2 f64)
(i64.store
(i32.const 100)
(get_local $1)
@@ -518,12 +516,12 @@
(f64.const 12.34)
)
)
- (func $call1 (; 17 ;) (param $0 i64) (result i64)
+ (func $call1 (; 16 ;) (param $0 i64) (result i64)
(call $call1
(get_local $0)
)
)
- (func $call2 (; 18 ;) (param $0 i64) (result i64)
+ (func $call2 (; 17 ;) (param $0 i64) (result i64)
(drop
(call $call2
(call $call2
@@ -533,18 +531,13 @@
)
(i64.const 245127260211081)
)
- (func $ifValue64 (; 19 ;) (param $0 i64) (param $1 i64) (result i64)
- (call $call2
- (get_local $0)
- )
- )
- (func $ifValue32 (; 20 ;) (param $0 i32) (param $1 i32) (result i32)
+ (func $ifValue32 (; 18 ;) (param $0 i32) (param $1 i32) (result i32)
(call $ifValue32
(get_local $0)
(get_local $1)
)
)
- (func $switch64 (; 21 ;) (param $0 i64) (result i32)
+ (func $switch64 (; 19 ;) (param $0 i64) (result i32)
(block $switch (result i32)
(block $switch-default
(block $switch-case0
@@ -579,7 +572,7 @@
(i32.const 1)
)
)
- (func $unreachable_leftovers (; 22 ;) (param $0 i32) (param $1 i32) (param $2 i32)
+ (func $unreachable_leftovers (; 20 ;) (param $0 i32) (param $1 i32) (param $2 i32)
(block $__rjto$0
(if
(i32.eqz
@@ -602,7 +595,7 @@
)
)
)
- (func $switch64TOOMUCH (; 23 ;) (param $0 i64) (result i32)
+ (func $switch64TOOMUCH (; 21 ;) (param $0 i64) (result i32)
(local $1 i32)
(local $2 i64)
(block $switch-default
@@ -679,7 +672,7 @@
)
(i32.const 44)
)
- (func $_memchr (; 24 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memchr (; 22 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@@ -910,7 +903,7 @@
(get_local $0)
)
)
- (func $keepAlive (; 25 ;)
+ (func $keepAlive (; 23 ;)
(call $loads)
(call $loads)
(call $stores)
@@ -950,14 +943,12 @@
)
)
(drop
- (call $ifValue64
- (i64.const 0)
+ (call $call2
(i64.const 0)
)
)
(drop
- (call $ifValue64
- (i64.const 0)
+ (call $call2
(i64.const 0)
)
)
@@ -1005,30 +996,8 @@
(i64.const 0)
)
)
- (if
- (i32.eqz
- (i32.wrap/i64
- (i64.shr_u
- (i64.const -9218868437227405312)
- (i64.const 32)
- )
- )
- )
- (call $abort)
- )
- (if
- (i32.eqz
- (i32.wrap/i64
- (i64.shr_u
- (i64.const -9218868437227405312)
- (i64.const 32)
- )
- )
- )
- (call $abort)
- )
)
- (func $legalstub$illegalParam (; 26 ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
+ (func $legalstub$illegalParam (; 24 ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
(call $illegalParam
(get_local $0)
(i64.or
@@ -1045,13 +1014,13 @@
(get_local $3)
)
)
- (func $legalstub$illegalResult (; 27 ;) (result i32)
+ (func $legalstub$illegalResult (; 25 ;) (result i32)
(set_global $tempRet0
(i32.const 2)
)
(i32.const 1)
)
- (func $legalfunc$illegalImport (; 28 ;) (param $0 f64) (param $1 i64) (param $2 i32)
+ (func $legalfunc$illegalImport (; 26 ;) (param $0 f64) (param $1 i64) (param $2 i32)
(call $legalimport$illegalImport
(get_local $0)
(i32.wrap/i64
@@ -1066,7 +1035,7 @@
(get_local $2)
)
)
- (func $legalfunc$_fabsf (; 29 ;) (param $0 f32) (result f32)
+ (func $legalfunc$_fabsf (; 27 ;) (param $0 f32) (result f32)
(f32.demote/f64
(call $legalimport$_fabsf
(f64.promote/f32
@@ -1075,7 +1044,7 @@
)
)
)
- (func $legalfunc$do_i64 (; 30 ;) (result i64)
+ (func $legalfunc$do_i64 (; 28 ;) (result i64)
(i64.or
(i64.extend_u/i32
(call $legalimport$do_i64)
diff --git a/test/wasm-only.fromasm.clamp b/test/wasm-only.fromasm.clamp
index 784edcf4c..46a388b48 100644
--- a/test/wasm-only.fromasm.clamp
+++ b/test/wasm-only.fromasm.clamp
@@ -1,5 +1,4 @@
(module
- (type $FUNCSIG$v (func))
(type $legaltype$illegalImport (func (param f64 i32 i32 i32)))
(type $legaltype$illegalImportResult (func (result i32)))
(type $legaltype$_fabsf (func (param f64) (result f64)))
@@ -7,7 +6,6 @@
(import "env" "table" (table 3 3 anyfunc))
(import "env" "memoryBase" (global $memoryBase i32))
(import "env" "tableBase" (global $tableBase i32))
- (import "env" "abort" (func $abort))
(import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32)))
(import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32)))
(import "env" "_fabsf" (func $legalimport$_fabsf (param f64) (result f64)))
@@ -19,7 +17,7 @@
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$illegalResult))
(export "keepAlive" (func $keepAlive))
- (func $loads (; 5 ;)
+ (func $loads (; 4 ;)
(drop
(i32.load8_s
(i32.const 100)
@@ -131,7 +129,7 @@
)
)
)
- (func $stores (; 6 ;)
+ (func $stores (; 5 ;)
(local $0 i32)
(local $1 f64)
(local $2 f32)
@@ -224,7 +222,7 @@
(get_local $1)
)
)
- (func $test (; 7 ;)
+ (func $test (; 6 ;)
(local $0 f32)
(local $1 i32)
(set_local $1
@@ -233,7 +231,7 @@
)
)
)
- (func $i64s-div (; 8 ;) (param $0 i64) (param $1 i64) (result i64)
+ (func $i64s-div (; 7 ;) (param $0 i64) (param $1 i64) (result i64)
(if (result i64)
(i64.eqz
(get_local $1)
@@ -258,7 +256,7 @@
)
)
)
- (func $f32-to-int64 (; 9 ;) (param $0 f32) (result i64)
+ (func $f32-to-int64 (; 8 ;) (param $0 f32) (result i64)
(if (result i64)
(f32.ne
(get_local $0)
@@ -284,7 +282,7 @@
)
)
)
- (func $f64-to-int64 (; 10 ;) (param $0 f64) (result i64)
+ (func $f64-to-int64 (; 9 ;) (param $0 f64) (result i64)
(if (result i64)
(f64.ne
(get_local $0)
@@ -310,7 +308,7 @@
)
)
)
- (func $f32-to-uint64 (; 11 ;) (param $0 f32) (result i64)
+ (func $f32-to-uint64 (; 10 ;) (param $0 f32) (result i64)
(if (result i64)
(f32.ne
(get_local $0)
@@ -336,7 +334,7 @@
)
)
)
- (func $f64-to-uint64 (; 12 ;) (param $0 f64) (result i64)
+ (func $f64-to-uint64 (; 11 ;) (param $0 f64) (result i64)
(if (result i64)
(f64.ne
(get_local $0)
@@ -362,7 +360,7 @@
)
)
)
- (func $test64 (; 13 ;)
+ (func $test64 (; 12 ;)
(local $0 i64)
(local $1 f32)
(local $2 f64)
@@ -480,7 +478,7 @@
)
)
)
- (func $imports (; 14 ;) (result i64)
+ (func $imports (; 13 ;) (result i64)
(call $legalfunc$illegalImport
(f64.const -3.13159)
(i64.const 94489280523)
@@ -498,7 +496,7 @@
)
)
)
- (func $arg (; 15 ;) (param $0 i64)
+ (func $arg (; 14 ;) (param $0 i64)
(i64.store
(i32.const 100)
(get_local $0)
@@ -507,7 +505,7 @@
(get_local $0)
)
)
- (func $illegalParam (; 16 ;) (param $0 i32) (param $1 i64) (param $2 f64)
+ (func $illegalParam (; 15 ;) (param $0 i32) (param $1 i64) (param $2 f64)
(i64.store
(i32.const 100)
(get_local $1)
@@ -518,12 +516,12 @@
(f64.const 12.34)
)
)
- (func $call1 (; 17 ;) (param $0 i64) (result i64)
+ (func $call1 (; 16 ;) (param $0 i64) (result i64)
(call $call1
(get_local $0)
)
)
- (func $call2 (; 18 ;) (param $0 i64) (result i64)
+ (func $call2 (; 17 ;) (param $0 i64) (result i64)
(drop
(call $call2
(call $call2
@@ -533,18 +531,13 @@
)
(i64.const 245127260211081)
)
- (func $ifValue64 (; 19 ;) (param $0 i64) (param $1 i64) (result i64)
- (call $call2
- (get_local $0)
- )
- )
- (func $ifValue32 (; 20 ;) (param $0 i32) (param $1 i32) (result i32)
+ (func $ifValue32 (; 18 ;) (param $0 i32) (param $1 i32) (result i32)
(call $ifValue32
(get_local $0)
(get_local $1)
)
)
- (func $switch64 (; 21 ;) (param $0 i64) (result i32)
+ (func $switch64 (; 19 ;) (param $0 i64) (result i32)
(block $switch (result i32)
(block $switch-default
(block $switch-case0
@@ -579,7 +572,7 @@
(i32.const 1)
)
)
- (func $unreachable_leftovers (; 22 ;) (param $0 i32) (param $1 i32) (param $2 i32)
+ (func $unreachable_leftovers (; 20 ;) (param $0 i32) (param $1 i32) (param $2 i32)
(block $__rjto$0
(if
(i32.eqz
@@ -602,7 +595,7 @@
)
)
)
- (func $switch64TOOMUCH (; 23 ;) (param $0 i64) (result i32)
+ (func $switch64TOOMUCH (; 21 ;) (param $0 i64) (result i32)
(local $1 i32)
(local $2 i64)
(block $switch-default
@@ -679,7 +672,7 @@
)
(i32.const 44)
)
- (func $_memchr (; 24 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memchr (; 22 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@@ -910,7 +903,7 @@
(get_local $0)
)
)
- (func $keepAlive (; 25 ;)
+ (func $keepAlive (; 23 ;)
(call $loads)
(call $loads)
(call $stores)
@@ -950,14 +943,12 @@
)
)
(drop
- (call $ifValue64
- (i64.const 0)
+ (call $call2
(i64.const 0)
)
)
(drop
- (call $ifValue64
- (i64.const 0)
+ (call $call2
(i64.const 0)
)
)
@@ -1005,30 +996,8 @@
(i64.const 0)
)
)
- (if
- (i32.eqz
- (i32.wrap/i64
- (i64.shr_u
- (i64.const -9218868437227405312)
- (i64.const 32)
- )
- )
- )
- (call $abort)
- )
- (if
- (i32.eqz
- (i32.wrap/i64
- (i64.shr_u
- (i64.const -9218868437227405312)
- (i64.const 32)
- )
- )
- )
- (call $abort)
- )
)
- (func $legalstub$illegalParam (; 26 ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
+ (func $legalstub$illegalParam (; 24 ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
(call $illegalParam
(get_local $0)
(i64.or
@@ -1045,13 +1014,13 @@
(get_local $3)
)
)
- (func $legalstub$illegalResult (; 27 ;) (result i32)
+ (func $legalstub$illegalResult (; 25 ;) (result i32)
(set_global $tempRet0
(i32.const 2)
)
(i32.const 1)
)
- (func $legalfunc$illegalImport (; 28 ;) (param $0 f64) (param $1 i64) (param $2 i32)
+ (func $legalfunc$illegalImport (; 26 ;) (param $0 f64) (param $1 i64) (param $2 i32)
(call $legalimport$illegalImport
(get_local $0)
(i32.wrap/i64
@@ -1066,7 +1035,7 @@
(get_local $2)
)
)
- (func $legalfunc$_fabsf (; 29 ;) (param $0 f32) (result f32)
+ (func $legalfunc$_fabsf (; 27 ;) (param $0 f32) (result f32)
(f32.demote/f64
(call $legalimport$_fabsf
(f64.promote/f32
@@ -1075,7 +1044,7 @@
)
)
)
- (func $legalfunc$do_i64 (; 30 ;) (result i64)
+ (func $legalfunc$do_i64 (; 28 ;) (result i64)
(i64.or
(i64.extend_u/i32
(call $legalimport$do_i64)
diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise
index a35dda983..72e62809e 100644
--- a/test/wasm-only.fromasm.imprecise
+++ b/test/wasm-only.fromasm.imprecise
@@ -1,12 +1,10 @@
(module
- (type $FUNCSIG$v (func))
(type $legaltype$illegalImport (func (param f64 i32 i32 i32)))
(type $legaltype$illegalImportResult (func (result i32)))
(type $legaltype$_fabsf (func (param f64) (result f64)))
(import "env" "memory" (memory $0 256 256))
(import "env" "table" (table 3 3 anyfunc))
(import "env" "tableBase" (global $tableBase i32))
- (import "env" "abort" (func $abort))
(import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32)))
(import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32)))
(import "env" "_fabsf" (func $legalimport$_fabsf (param f64) (result f64)))
@@ -17,7 +15,7 @@
(export "illegalParam" (func $legalstub$illegalParam))
(export "illegalResult" (func $legalstub$illegalResult))
(export "keepAlive" (func $keepAlive))
- (func $stores (; 5 ;)
+ (func $stores (; 4 ;)
(local $0 i32)
(local $1 f64)
(local $2 f32)
@@ -110,7 +108,7 @@
(get_local $1)
)
)
- (func $test (; 6 ;)
+ (func $test (; 5 ;)
(local $0 f32)
(local $1 i32)
(set_local $1
@@ -119,7 +117,7 @@
)
)
)
- (func $test64 (; 7 ;)
+ (func $test64 (; 6 ;)
(local $0 i64)
(local $1 i32)
(local $2 i64)
@@ -161,7 +159,7 @@
)
)
)
- (func $imports (; 8 ;) (result i64)
+ (func $imports (; 7 ;) (result i64)
(call $legalfunc$illegalImport
(f64.const -3.13159)
(i64.const 94489280523)
@@ -179,7 +177,7 @@
)
)
)
- (func $arg (; 9 ;) (param $0 i64)
+ (func $arg (; 8 ;) (param $0 i64)
(i64.store
(i32.const 100)
(get_local $0)
@@ -188,7 +186,7 @@
(get_local $0)
)
)
- (func $illegalParam (; 10 ;) (param $0 i32) (param $1 i64) (param $2 f64)
+ (func $illegalParam (; 9 ;) (param $0 i32) (param $1 i64) (param $2 f64)
(i64.store
(i32.const 100)
(get_local $1)
@@ -199,12 +197,12 @@
(f64.const 12.34)
)
)
- (func $call1 (; 11 ;) (param $0 i64) (result i64)
+ (func $call1 (; 10 ;) (param $0 i64) (result i64)
(call $call1
(get_local $0)
)
)
- (func $call2 (; 12 ;) (param $0 i64) (result i64)
+ (func $call2 (; 11 ;) (param $0 i64) (result i64)
(drop
(call $call2
(call $call2
@@ -214,18 +212,13 @@
)
(i64.const 245127260211081)
)
- (func $ifValue64 (; 13 ;) (param $0 i64) (param $1 i64) (result i64)
- (call $call2
- (get_local $0)
- )
- )
- (func $ifValue32 (; 14 ;) (param $0 i32) (param $1 i32) (result i32)
+ (func $ifValue32 (; 12 ;) (param $0 i32) (param $1 i32) (result i32)
(call $ifValue32
(get_local $0)
(get_local $1)
)
)
- (func $switch64 (; 15 ;) (param $0 i64) (result i32)
+ (func $switch64 (; 13 ;) (param $0 i64) (result i32)
(block $switch (result i32)
(block $switch-default
(block $switch-case0
@@ -260,7 +253,7 @@
(i32.const 1)
)
)
- (func $unreachable_leftovers (; 16 ;) (param $0 i32) (param $1 i32) (param $2 i32)
+ (func $unreachable_leftovers (; 14 ;) (param $0 i32) (param $1 i32) (param $2 i32)
(block $__rjto$0
(if
(i32.eqz
@@ -283,7 +276,7 @@
)
)
)
- (func $switch64TOOMUCH (; 17 ;) (param $0 i64) (result i32)
+ (func $switch64TOOMUCH (; 15 ;) (param $0 i64) (result i32)
(local $1 i32)
(local $2 i64)
(block $switch-default
@@ -360,7 +353,7 @@
)
(i32.const 44)
)
- (func $_memchr (; 18 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memchr (; 16 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@@ -591,7 +584,7 @@
(get_local $0)
)
)
- (func $keepAlive (; 19 ;)
+ (func $keepAlive (; 17 ;)
(call $stores)
(call $stores)
(call $test)
@@ -629,14 +622,12 @@
)
)
(drop
- (call $ifValue64
- (i64.const 0)
+ (call $call2
(i64.const 0)
)
)
(drop
- (call $ifValue64
- (i64.const 0)
+ (call $call2
(i64.const 0)
)
)
@@ -684,30 +675,8 @@
(i64.const 0)
)
)
- (if
- (i32.eqz
- (i32.wrap/i64
- (i64.shr_u
- (i64.const -9218868437227405312)
- (i64.const 32)
- )
- )
- )
- (call $abort)
- )
- (if
- (i32.eqz
- (i32.wrap/i64
- (i64.shr_u
- (i64.const -9218868437227405312)
- (i64.const 32)
- )
- )
- )
- (call $abort)
- )
)
- (func $legalstub$illegalParam (; 20 ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
+ (func $legalstub$illegalParam (; 18 ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
(call $illegalParam
(get_local $0)
(i64.or
@@ -724,13 +693,13 @@
(get_local $3)
)
)
- (func $legalstub$illegalResult (; 21 ;) (result i32)
+ (func $legalstub$illegalResult (; 19 ;) (result i32)
(set_global $tempRet0
(i32.const 2)
)
(i32.const 1)
)
- (func $legalfunc$illegalImport (; 22 ;) (param $0 f64) (param $1 i64) (param $2 i32)
+ (func $legalfunc$illegalImport (; 20 ;) (param $0 f64) (param $1 i64) (param $2 i32)
(call $legalimport$illegalImport
(get_local $0)
(i32.wrap/i64
@@ -745,7 +714,7 @@
(get_local $2)
)
)
- (func $legalfunc$_fabsf (; 23 ;) (param $0 f32) (result f32)
+ (func $legalfunc$_fabsf (; 21 ;) (param $0 f32) (result f32)
(f32.demote/f64
(call $legalimport$_fabsf
(f64.promote/f32
@@ -754,7 +723,7 @@
)
)
)
- (func $legalfunc$do_i64 (; 24 ;) (result i64)
+ (func $legalfunc$do_i64 (; 22 ;) (result i64)
(i64.or
(i64.extend_u/i32
(call $legalimport$do_i64)