Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/passes/Memory64Lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ struct Memory64Lowering : public WalkerPass<PostWalker<Memory64Lowering>> {
}
}
}

void run(Module* module) override {
if (!module->features.has(FeatureSet::Memory64)) {
return;
}
super::run(module);
module->features.disable(FeatureSet::Memory64);
}
};

Pass* createMemory64LoweringPass() { return new Memory64Lowering(); }
Expand Down
8 changes: 8 additions & 0 deletions src/passes/SignExtLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ struct SignExtLowering : public WalkerPass<PostWalker<SignExtLowering>> {
}
}
}

void run(Module* module) override {
if (!module->features.has(FeatureSet::SignExt)) {
return;
}
super::run(module);
module->features.disable(FeatureSet::SignExt);
}
};

Pass* createSignExtLoweringPass() { return new SignExtLowering(); }
Expand Down
3 changes: 2 additions & 1 deletion src/passes/pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ void PassRegistry::registerPasses() {
"apply more specific subtypes to signature types where possible",
createSignatureRefiningPass);
registerPass("signext-lowering",
"lower sign-ext operations to wasm mvp",
"lower sign-ext operations to wasm mvp and disable the sign "
"extension feature",
createSignExtLoweringPass);
registerPass("simplify-globals",
"miscellaneous globals-related optimizations",
Expand Down
3 changes: 2 additions & 1 deletion test/lit/help/wasm-opt.test
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@
;; CHECK-NEXT: signature types where possible
;; CHECK-NEXT:
;; CHECK-NEXT: --signext-lowering lower sign-ext operations to
;; CHECK-NEXT: wasm mvp
;; CHECK-NEXT: wasm mvp and disable the sign
;; CHECK-NEXT: extension feature
;; CHECK-NEXT:
;; CHECK-NEXT: --simplify-globals miscellaneous globals-related
;; CHECK-NEXT: optimizations
Expand Down
3 changes: 2 additions & 1 deletion test/lit/help/wasm2js.test
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@
;; CHECK-NEXT: signature types where possible
;; CHECK-NEXT:
;; CHECK-NEXT: --signext-lowering lower sign-ext operations to
;; CHECK-NEXT: wasm mvp
;; CHECK-NEXT: wasm mvp and disable the sign
;; CHECK-NEXT: extension feature
;; CHECK-NEXT:
;; CHECK-NEXT: --simplify-globals miscellaneous globals-related
;; CHECK-NEXT: optimizations
Expand Down
9 changes: 9 additions & 0 deletions test/lit/passes/memory64-lowering-features.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;; RUN: wasm-opt %s --enable-memory64 --print-features --print --memory64-lowering --print-features | filecheck %s

;; Check that the --memory64-lowering pass disables the signext feature.

;; CHECK: --enable-memory64
;; CHECK: (module
;; CHECK-NOT: --enable-memory64

(module)
9 changes: 9 additions & 0 deletions test/lit/passes/signext-lowering-features.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;; RUN: wasm-opt %s --enable-sign-ext --print-features --print --signext-lowering --print-features | filecheck %s

;; Check that the --signext-lowering pass disables the signext feature.

;; CHECK: --enable-sign-ext
;; CHECK: (module
;; CHECK-NOT: --enable-sign-ext

(module)