diff --git a/src/passes/TranslateEH.cpp b/src/passes/TranslateEH.cpp index d8a00446811..760c4b656d2 100644 --- a/src/passes/TranslateEH.cpp +++ b/src/passes/TranslateEH.cpp @@ -15,7 +15,7 @@ */ // -// TranslateEHOldToNew translates the old Phase 3 EH instructions, which include +// TranslateToNewEH translates the old Phase 3 EH instructions, which include // try, catch, catch_all, delegate, and rethrow, into the new EH instructions, // which include try_table (with catch / catch_ref / catch_all / catch_all_ref) // and throw_ref, passed at the Oct 2023 CG meeting. This translator can be used @@ -24,12 +24,6 @@ // end of the Binaryen pipeline to produce binaries for the new spec while the // end-to-end toolchain implementation for the new spec is in progress. // -// TODO -// TranslateEHNewToOld translates the new EH instructions to the old ones. This -// can be used as a stopgap tool while Binaryen implementation for the whole -// optimization pipeline is not complete but we need to test our LLVM -// implementation for the new spec. This has not been implemented yet. -// #include #include @@ -45,8 +39,7 @@ namespace { // Translates the old EH instructions (try / catch / catch_all / delegate / // rethrow) into the new ones (try_table (+ catch / catch_ref / catch_all / // catch_all_ref) / throw_ref). -struct TranslateEHOldToNew - : public WalkerPass> { +struct TranslateToNewEH : public WalkerPass> { bool isFunctionParallel() override { return true; } // Scans and records which try labels are targeted by delegates and rethrows. @@ -201,10 +194,8 @@ struct TranslateEHOldToNew // exnref) tuples for a short time. std::unordered_map typeToScratchLocal; - bool refinalize = false; - std::unique_ptr create() override { - return std::make_unique(); + return std::make_unique(); } // Get a scratch local for a given type. These locals are used to contain @@ -680,7 +671,6 @@ struct TranslateEHOldToNew } void visitTry(Try* curr) { - refinalize = true; Builder builder(*getModule()); Block* outerBlock = nullptr; auto it = delegateTargetToBrTarget.find(curr->name); @@ -807,15 +797,8 @@ struct TranslateEHOldToNew } }; -struct TranslateEHNewToOld - : public WalkerPass> { - // TODO -}; - } // namespace -Pass* createTranslateEHOldToNewPass() { return new TranslateEHOldToNew(); } - -Pass* createTranslateEHNewToOldPass() { return new TranslateEHNewToOld(); } +Pass* createTranslateToNewEHPass() { return new TranslateToNewEH(); } } // namespace wasm diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 5f5db2f7f49..0b7d3426ba8 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -491,9 +491,9 @@ void PassRegistry::registerPasses() { registerPass("strip-target-features", "strip the wasm target features section", createStripTargetFeaturesPass); - registerPass("translate-eh-old-to-new", + registerPass("translate-to-new-eh", "translate old EH instructions to new ones", - createTranslateEHOldToNewPass); + createTranslateToNewEHPass); registerPass("trap-mode-clamp", "replace trapping operations with clamping semantics", createTrapModeClamp); diff --git a/src/passes/passes.h b/src/passes/passes.h index 66535bdc0e2..8e263032acd 100644 --- a/src/passes/passes.h +++ b/src/passes/passes.h @@ -164,7 +164,7 @@ Pass* createStripEHPass(); Pass* createStubUnsupportedJSOpsPass(); Pass* createSSAifyPass(); Pass* createSSAifyNoMergePass(); -Pass* createTranslateEHOldToNewPass(); +Pass* createTranslateToNewEHPass(); Pass* createTrapModeClamp(); Pass* createTrapModeJS(); Pass* createTupleOptimizationPass(); diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test index 07d218007d7..fc33fce8d60 100644 --- a/test/lit/help/wasm-opt.test +++ b/test/lit/help/wasm-opt.test @@ -486,7 +486,7 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --symbolmap (alias for print-function-map) ;; CHECK-NEXT: -;; CHECK-NEXT: --translate-eh-old-to-new translate old EH instructions to +;; CHECK-NEXT: --translate-to-new-eh translate old EH instructions to ;; CHECK-NEXT: new ones ;; CHECK-NEXT: ;; CHECK-NEXT: --trap-mode-clamp replace trapping operations with diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index e81d07718ea..7db56410167 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -445,7 +445,7 @@ ;; CHECK-NEXT: ;; CHECK-NEXT: --symbolmap (alias for print-function-map) ;; CHECK-NEXT: -;; CHECK-NEXT: --translate-eh-old-to-new translate old EH instructions to +;; CHECK-NEXT: --translate-to-new-eh translate old EH instructions to ;; CHECK-NEXT: new ones ;; CHECK-NEXT: ;; CHECK-NEXT: --trap-mode-clamp replace trapping operations with diff --git a/test/lit/passes/translate-eh-old-to-new.wast b/test/lit/passes/translate-to-new-eh.wast similarity index 99% rename from test/lit/passes/translate-eh-old-to-new.wast rename to test/lit/passes/translate-to-new-eh.wast index 014661b2769..da429bea46a 100644 --- a/test/lit/passes/translate-eh-old-to-new.wast +++ b/test/lit/passes/translate-to-new-eh.wast @@ -1,5 +1,5 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. -;; RUN: wasm-opt %s -all --translate-eh-old-to-new -S -o - | filecheck %s +;; RUN: wasm-opt %s -all --translate-to-new-eh -S -o - | filecheck %s (module ;; CHECK: (type $0 (func (result i32 i64)))