diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/gtest/stringify.cpp | 2 | ||||
-rw-r--r-- | test/lit/passes/outlining.wast | 239 |
2 files changed, 189 insertions, 52 deletions
diff --git a/test/gtest/stringify.cpp b/test/gtest/stringify.cpp index 59b7db6e1..3e50c6d4c 100644 --- a/test/gtest/stringify.cpp +++ b/test/gtest/stringify.cpp @@ -266,7 +266,7 @@ TEST_F(StringifyTest, Substrings) { // 10, 11, 6 appears at idx 18 and again at 27 SuffixTree::RepeatedSubstring{3u, (std::vector<unsigned>{23, 34})}, // 11, 6 appears at idx 32, 19 and again at 28 - SuffixTree::RepeatedSubstring{2u, (std::vector<unsigned>{40, 24, 35})}, + SuffixTree::RepeatedSubstring{2u, (std::vector<unsigned>{24, 35, 40})}, // 7, 6 appears at idx 11 and again at 24 SuffixTree::RepeatedSubstring{2u, (std::vector<unsigned>{14, 30})}})); } diff --git a/test/lit/passes/outlining.wast b/test/lit/passes/outlining.wast index d62570c11..ffd5eb081 100644 --- a/test/lit/passes/outlining.wast +++ b/test/lit/passes/outlining.wast @@ -2,9 +2,7 @@ ;; RUN: foreach %s %t wasm-opt --outlining -S -o - | filecheck %s -;; TODO: Add a test that creates an outlined function with a sequence at beginning ;; TODO: Add a test that creates an outlined function with one return value -;; TODO: Add a test that creates an outlined function that no arguments ;; 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 @@ -18,6 +16,18 @@ ;; CHECK: (type $1 (func (param i32))) + ;; CHECK: (func $outline$ (param $0 i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK: (func $a (result i32) ;; CHECK-NEXT: (call $outline$ ;; CHECK-NEXT: (i32.const 7) @@ -27,10 +37,18 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $a (result i32) - (drop (i32.const 7)) - (drop (i32.const 1)) - (drop (i32.const 2)) - (return (i32.const 4)) + (drop + (i32.const 7) + ) + (drop + (i32.const 1) + ) + (drop + (i32.const 2) + ) + (return + (i32.const 4) + ) ) ;; CHECK: (func $b (result i32) ;; CHECK-NEXT: (call $outline$ @@ -41,68 +59,187 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $b (result i32) - (drop (i32.const 0)) - (drop (i32.const 1)) - (drop (i32.const 2)) - (return (i32.const 5)) + (drop + (i32.const 0) + ) + (drop + (i32.const 1) + ) + (drop + (i32.const 2) + ) + (return + (i32.const 5) + ) ) ) ;; Tests that outlining occurs properly when the sequence is at the end of a function. +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (func $outline$ + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + + ;; CHECK: (func $c + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: ) + (func $c + (drop + (i32.const 1) + ) + (drop + (i32.const 2) + ) + ) + ;; CHECK: (func $d + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: ) + (func $d + (drop + (i32.const 1) + ) + (drop + (i32.const 2) + ) + ) +) -;; CHECK: (func $outline$ (param $0 i32) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (i32.const 1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (i32.const 2) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) +;; Tests that outlining occurs properly when the sequence is at the beginning of a function. +;; Also tests that the outlined function has no arguments. (module ;; CHECK: (type $0 (func)) - ;; CHECK: (type $1 (func (param i32))) + ;; CHECK: (func $outline$ + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) - ;; CHECK: (func $a + ;; CHECK: (func $e + ;; CHECK-NEXT: (call $outline$) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (i32.const 7) + ;; CHECK-NEXT: (i32.const 6) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (call $outline$ - ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) + (func $e + (drop + (i32.const 0) + ) + (drop + (i32.add + (i32.const 0) + (i32.const 1) + ) + ) + (drop + (i32.const 1) + ) + (drop + (i32.const 6) + ) + ) + ;; CHECK: (func $f + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 7) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $a - (drop (i32.const 7)) - (drop (i32.const 4)) - (drop (i32.const 1)) - (drop (i32.const 2)) + (func $f + (drop + (i32.const 0) + ) + (drop + (i32.add + (i32.const 0) + (i32.const 1) + ) + ) + (drop + (i32.const 1) + ) + (drop + (i32.const 7) + ) ) - ;; CHECK: (func $b +) + +;; Tests multiple sequences being outlined from the same source function into different +;; outlined functions. +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (func $outline$ ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (call $outline$ - ;; CHECK-NEXT: (i32.const 5) + ;; CHECK-NEXT: ) + + ;; CHECK: (func $outline$_4 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.sub + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $b - (drop (i32.const 0)) - (drop (i32.const 5)) - (drop (i32.const 1)) - (drop (i32.const 2)) + + ;; CHECK: (func $g + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: (call $outline$_4) + ;; CHECK-NEXT: ) + (func $g + (drop + (i32.add + (i32.const 0) + (i32.const 1) + ) + ) + (drop + (i32.sub + (i32.const 3) + (i32.const 4) + ) + ) + ) + ;; CHECK: (func $h + ;; CHECK-NEXT: (call $outline$_4) + ;; CHECK-NEXT: ) + (func $h + (drop + (i32.sub + (i32.const 3) + (i32.const 4) + ) + ) + ) + ;; CHECK: (func $i + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: ) + (func $i + (drop + (i32.add + (i32.const 0) + (i32.const 1) + ) + ) ) ) -;; CHECK: (func $outline$ (param $0 i32) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (i32.const 1) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (drop -;; CHECK-NEXT: (i32.const 2) -;; CHECK-NEXT: ) -;; CHECK-NEXT: ) |