Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/tools/optimization-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ struct OptimizationOptions : public ToolOptions {
"-sp",
"Skip a pass (do not run it)",
OptimizationOptionsCategory,
Options::Arguments::One,
Options::Arguments::N,
[this](Options*, const std::string& pass) {
passOptions.passesToSkip.insert(pass);
});
Expand Down
71 changes: 71 additions & 0 deletions test/lit/passes/O1_skip_passes.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
;; RUN: foreach %s %t wasm-opt -O2 --skip-pass=coalesce-locals --skip-pass=simplify-locals --skip-pass=simplify-locals-nostructure -S -o - 2>&1 | filecheck %s

;; Check that we can skip several passes. Note that no local.tee is introduced.

;; There should also be no warning in the output.
;; CHECK-NOT: warning:

(module
;; CHECK: (type $0 (func (param i32 i32)))

;; CHECK: (type $1 (func (param i32)))

;; CHECK: (import "a" "b" (func $log (param i32 i32)))
(import "a" "b" (func $log (param i32 i32)))

(func $foo (export "foo") (param $p i32)
;; The locals $x and $y can be coalesced into a single local, but as we do not
;; run that pass, they will not be. Other minor optimizations will occur here,
;; such as using a tee.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment says a tee will happen, which contradicts the previous one if I am not mistaken?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the test from O1_skip.wast but forgot to update all the comments. This is fixed.

(local $x i32)
(local $y i32)

(local.set $x
(i32.add
(local.get $p)
(i32.const 1)
)
)
(call $log
(local.get $x)
(local.get $x)
)

(local.set $y
(i32.add
(local.get $p)
(i32.const 1)
)
)
(call $log
(local.get $y)
(local.get $y)
)
)
)
;; CHECK: (export "foo" (func $foo))

;; CHECK: (func $foo (param $p i32)
;; CHECK-NEXT: (local $x i32)
;; CHECK-NEXT: (local $y i32)
;; CHECK-NEXT: (local.set $x
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: (local.get $p)
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $log
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: )
;; CHECK-NEXT: (local.set $y
;; CHECK-NEXT: (i32.add
;; CHECK-NEXT: (local.get $p)
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $log
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: (local.get $y)
;; CHECK-NEXT: )
;; CHECK-NEXT: )