diff options
Diffstat (limited to 'test/lit/passes/directize_all-features.wast')
-rw-r--r-- | test/lit/passes/directize_all-features.wast | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/test/lit/passes/directize_all-features.wast b/test/lit/passes/directize_all-features.wast index 997992b07..074558d95 100644 --- a/test/lit/passes/directize_all-features.wast +++ b/test/lit/passes/directize_all-features.wast @@ -1599,6 +1599,101 @@ ) ) +;; A table.init prevents optimization. +(module + ;; CHECK: (type $i32 (func (result i32))) + ;; IMMUT: (type $i32 (func (result i32))) + (type $i32 (func (result i32))) + + ;; CHECK: (type $1 (func)) + + ;; CHECK: (table $table 111 funcref) + ;; IMMUT: (type $1 (func)) + + ;; IMMUT: (table $table 111 funcref) + (table $table 111 funcref) + (elem (i32.const 0) $func-A) + + ;; CHECK: (elem $0 (i32.const 0) $func-A) + + ;; CHECK: (elem $elem func $func-B) + ;; IMMUT: (elem $0 (i32.const 0) $func-A) + + ;; IMMUT: (elem $elem func $func-B) + (elem $elem $func-B) + + ;; CHECK: (export "a" (func $init)) + ;; IMMUT: (export "a" (func $init)) + (export "a" (func $init)) + ;; CHECK: (export "b" (func $call)) + ;; IMMUT: (export "b" (func $call)) + (export "b" (func $call)) + + ;; CHECK: (func $func-A (type $i32) (result i32) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; IMMUT: (func $func-A (type $i32) (result i32) + ;; IMMUT-NEXT: (i32.const 0) + ;; IMMUT-NEXT: ) + (func $func-A (result i32) + (i32.const 0) + ) + + ;; CHECK: (func $func-B (type $i32) (result i32) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; IMMUT: (func $func-B (type $i32) (result i32) + ;; IMMUT-NEXT: (unreachable) + ;; IMMUT-NEXT: ) + (func $func-B (result i32) + (unreachable) + ) + + ;; CHECK: (func $init (type $1) + ;; CHECK-NEXT: (table.init $table $elem + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; IMMUT: (func $init (type $1) + ;; IMMUT-NEXT: (table.init $table $elem + ;; IMMUT-NEXT: (i32.const 0) + ;; IMMUT-NEXT: (i32.const 0) + ;; IMMUT-NEXT: (i32.const 1) + ;; IMMUT-NEXT: ) + ;; IMMUT-NEXT: ) + (func $init + (table.init $table $elem + (i32.const 0) + (i32.const 0) + (i32.const 1) + ) + ) + + ;; CHECK: (func $call (type $1) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call_indirect $table (type $i32) + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; IMMUT: (func $call (type $1) + ;; IMMUT-NEXT: (drop + ;; IMMUT-NEXT: (call $func-A) + ;; IMMUT-NEXT: ) + ;; IMMUT-NEXT: ) + (func $call + (drop + ;; This cannot be turned into a direct call due to the table.init, unless we + ;; assume initial contents are immutable. + (call_indirect (type $i32) + (i32.const 0) + ) + ) + ) +) + ;; The elem's offset is way out of bounds, which we should not error on, and do ;; nothing otherwise. (module |