Skip to content

Commit 6c54803

Browse files
authored
Fix skipping of nested/internal passes (#7741)
When --skip-pass is used, it identifies the pass to skip by name. We did not update the name of nested/internal passes, so their name was empty, causing skipping to fail (such passes are wrapped by another struct, which had an empty name; to fix it, copy the name to the wrapper). As a drive-by, rename the existing skip-pass tests, which mentioned -O1 even though they use -O2, and the opt level isn't even worth mentioning.
1 parent 90e98db commit 6c54803

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

src/passes/pass-utils.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ struct FilteredPass : public Pass {
3535
return std::make_unique<FilteredPass>(pass->create(), relevantFuncs);
3636
}
3737

38-
FilteredPass(std::unique_ptr<Pass>&& pass, const FuncSet& relevantFuncs)
39-
: pass(std::move(pass)), relevantFuncs(relevantFuncs) {}
38+
FilteredPass(std::unique_ptr<Pass>&& pass_, const FuncSet& relevantFuncs)
39+
: pass(std::move(pass_)), relevantFuncs(relevantFuncs) {
40+
// Copy the pass's name, for debugging and for --skip-pass support.
41+
name = pass->name;
42+
}
4043

4144
bool isFunctionParallel() override {
4245
assert(pass->isFunctionParallel());
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
2+
3+
;; RUN: foreach %s %t wasm-opt --inlining-optimizing --optimize-level=3 --skip-pass=coalesce-locals -S -o - 2>&1 | filecheck %s
4+
5+
;; We should skip coalese-locals when it is run as an internal sub-pass. Here
6+
;; we inline and optimize afterwards, which normally runs the full set of
7+
;; function passes, but skip pass skips it even there.
8+
9+
(module
10+
;; CHECK: (import "a" "b" (func $log (param i32 i32)))
11+
(import "a" "b" (func $log (param i32 i32)))
12+
13+
(func $foo (param $p i32)
14+
;; The locals $x and $y can be coalesced into a single local, but as we do not
15+
;; run that pass, they will not be. Other minor optimizations will occur here,
16+
;; such as using a tee.
17+
(local $x i32)
18+
(local $y i32)
19+
20+
(local.set $x
21+
(i32.add
22+
(local.get $p)
23+
(i32.const 1)
24+
)
25+
)
26+
(call $log
27+
(local.get $x)
28+
(local.get $x)
29+
)
30+
31+
(local.set $y
32+
(i32.add
33+
(local.get $p)
34+
(i32.const 1)
35+
)
36+
)
37+
(call $log
38+
(local.get $y)
39+
(local.get $y)
40+
)
41+
)
42+
43+
;; CHECK: (func $call-foo (param $p i32)
44+
;; CHECK-NEXT: (local $1 i32)
45+
;; CHECK-NEXT: (local $2 i32)
46+
;; CHECK-NEXT: (call $log
47+
;; CHECK-NEXT: (local.tee $2
48+
;; CHECK-NEXT: (local.tee $1
49+
;; CHECK-NEXT: (i32.add
50+
;; CHECK-NEXT: (local.get $p)
51+
;; CHECK-NEXT: (i32.const 1)
52+
;; CHECK-NEXT: )
53+
;; CHECK-NEXT: )
54+
;; CHECK-NEXT: )
55+
;; CHECK-NEXT: (local.get $2)
56+
;; CHECK-NEXT: )
57+
;; CHECK-NEXT: (call $log
58+
;; CHECK-NEXT: (local.get $1)
59+
;; CHECK-NEXT: (local.get $1)
60+
;; CHECK-NEXT: )
61+
;; CHECK-NEXT: )
62+
(func $call-foo (export "call-foo") (param $p i32)
63+
(call $foo
64+
(local.get $p)
65+
)
66+
)
67+
)
File renamed without changes.

0 commit comments

Comments
 (0)