diff options
Diffstat (limited to 'test/lit/passes/coalesce-locals-gc.wast')
-rw-r--r-- | test/lit/passes/coalesce-locals-gc.wast | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/test/lit/passes/coalesce-locals-gc.wast b/test/lit/passes/coalesce-locals-gc.wast index 29dffb5bd..1a830b4a5 100644 --- a/test/lit/passes/coalesce-locals-gc.wast +++ b/test/lit/passes/coalesce-locals-gc.wast @@ -155,8 +155,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (i31.new - ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (block (result i31ref) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -216,4 +218,36 @@ ) ) ) + + ;; CHECK: (func $replace-i31-local (type $none_=>_i32) (result i32) + ;; CHECK-NEXT: (local $0 i31ref) + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: (ref.is_i31 + ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (block (result i31ref) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $replace-i31-local (result i32) + (local $local i31ref) + (i32.add + (unreachable) + (ref.test i31 + (ref.cast null i31 + ;; This local.get is in unreachable code, and coalesce-locals will remove + ;; it in order to avoid using the local index at all. While doing so it + ;; must emit something of the exact same type so validation still works + ;; (we can't turn this into a non-nullable reference, in particular - that + ;; would hit a validation error as the cast outside of us is nullable). + (local.get $local) + ) + ) + ) + ) ) |