diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/code-pushing-eh.wast | 132 | ||||
-rw-r--r-- | test/lit/passes/vacuum-eh.wast | 51 |
2 files changed, 173 insertions, 10 deletions
diff --git a/test/lit/passes/code-pushing-eh.wast b/test/lit/passes/code-pushing-eh.wast index a18b10dae..c428d757d 100644 --- a/test/lit/passes/code-pushing-eh.wast +++ b/test/lit/passes/code-pushing-eh.wast @@ -1,17 +1,19 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. ;; RUN: wasm-opt %s --code-pushing -all -S -o - | filecheck %s +;; The tests in this file test EffectAnalyzer, which is used by CodePushing. + (module ;; CHECK: (tag $e (param i32)) (tag $e (param i32)) - ;; CHECK: (func $cant-push-past-call + ;; CHECK: (func $cannot-push-past-call ;; CHECK-NEXT: (local $x i32) ;; CHECK-NEXT: (block $out ;; CHECK-NEXT: (local.set $x ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (call $cant-push-past-call) + ;; CHECK-NEXT: (call $cannot-push-past-call) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) @@ -23,19 +25,19 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cant-push-past-call + (func $cannot-push-past-call (local $x i32) (block $out ;; This local.set cannot be pushed down, because the call below can throw (local.set $x (i32.const 1)) - (call $cant-push-past-call) + (call $cannot-push-past-call) (drop (i32.const 1)) (br_if $out (i32.const 2)) (drop (local.get $x)) ) ) - ;; CHECK: (func $cant-push-past-throw + ;; CHECK: (func $cannot-push-past-throw ;; CHECK-NEXT: (local $x i32) ;; CHECK-NEXT: (block $out ;; CHECK-NEXT: (local.set $x @@ -55,7 +57,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cant-push-past-throw + (func $cannot-push-past-throw (local $x i32) (block $out ;; This local.set cannot be pushed down, because there is 'throw' below @@ -117,7 +119,7 @@ ;; CHECK-NEXT: ) (func $foo) - ;; CHECK: (func $cant-push-past-try + ;; CHECK: (func $cannot-push-past-try ;; CHECK-NEXT: (local $x i32) ;; CHECK-NEXT: (block $out ;; CHECK-NEXT: (local.set $x @@ -144,7 +146,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cant-push-past-try + (func $cannot-push-past-try (local $x i32) (block $out ;; This local.set cannot be pushed down, because the exception thrown by @@ -164,7 +166,7 @@ ) ) - ;; CHECK: (func $cant-push-past-rethrow-within-catch + ;; CHECK: (func $cannot-push-past-rethrow-within-catch ;; CHECK-NEXT: (local $x i32) ;; CHECK-NEXT: (block $out ;; CHECK-NEXT: (local.set $x @@ -191,7 +193,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cant-push-past-rethrow-within-catch + (func $cannot-push-past-rethrow-within-catch (local $x i32) (block $out ;; This local.set cannot be pushed down, because there is 'rethrow' within @@ -210,4 +212,114 @@ (drop (local.get $x)) ) ) + + ;; CHECK: (func $can-push-past-try-delegate + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (block $out + ;; CHECK-NEXT: (try $l + ;; CHECK-NEXT: (do + ;; CHECK-NEXT: (try $try + ;; CHECK-NEXT: (do + ;; CHECK-NEXT: (throw $e + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (delegate $l) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (catch_all + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $out + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $can-push-past-try-delegate + (local $x i32) + (block $out + ;; This local.set can be pushed down, because the 'throw' below is going + ;; to be caught by the catch_all + (local.set $x (i32.const 1)) + (try $l + (do + (try + (do + (throw $e (i32.const 0)) + ) + (delegate $l) + ) + ) + (catch_all) + ) + (drop (i32.const 1)) + (br_if $out (i32.const 2)) + (drop (local.get $x)) + ) + ) + + ;; CHECK: (func $cannot-push-past-try-delegate + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (block $out + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (try $l + ;; CHECK-NEXT: (do + ;; CHECK-NEXT: (try $try + ;; CHECK-NEXT: (do + ;; CHECK-NEXT: (throw $e + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (delegate 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (catch_all + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $out + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $cannot-push-past-try-delegate + (local $x i32) + (block $out + ;; This local.set cannot be pushed down, because the 'delegate' bypasses + ;; the catch_all, making the whole 'try' throwable. + (local.set $x (i32.const 1)) + (try $l + (do + (try + (do + (throw $e (i32.const 0)) + ) + (delegate 2) + ) + ) + (catch_all) + ) + (drop (i32.const 1)) + (br_if $out (i32.const 2)) + (drop (local.get $x)) + ) + ) ) diff --git a/test/lit/passes/vacuum-eh.wast b/test/lit/passes/vacuum-eh.wast index ef6b6ff5b..574a525bc 100644 --- a/test/lit/passes/vacuum-eh.wast +++ b/test/lit/passes/vacuum-eh.wast @@ -125,4 +125,55 @@ ) ) ) + + ;; CHECK: (func $try-delegate-outer-target + ;; CHECK-NEXT: (local $0 i32) + ;; CHECK-NEXT: (try $label$0 + ;; CHECK-NEXT: (do + ;; CHECK-NEXT: (try $try + ;; CHECK-NEXT: (do + ;; CHECK-NEXT: (try $try2 + ;; CHECK-NEXT: (do + ;; CHECK-NEXT: (throw $e + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (delegate $label$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (catch_all + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $try-delegate-outer-target + (local $0 i32) + (try $label$0 ;; outer try + (do + ;; If it were not for the inner (delegate $label0), this middle try + ;; cannot throw even if there is a throw in the inner try, because this + ;; try has a catch_all. And Vacuum can replace the outer try-catch with + ;; the try's body if the body doesn't throw. + ;; + ;; But because the inner try has a delegate that targets the outer try, + ;; this middle try can throw, and we can't do the optimization for + ;; the outer try. + (try ;; middle try + (do + (try ;; inner try + (do + (throw $e + (i32.const 0) + ) + ) + (delegate $label$0) + ) + ) + (catch_all) + ) + ) + ) + ) ) |