diff options
-rw-r--r-- | src/passes/FuncCastEmulation.cpp | 3 | ||||
-rw-r--r-- | src/passes/pass.cpp | 2 | ||||
-rw-r--r-- | test/passes/fpcast-emu.txt | 37 | ||||
-rw-r--r-- | test/passes/fpcast-emu.wast | 22 |
4 files changed, 62 insertions, 2 deletions
diff --git a/src/passes/FuncCastEmulation.cpp b/src/passes/FuncCastEmulation.cpp index 59a2588da..013e9403e 100644 --- a/src/passes/FuncCastEmulation.cpp +++ b/src/passes/FuncCastEmulation.cpp @@ -142,9 +142,10 @@ struct ParallelFuncCastEmulation : public WalkerPass<PostWalker<ParallelFuncCast curr->operands.push_back(LiteralUtils::makeZero(i64, *getModule())); } // Set the new types + curr->fullType = ABIType; auto oldType = curr->type; curr->type = i64; - curr->fullType = ABIType; + curr->finalize(); // may be unreachable // Fix up return value replaceCurrent(fromABI(curr, oldType, getModule())); } diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 6518a6f3d..be7365998 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -98,7 +98,6 @@ void PassRegistry::registerPasses() { registerPass("print-minified", "print in minified s-expression format", createMinifiedPrinterPass); registerPass("print-full", "print in full s-expression format", createFullPrinterPass); registerPass("print-call-graph", "print call graph", createPrintCallGraphPass); - registerPass("rse", "remove redundant set_locals", createRedundantSetEliminationPass); registerPass("relooper-jump-threading", "thread relooper jumps (fastcomp output only)", createRelooperJumpThreadingPass); registerPass("remove-imports", "removes imports and replaces them with nops", createRemoveImportsPass); registerPass("remove-memory", "removes memory segments", createRemoveMemoryPass); @@ -108,6 +107,7 @@ void PassRegistry::registerPasses() { registerPass("reorder-functions", "sorts functions by access frequency", createReorderFunctionsPass); registerPass("reorder-locals", "sorts locals by access frequency", createReorderLocalsPass); registerPass("rereloop", "re-optimize control flow using the relooper algorithm", createReReloopPass); + registerPass("rse", "remove redundant set_locals", createRedundantSetEliminationPass); registerPass("simplify-locals", "miscellaneous locals-related optimizations", createSimplifyLocalsPass); registerPass("safe-heap", "instrument loads and stores to check for invalid behavior", createSafeHeapPass); registerPass("simplify-locals-notee", "miscellaneous locals-related optimizations", createSimplifyLocalsNoTeePass); diff --git a/test/passes/fpcast-emu.txt b/test/passes/fpcast-emu.txt index 94b92ad17..b1560517c 100644 --- a/test/passes/fpcast-emu.txt +++ b/test/passes/fpcast-emu.txt @@ -292,3 +292,40 @@ ) ) ) +(module + (type $0 (func (param i64))) + (type $1 (func (param f32) (result i64))) + (type $FUNCSIG$jjjjjjjjjjjjjjjj (func (param i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64) (result i64))) + (global $global$0 (mut i32) (i32.const 10)) + (table 42 42 anyfunc) + (export "func_106" (func $0)) + (func $0 (; 0 ;) (type $1) (param $0 f32) (result i64) + (block $label$1 (result i64) + (loop $label$2 + (set_global $global$0 + (i32.const 0) + ) + (call_indirect (type $FUNCSIG$jjjjjjjjjjjjjjjj) + (br $label$1 + (i64.const 4294967295) + ) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i32.const 18) + ) + ) + ) + ) +) diff --git a/test/passes/fpcast-emu.wast b/test/passes/fpcast-emu.wast index cef0d0deb..654cf64e1 100644 --- a/test/passes/fpcast-emu.wast +++ b/test/passes/fpcast-emu.wast @@ -45,4 +45,26 @@ ) ) ) +(module + (type $0 (func (param i64))) + (type $1 (func (param f32) (result i64))) + (global $global$0 (mut i32) (i32.const 10)) + (table 42 42 anyfunc) + (export "func_106" (func $0)) + (func $0 (; 0 ;) (type $1) (param $0 f32) (result i64) + (block $label$1 (result i64) + (loop $label$2 + (set_global $global$0 + (i32.const 0) + ) + (call_indirect (type $0) + (br $label$1 + (i64.const 4294967295) + ) + (i32.const 18) + ) + ) + ) + ) +) |