summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/SignExtLowering.cpp8
-rw-r--r--src/passes/pass.cpp3
-rw-r--r--test/lit/help/wasm-opt.test3
-rw-r--r--test/lit/help/wasm2js.test3
-rw-r--r--test/lit/passes/signext-lowering-features.wast9
5 files changed, 23 insertions, 3 deletions
diff --git a/src/passes/SignExtLowering.cpp b/src/passes/SignExtLowering.cpp
index 7d03046ea..beb36494f 100644
--- a/src/passes/SignExtLowering.cpp
+++ b/src/passes/SignExtLowering.cpp
@@ -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(); }
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index d567fee95..ff2c7d45f 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -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",
diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test
index ae1768f9f..2e10ed073 100644
--- a/test/lit/help/wasm-opt.test
+++ b/test/lit/help/wasm-opt.test
@@ -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
diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test
index f75d37965..1766d771d 100644
--- a/test/lit/help/wasm2js.test
+++ b/test/lit/help/wasm2js.test
@@ -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
diff --git a/test/lit/passes/signext-lowering-features.wast b/test/lit/passes/signext-lowering-features.wast
new file mode 100644
index 000000000..fb0671584
--- /dev/null
+++ b/test/lit/passes/signext-lowering-features.wast
@@ -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)