diff options
author | Alon Zakai <azakai@google.com> | 2021-06-18 17:04:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-18 17:04:06 -0700 |
commit | aae35755e1d047c1f6fba9abfd2d836feafa5f66 (patch) | |
tree | f29fb2ad1de40ef80c3a9468a825ad4a61a670e0 /test | |
parent | 28e88b9f993a2e45662fde0b10920aa22e7b1b7f (diff) | |
download | binaryen-aae35755e1d047c1f6fba9abfd2d836feafa5f66.tar.gz binaryen-aae35755e1d047c1f6fba9abfd2d836feafa5f66.tar.bz2 binaryen-aae35755e1d047c1f6fba9abfd2d836feafa5f66.zip |
[Wasm GC] Fix inlining + non-nullable locals (#3945)
We don't need to assign a zero value for such locals (and we can't, as no
default value exists for them).
Fixes #3944
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/inlining-gc.wast | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/lit/passes/inlining-gc.wast b/test/lit/passes/inlining-gc.wast new file mode 100644 index 000000000..11ac125b2 --- /dev/null +++ b/test/lit/passes/inlining-gc.wast @@ -0,0 +1,45 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. +;; RUN: wasm-opt %s --inlining --enable-gc-nn-locals -all -S -o - | filecheck %s + +(module + ;; CHECK: (func $caller-nullable + ;; CHECK-NEXT: (local $0 funcref) + ;; CHECK-NEXT: (block $__inlined_func$target-nullable + ;; CHECK-NEXT: (local.set $0 + ;; CHECK-NEXT: (ref.null func) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $caller-nullable + ;; Call a function with a nullable local. After the inlining there will + ;; be a new local in this function for the use of the inlined code, and also + ;; we assign the null value to that local in the inlined block (which does + ;; not matter much here, but in general if we had a loop that the inlined + ;; block was inside of, that would be important to get the right behavior). + (call $target-nullable) + ) + + (func $target-nullable + (local $1 (ref null func)) + ) + + ;; CHECK: (func $caller-non-nullable + ;; CHECK-NEXT: (local $0 (ref func)) + ;; CHECK-NEXT: (block $__inlined_func$target-non-nullable + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $caller-non-nullable + ;; Call a function with a non-nullable local. After the inlining there will + ;; be a new local in this function for the use of the inlined code. We do not + ;; need to zero it out (such locals cannot be used before being set anyhow, so + ;; no zero is needed; and we cannot set a zero anyhow as none exists for the + ;; type). + (call $target-non-nullable) + ) + + (func $target-non-nullable + (local $1 (ref func)) + ) +) |