summaryrefslogtreecommitdiff
path: root/test/lit/passes
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-04-22 10:42:43 -0700
committerGitHub <noreply@github.com>2022-04-22 10:42:43 -0700
commit2ab19d9ac528ff11fa14b184a84c92e72d5b0163 (patch)
tree015d0a00203a1fc08c95e795b2e1c9bc68817050 /test/lit/passes
parent6000629ae7cc2962483cd0d7ae4a770c8f2a34a0 (diff)
downloadbinaryen-2ab19d9ac528ff11fa14b184a84c92e72d5b0163.tar.gz
binaryen-2ab19d9ac528ff11fa14b184a84c92e72d5b0163.tar.bz2
binaryen-2ab19d9ac528ff11fa14b184a84c92e72d5b0163.zip
[NominalFuzzing] Fix getHeapTypeCounts() on unreachable casts (#4609)
The cast instruction may be unreachable but the intended type for the cast still needs to be collected. Otherwise we end up with problems both during optimizations that look at heap types and in printing (which will use the heap type in code but not declare it). Diff without whitespace is much smaller: this just moves code around so that we can use a template to avoid code duplication. The actual change is just to scan ->intendedType unconditionally, and not ignore it if the cast is unreachable.
Diffstat (limited to 'test/lit/passes')
-rw-r--r--test/lit/passes/signature-pruning.wast24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/lit/passes/signature-pruning.wast b/test/lit/passes/signature-pruning.wast
index 3c27ee874..3c4500eaf 100644
--- a/test/lit/passes/signature-pruning.wast
+++ b/test/lit/passes/signature-pruning.wast
@@ -786,3 +786,27 @@
(call $bar (ref.null func))
)
)
+
+(module
+ ;; CHECK: (type $none_=>_none (func_subtype func))
+
+ ;; CHECK: (type $A (struct_subtype data))
+ (type $A (struct_subtype data))
+ ;; CHECK: (func $0 (type $none_=>_none)
+ ;; CHECK-NEXT: (local $0 f32)
+ ;; CHECK-NEXT: (ref.cast_static $A
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $0 (param $0 f32)
+ ;; $A is only used in an unreachable cast. We should not error when
+ ;; removing the param from this function, during which we collect heap
+ ;; types, and must find this one even though the cast is unreachable, as
+ ;; we do need to handle it in the optimization as well as print it (note how
+ ;; type $A is declared in the output here - it would be a bug if it were
+ ;; not, which this is a regression test for).
+ (ref.cast_static $A
+ (unreachable)
+ )
+ )
+)