summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-03-13 13:28:36 -0700
committerGitHub <noreply@github.com>2023-03-13 13:28:36 -0700
commit4f27e889dbdefa3b55d89f8b0cf319419eae41bd (patch)
tree772df41e9cf89ea3c0fdbcca92eef8d7da13fe68 /test
parent9053486f43d43449118c75c75a146abebcd7d1c4 (diff)
downloadbinaryen-4f27e889dbdefa3b55d89f8b0cf319419eae41bd.tar.gz
binaryen-4f27e889dbdefa3b55d89f8b0cf319419eae41bd.tar.bz2
binaryen-4f27e889dbdefa3b55d89f8b0cf319419eae41bd.zip
[Wasm GC] Properly handle packed field truncation in StructNew (#5570)
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/precompute-gc.wast18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/lit/passes/precompute-gc.wast b/test/lit/passes/precompute-gc.wast
index 0c5b9f8b8..782cf9b06 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 $struct_i8 (struct (field i8)))
+
(type $array16 (array (mut i16)))
(type $func-return-i32 (func (result i32)))
@@ -1469,4 +1471,20 @@
(local.get $s)
)
)
+
+ ;; CHECK: (func $struct.new.packed (type $func-return-i32) (result i32)
+ ;; CHECK-NEXT: (i32.const 120)
+ ;; CHECK-NEXT: )
+ ;; NOMNL: (func $struct.new.packed (type $func-return-i32) (result i32)
+ ;; NOMNL-NEXT: (i32.const 120)
+ ;; NOMNL-NEXT: )
+ (func $struct.new.packed (result i32)
+ ;; Truncation happens when we write to this packed i8 field, so the result we
+ ;; read back is 0x12345678 & 0xff which is 0x78 == 120.
+ (struct.get_s $struct_i8 0
+ (struct.new $struct_i8
+ (i32.const 0x12345678)
+ )
+ )
+ )
)