diff options
author | Ashley Nelson <nashley@google.com> | 2023-11-16 17:44:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 17:44:02 -0800 |
commit | 7ae118528b23215432790b0c123e1bd42db128ef (patch) | |
tree | 65c8648121cf83cd964806cef8b982d3f8948794 | |
parent | b43b70df7420414cbafa23e4f41453437e07d0a7 (diff) | |
download | binaryen-7ae118528b23215432790b0c123e1bd42db128ef.tar.gz binaryen-7ae118528b23215432790b0c123e1bd42db128ef.tar.bz2 binaryen-7ae118528b23215432790b0c123e1bd42db128ef.zip |
[Outlining] Adds filter tests (#6119)
Adds tests that ensure outlining is skipping repeat sequences that include local.get, local.set, br, and return instructions.
-rw-r--r-- | test/lit/passes/outlining.wast | 157 |
1 files changed, 138 insertions, 19 deletions
diff --git a/test/lit/passes/outlining.wast b/test/lit/passes/outlining.wast index a080162ca..d1bb6584e 100644 --- a/test/lit/passes/outlining.wast +++ b/test/lit/passes/outlining.wast @@ -4,10 +4,6 @@ ;; TODO: Add a test that creates an outlined function with one return value ;; TODO: Add a test that creates an outlined function that returns multiple values -;; TODO: Add a test that makes sure we filter localSets correctly -;; TODO: Add a test that makes sure we filter localGets correctly -;; TODO: Add a test that makes sure we filter branches correctly -;; TODO: Add a test that makes sure we filter globals correctly ;; TODO: Add a test that fails to outline a single control flow that repeats @@ -87,10 +83,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK: (func $c + ;; CHECK: (func $a ;; CHECK-NEXT: (call $outline$) ;; CHECK-NEXT: ) - (func $c + (func $a (drop (i32.const 1) ) @@ -98,10 +94,10 @@ (i32.const 2) ) ) - ;; CHECK: (func $d + ;; CHECK: (func $b ;; CHECK-NEXT: (call $outline$) ;; CHECK-NEXT: ) - (func $d + (func $b (drop (i32.const 1) ) @@ -131,13 +127,13 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK: (func $e + ;; CHECK: (func $a ;; CHECK-NEXT: (call $outline$) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.const 6) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $e + (func $a (drop (i32.const 0) ) @@ -154,13 +150,13 @@ (i32.const 6) ) ) - ;; CHECK: (func $f + ;; CHECK: (func $b ;; CHECK-NEXT: (call $outline$) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.const 7) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $f + (func $b (drop (i32.const 0) ) @@ -202,11 +198,11 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK: (func $g + ;; CHECK: (func $a ;; CHECK-NEXT: (call $outline$) ;; CHECK-NEXT: (call $outline$_4) ;; CHECK-NEXT: ) - (func $g + (func $a (drop (i32.add (i32.const 0) @@ -220,10 +216,10 @@ ) ) ) - ;; CHECK: (func $h + ;; CHECK: (func $b ;; CHECK-NEXT: (call $outline$_4) ;; CHECK-NEXT: ) - (func $h + (func $b (drop (i32.sub (i32.const 3) @@ -231,10 +227,10 @@ ) ) ) - ;; CHECK: (func $i + ;; CHECK: (func $c ;; CHECK-NEXT: (call $outline$) ;; CHECK-NEXT: ) - (func $i + (func $c (drop (i32.add (i32.const 0) @@ -244,7 +240,6 @@ ) ) - ;; Tests that outlining works correctly with If control flow (module ;; CHECK: (type $0 (func (param i32))) @@ -294,3 +289,127 @@ ) ) ) + +;; Tests that local.get instructions are correctly filtered from being outlined. +(module + ;; CHECK: (type $0 (func (param i32))) + + ;; CHECK: (func $a (param $0 i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $a (param i32) + (drop + (i32.add + (local.get 0) + (i32.const 1) + ) + ) + ) + ;; CHECK: (func $b (param $0 i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $b (param i32) + (drop + (i32.add + (local.get 0) + (i32.const 1) + ) + ) + ) +) + +;; Tests local.set instructions are correctly filtered from being outlined. +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (func $a + ;; CHECK-NEXT: (local $i i32) + ;; CHECK-NEXT: (local.set $i + ;; CHECK-NEXT: (i32.const 7) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $a + (local $i i32) + (local.set $i + (i32.const 7) + ) + ) + ;; CHECK: (func $b + ;; CHECK-NEXT: (local $i i32) + ;; CHECK-NEXT: (local.set $i + ;; CHECK-NEXT: (i32.const 7) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $b + (local $i i32) + (local.set $i + (i32.const 7) + ) + ) +) + +;; Tests branch instructions are correctly filtered from being outlined. +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (func $a + ;; CHECK-NEXT: (block $label1 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br $label1) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br $label1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $a + (block $label1 + (drop + (i32.const 4) + ) + (br $label1) + (drop + (i32.const 4) + ) + (br $label1) + ) + ) +) + +;; Tests return instructions are correctly filtered from being outlined. +(module + ;; CHECK: (type $0 (func (result i32))) + + ;; CHECK: (func $a (result i32) + ;; CHECK-NEXT: (return + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $a (result i32) + (return + (i32.const 2) + ) + ) + ;; CHECK: (func $b (result i32) + ;; CHECK-NEXT: (return + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $b (result i32) + (return + (i32.const 2) + ) + ) +) |