summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/exec/strings.wast36
-rw-r--r--test/lit/passes/precompute-gc.wast40
-rw-r--r--test/lit/strings.wast23
3 files changed, 89 insertions, 10 deletions
diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast
new file mode 100644
index 000000000..2852337c8
--- /dev/null
+++ b/test/lit/exec/strings.wast
@@ -0,0 +1,36 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited.
+
+;; RUN: wasm-opt %s -all --fuzz-exec -q -o /dev/null 2>&1 | filecheck %s
+
+(module
+ (type $array16 (array (mut i16)))
+
+ ;; CHECK: [fuzz-exec] calling new_wtf16_array
+ ;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello")
+ (func "new_wtf16_array" (result stringref)
+ (string.new_wtf16_array
+ (array.init_static $array16
+ (i32.const 104) ;; h
+ (i32.const 101) ;; e
+ (i32.const 108) ;; l
+ (i32.const 108) ;; l
+ (i32.const 111) ;; o
+ )
+ (i32.const 1) ;; start from index 1, to chop off the 'h'
+ (i32.const 5)
+ )
+ )
+
+ ;; CHECK: [fuzz-exec] calling const
+ ;; CHECK-NEXT: [fuzz-exec] note result: const => string("world")
+ (func "const" (result stringref)
+ (string.const "world")
+ )
+)
+;; CHECK: [fuzz-exec] calling new_wtf16_array
+;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello")
+
+;; CHECK: [fuzz-exec] calling const
+;; CHECK-NEXT: [fuzz-exec] note result: const => string("world")
+;; CHECK-NEXT: [fuzz-exec] comparing const
+;; CHECK-NEXT: [fuzz-exec] comparing new_wtf16_array
diff --git a/test/lit/passes/precompute-gc.wast b/test/lit/passes/precompute-gc.wast
index f53ced968..0c5b9f8b8 100644
--- a/test/lit/passes/precompute-gc.wast
+++ b/test/lit/passes/precompute-gc.wast
@@ -23,6 +23,8 @@
;; NOMNL: (type $B (struct (field (mut f64))))
(type $B (struct (field (mut f64))))
+ (type $array16 (array (mut i16)))
+
(type $func-return-i32 (func (result i32)))
;; CHECK: (import "fuzzing-support" "log-i32" (func $log (param i32)))
@@ -1429,4 +1431,42 @@
)
)
)
+
+ ;; CHECK: (func $strings (type $ref|string|_=>_none) (param $param (ref string))
+ ;; CHECK-NEXT: (local $s (ref string))
+ ;; CHECK-NEXT: (local.set $s
+ ;; CHECK-NEXT: (string.const "hello, world")
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $strings
+ ;; CHECK-NEXT: (string.const "hello, world")
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $strings
+ ;; CHECK-NEXT: (string.const "hello, world")
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; NOMNL: (func $strings (type $ref|string|_=>_none) (param $param (ref string))
+ ;; NOMNL-NEXT: (local $s (ref string))
+ ;; NOMNL-NEXT: (local.set $s
+ ;; NOMNL-NEXT: (string.const "hello, world")
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: (call $strings
+ ;; NOMNL-NEXT: (string.const "hello, world")
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: (call $strings
+ ;; NOMNL-NEXT: (string.const "hello, world")
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: )
+ (func $strings (param $param (ref string))
+ (local $s (ref string))
+ (local.set $s
+ (string.const "hello, world")
+ )
+ ;; The constant string should be propagated twice, to both of these calls.
+ (call $strings
+ (local.get $s)
+ )
+ (call $strings
+ (local.get $s)
+ )
+ )
)
diff --git a/test/lit/strings.wast b/test/lit/strings.wast
index 63139d900..1e38ff894 100644
--- a/test/lit/strings.wast
+++ b/test/lit/strings.wast
@@ -22,19 +22,21 @@
;; CHECK: (type $array (array (mut i8)))
(type $array (array_subtype (mut i8) data))
- ;; CHECK: (type $none_=>_none (func))
-
;; CHECK: (type $array16 (array (mut i16)))
(type $array16 (array_subtype (mut i16) data))
;; CHECK: (type $stringref_stringview_wtf8_stringview_wtf16_stringview_iter_stringref_stringview_wtf8_stringview_wtf16_stringview_iter_ref|string|_ref|stringview_wtf8|_ref|stringview_wtf16|_ref|stringview_iter|_=>_none (func (param stringref stringview_wtf8 stringview_wtf16 stringview_iter stringref stringview_wtf8 stringview_wtf16 stringview_iter (ref string) (ref stringview_wtf8) (ref stringview_wtf16) (ref stringview_iter))))
+ ;; CHECK: (type $ref|string|_=>_none (func (param (ref string))))
+
;; CHECK: (type $stringview_wtf16_=>_none (func (param stringview_wtf16)))
;; CHECK: (type $ref|$array|_ref|$array16|_=>_none (func (param (ref $array) (ref $array16))))
;; CHECK: (type $stringref_ref|$array|_ref|$array16|_=>_none (func (param stringref (ref $array) (ref $array16))))
+ ;; CHECK: (type $none_=>_none (func))
+
;; CHECK: (type $ref|$array|_=>_none (func (param (ref $array))))
;; CHECK: (type $stringref_=>_i32 (func (param stringref) (result i32)))
@@ -109,25 +111,26 @@
)
)
- ;; CHECK: (func $string.const (type $none_=>_none)
- ;; CHECK-NEXT: (drop
+ ;; CHECK: (func $string.const (type $ref|string|_=>_none) (param $param (ref string))
+ ;; CHECK-NEXT: (call $string.const
;; CHECK-NEXT: (string.const "foo")
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $string.const
;; CHECK-NEXT: (string.const "foo")
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $string.const
;; CHECK-NEXT: (string.const "bar")
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- (func $string.const
- (drop
+ (func $string.const (param $param (ref string))
+ ;; Use calls to avoid precompute removing dropped constants.
+ (call $string.const
(string.const "foo")
)
- (drop
+ (call $string.const
(string.const "foo") ;; intentionally repeat the previous one
)
- (drop
+ (call $string.const
(string.const "bar")
)
)