Skip to content

Commit

Permalink
[EH] Change translator option name (WebAssembly#6259)
Browse files Browse the repository at this point in the history
The previous name feels too verbose and unwieldy.

This also removes the "new-to-old EH" placeholder. I think it'd be
better to add it back when it is actually added.
  • Loading branch information
aheejin committed Jan 31, 2024
1 parent 8504571 commit cf14a9f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 27 deletions.
25 changes: 4 additions & 21 deletions src/passes/TranslateEH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <ir/drop.h>
#include <ir/find_all.h>
Expand All @@ -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<PostWalker<TranslateEHOldToNew>> {
struct TranslateToNewEH : public WalkerPass<PostWalker<TranslateToNewEH>> {
bool isFunctionParallel() override { return true; }

// Scans and records which try labels are targeted by delegates and rethrows.
Expand Down Expand Up @@ -201,10 +194,8 @@ struct TranslateEHOldToNew
// exnref) tuples for a short time.
std::unordered_map<Type, Index> typeToScratchLocal;

bool refinalize = false;

std::unique_ptr<Pass> create() override {
return std::make_unique<TranslateEHOldToNew>();
return std::make_unique<TranslateToNewEH>();
}

// Get a scratch local for a given type. These locals are used to contain
Expand Down Expand Up @@ -680,7 +671,6 @@ struct TranslateEHOldToNew
}

void visitTry(Try* curr) {
refinalize = true;
Builder builder(*getModule());
Block* outerBlock = nullptr;
auto it = delegateTargetToBrTarget.find(curr->name);
Expand Down Expand Up @@ -807,15 +797,8 @@ struct TranslateEHOldToNew
}
};

struct TranslateEHNewToOld
: public WalkerPass<PostWalker<TranslateEHNewToOld>> {
// TODO
};

} // namespace

Pass* createTranslateEHOldToNewPass() { return new TranslateEHOldToNew(); }

Pass* createTranslateEHNewToOldPass() { return new TranslateEHNewToOld(); }
Pass* createTranslateToNewEHPass() { return new TranslateToNewEH(); }

} // namespace wasm
4 changes: 2 additions & 2 deletions src/passes/pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/passes/passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Pass* createStripEHPass();
Pass* createStubUnsupportedJSOpsPass();
Pass* createSSAifyPass();
Pass* createSSAifyNoMergePass();
Pass* createTranslateEHOldToNewPass();
Pass* createTranslateToNewEHPass();
Pass* createTrapModeClamp();
Pass* createTrapModeJS();
Pass* createTupleOptimizationPass();
Expand Down
2 changes: 1 addition & 1 deletion test/lit/help/wasm-opt.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/lit/help/wasm2js.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)))
Expand Down

0 comments on commit cf14a9f

Please sign in to comment.