diff options
-rw-r--r-- | src/passes/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/passes/NoExitRuntime.cpp | 65 | ||||
-rw-r--r-- | src/passes/pass.cpp | 4 | ||||
-rw-r--r-- | src/passes/passes.h | 1 | ||||
-rw-r--r-- | test/lit/help/wasm-opt.test | 4 | ||||
-rw-r--r-- | test/lit/help/wasm2js.test | 4 | ||||
-rw-r--r-- | test/passes/no-exit-runtime.txt | 166 | ||||
-rw-r--r-- | test/passes/no-exit-runtime.wast | 47 |
8 files changed, 0 insertions, 292 deletions
diff --git a/src/passes/CMakeLists.txt b/src/passes/CMakeLists.txt index e24072424..7e5960d4b 100644 --- a/src/passes/CMakeLists.txt +++ b/src/passes/CMakeLists.txt @@ -58,7 +58,6 @@ set(passes_SOURCES MinifyImportsAndExports.cpp NameList.cpp NameTypes.cpp - NoExitRuntime.cpp OnceReduction.cpp OptimizeAddedConstants.cpp OptimizeInstructions.cpp diff --git a/src/passes/NoExitRuntime.cpp b/src/passes/NoExitRuntime.cpp deleted file mode 100644 index e15ef81bc..000000000 --- a/src/passes/NoExitRuntime.cpp +++ /dev/null @@ -1,65 +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. - */ - -// -// Assumes the program will never exit the runtime (as in the emscripten -// NO_EXIT_RUNTIME option). That means that atexit()s do not need to be -// run. -// - -#include <asmjs/shared-constants.h> -#include <pass.h> -#include <wasm-builder.h> -#include <wasm.h> - -namespace wasm { - -struct NoExitRuntime : public WalkerPass<PostWalker<NoExitRuntime>> { - bool isFunctionParallel() override { return true; } - - Pass* create() override { return new NoExitRuntime; } - - // Remove all possible manifestations of atexit, across llvm wasm - // backend. - std::array<Name, 4> ATEXIT_NAMES = { - {"___cxa_atexit", "__cxa_atexit", "_atexit", "atexit"}}; - - void visitCall(Call* curr) { - auto* import = getModule()->getFunctionOrNull(curr->target); - if (!import || !import->imported() || import->module != ENV) { - return; - } - for (auto name : ATEXIT_NAMES) { - if (name == import->base) { - // Remove the call, and drop the arguments (which may have side - // effects); let other passes clean that up more. - Builder builder(*getModule()); - std::vector<Expression*> args; - for (auto* operand : curr->operands) { - args.push_back(builder.makeDrop(operand)); - } - // Ensure the block has the right type using the last arg. - args.push_back(builder.replaceWithIdenticalType(curr)); - replaceCurrent(builder.makeBlock(args)); - break; - } - } - } -}; - -Pass* createNoExitRuntimePass() { return new NoExitRuntime(); } - -} // namespace wasm diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 99288cc6e..9158f22dd 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -251,10 +251,6 @@ void PassRegistry::registerPasses() { createModAsyncifyNeverUnwindPass); registerPass("nm", "name list", createNameListPass); registerPass("name-types", "(re)name all heap types", createNameTypesPass); - registerPass("no-exit-runtime", - "removes calls to atexit(), which is valid if the C runtime " - "will never be exited", - createNoExitRuntimePass); registerPass("once-reduction", "reduces calls to code that only runs once", createOnceReductionPass); diff --git a/src/passes/passes.h b/src/passes/passes.h index 0e72bb518..501edccc7 100644 --- a/src/passes/passes.h +++ b/src/passes/passes.h @@ -79,7 +79,6 @@ Pass* createMinifyImportsAndExportsAndModulesPass(); Pass* createMetricsPass(); Pass* createNameListPass(); Pass* createNameTypesPass(); -Pass* createNoExitRuntimePass(); Pass* createOnceReductionPass(); Pass* createOptimizeAddedConstantsPass(); Pass* createOptimizeAddedConstantsPropagatePass(); diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test index ef6a7637b..0179b2fbe 100644 --- a/test/lit/help/wasm-opt.test +++ b/test/lit/help/wasm-opt.test @@ -252,10 +252,6 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --nm name list ;; CHECK-NEXT: -;; CHECK-NEXT: --no-exit-runtime removes calls to atexit(), which -;; CHECK-NEXT: is valid if the C runtime will -;; CHECK-NEXT: never be exited -;; CHECK-NEXT: ;; CHECK-NEXT: --once-reduction reduces calls to code that only ;; CHECK-NEXT: runs once ;; CHECK-NEXT: diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index a10eee344..f02ce4c2a 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -214,10 +214,6 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --nm name list ;; CHECK-NEXT: -;; CHECK-NEXT: --no-exit-runtime removes calls to atexit(), which -;; CHECK-NEXT: is valid if the C runtime will -;; CHECK-NEXT: never be exited -;; CHECK-NEXT: ;; CHECK-NEXT: --once-reduction reduces calls to code that only ;; CHECK-NEXT: runs once ;; CHECK-NEXT: diff --git a/test/passes/no-exit-runtime.txt b/test/passes/no-exit-runtime.txt deleted file mode 100644 index 6f367dacc..000000000 --- a/test/passes/no-exit-runtime.txt +++ /dev/null @@ -1,166 +0,0 @@ -(module - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (import "env" "atexit" (func $fimport$0 (param i32 i32) (result i32))) - (import "env" "__cxa_atexit" (func $fimport$1 (param i32 i32) (result i32))) - (import "env" "_atexit" (func $fimport$2 (param i32 i32) (result i32))) - (import "env" "___cxa_atexit" (func $fimport$3 (param i32 i32) (result i32))) - (import "env" "other" (func $fimport$4 (param i32 i32) (result i32))) - (func $caller - (drop - (block (result i32) - (drop - (i32.const 0) - ) - (drop - (i32.const 1) - ) - (i32.const 0) - ) - ) - (drop - (block (result i32) - (drop - (i32.const 0) - ) - (drop - (i32.const 1) - ) - (i32.const 0) - ) - ) - (drop - (block (result i32) - (drop - (i32.const 0) - ) - (drop - (i32.const 1) - ) - (i32.const 0) - ) - ) - (drop - (block (result i32) - (drop - (i32.const 0) - ) - (drop - (i32.const 1) - ) - (i32.const 0) - ) - ) - (drop - (call $fimport$4 - (i32.const 0) - (i32.const 1) - ) - ) - (drop - (block - (drop - (unreachable) - ) - (drop - (i32.const 1) - ) - (unreachable) - ) - ) - ) - (func $side-effects (result i32) - (local $x i32) - (drop - (block (result i32) - (drop - (local.tee $x - (i32.const 1) - ) - ) - (drop - (i32.const 2) - ) - (i32.const 0) - ) - ) - (drop - (block (result i32) - (drop - (i32.const 3) - ) - (drop - (local.tee $x - (i32.const 4) - ) - ) - (i32.const 0) - ) - ) - (drop - (block (result i32) - (drop - (local.tee $x - (i32.const 5) - ) - ) - (drop - (local.tee $x - (i32.const 6) - ) - ) - (i32.const 0) - ) - ) - (drop - (block - (drop - (unreachable) - ) - (drop - (local.tee $x - (i32.const 7) - ) - ) - (unreachable) - ) - ) - (drop - (block - (drop - (local.tee $x - (i32.const 8) - ) - ) - (drop - (unreachable) - ) - (unreachable) - ) - ) - (drop - (block - (drop - (unreachable) - ) - (drop - (i32.const 9) - ) - (unreachable) - ) - ) - (drop - (block - (drop - (i32.const 10) - ) - (drop - (unreachable) - ) - (unreachable) - ) - ) - (local.get $x) - ) -) diff --git a/test/passes/no-exit-runtime.wast b/test/passes/no-exit-runtime.wast deleted file mode 100644 index 15966e1db..000000000 --- a/test/passes/no-exit-runtime.wast +++ /dev/null @@ -1,47 +0,0 @@ -(module - (import "env" "atexit" (func $fimport$0 (param i32 i32) (result i32))) - (import "env" "__cxa_atexit" (func $fimport$1 (param i32 i32) (result i32))) - (import "env" "_atexit" (func $fimport$2 (param i32 i32) (result i32))) - (import "env" "___cxa_atexit" (func $fimport$3 (param i32 i32) (result i32))) - (import "env" "other" (func $fimport$4 (param i32 i32) (result i32))) - (func $caller - (drop (call $fimport$0 (i32.const 0) (i32.const 1))) - (drop (call $fimport$1 (i32.const 0) (i32.const 1))) - (drop (call $fimport$2 (i32.const 0) (i32.const 1))) - (drop (call $fimport$3 (i32.const 0) (i32.const 1))) - (drop (call $fimport$4 (i32.const 0) (i32.const 1))) - (drop (call $fimport$0 (unreachable) (i32.const 1))) - ) - (func $side-effects (result i32) - (local $x i32) - (drop (call $fimport$0 - (local.tee $x (i32.const 1)) - (i32.const 2) - )) - (drop (call $fimport$0 - (i32.const 3) - (local.tee $x (i32.const 4)) - )) - (drop (call $fimport$0 - (local.tee $x (i32.const 5)) - (local.tee $x (i32.const 6)) - )) - (drop (call $fimport$0 - (unreachable) - (local.tee $x (i32.const 7)) - )) - (drop (call $fimport$0 - (local.tee $x (i32.const 8)) - (unreachable) - )) - (drop (call $fimport$0 - (unreachable) - (i32.const 9) - )) - (drop (call $fimport$0 - (i32.const 10) - (unreachable) - )) - (local.get $x) - ) -) |