From 97bb0bdacbb8ccd59aca116c66f0f43f322aebaa Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 26 Jan 2022 11:10:26 -0800 Subject: Remove NoExitRuntime pass (#4431) After emscripten-core/emscripten#15905 lands Emscripten will no longer use it, and nothing else needs it AFAIK. --- src/passes/CMakeLists.txt | 1 - src/passes/NoExitRuntime.cpp | 65 -------------------------------------------- src/passes/pass.cpp | 4 --- src/passes/passes.h | 1 - 4 files changed, 71 deletions(-) delete mode 100644 src/passes/NoExitRuntime.cpp (limited to 'src') 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 -#include -#include -#include - -namespace wasm { - -struct NoExitRuntime : public WalkerPass> { - bool isFunctionParallel() override { return true; } - - Pass* create() override { return new NoExitRuntime; } - - // Remove all possible manifestations of atexit, across llvm wasm - // backend. - std::array 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 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(); -- cgit v1.2.3