summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-11-04 10:27:06 -0700
committerGitHub <noreply@github.com>2022-11-04 10:27:06 -0700
commit0e112d4c51de69620a419e1afce88e08e725e40b (patch)
tree163a2028c7b8075596ffa213bd15fd2a035b9c69 /test
parent8388a33e84c0730f5a7c7e89bd089ad7c9db9455 (diff)
downloadbinaryen-0e112d4c51de69620a419e1afce88e08e725e40b.tar.gz
binaryen-0e112d4c51de69620a419e1afce88e08e725e40b.tar.bz2
binaryen-0e112d4c51de69620a419e1afce88e08e725e40b.zip
[Wasm GC] Fix GUFA on externalize/internalize (#5220)
These operations emit a completely different type than their input, so they must be marked as roots, and not as things that flow values through them (because then we filter everything out as the types are not compatible). Fixes #5219
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/gufa-extern.wast70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/lit/passes/gufa-extern.wast b/test/lit/passes/gufa-extern.wast
new file mode 100644
index 000000000..4a626b9c9
--- /dev/null
+++ b/test/lit/passes/gufa-extern.wast
@@ -0,0 +1,70 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+;; RUN: foreach %s %t wasm-opt -all --gufa --nominal -S -o - | filecheck %s
+
+(module
+ ;; CHECK: (type $externref_anyref_=>_none (func_subtype (param externref anyref) func))
+
+ ;; CHECK: (export "externals" (func $externals))
+
+ ;; CHECK: (func $externals (type $externref_anyref_=>_none) (param $ext externref) (param $any anyref)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (ref.as_data
+ ;; CHECK-NEXT: (extern.internalize
+ ;; CHECK-NEXT: (local.get $ext)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (extern.externalize
+ ;; CHECK-NEXT: (local.get $any)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $externals (export "externals") (param $ext externref) (param $any anyref)
+ ;; We must not turn these into unreachable code, as the function is
+ ;; exported.
+ (drop
+ (ref.as_data
+ (extern.internalize
+ (local.get $ext)
+ )
+ )
+ )
+ (drop
+ (extern.externalize
+ (local.get $any)
+ )
+ )
+ )
+
+ ;; CHECK: (func $non-exported (type $externref_anyref_=>_none) (param $ext externref) (param $any anyref)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (ref.as_data
+ ;; CHECK-NEXT: (extern.internalize
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (extern.externalize
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $non-exported (param $ext externref) (param $any anyref)
+ ;; This is not exported, so the params are dead code, and can be turned
+ ;; unreachable.
+ (drop
+ (ref.as_data
+ (extern.internalize
+ (local.get $ext)
+ )
+ )
+ )
+ (drop
+ (extern.externalize
+ (local.get $any)
+ )
+ )
+ )
+)