summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/signature-refining.wast57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/lit/passes/signature-refining.wast b/test/lit/passes/signature-refining.wast
index c2a505e51..95007b1c4 100644
--- a/test/lit/passes/signature-refining.wast
+++ b/test/lit/passes/signature-refining.wast
@@ -985,3 +985,60 @@
(struct.new $C) ;; this will allow this function's result to be refined to $C
)
)
+
+;; Test we consider call.without.effects when deciding what to refine. $A has
+;; two subtypes, B1 and B2, and a call.without.effects sends in one while a
+;; normal call sends in the other. As a result, we cannot refine to either.
+(module
+ (rec
+ ;; CHECK: (rec
+ ;; CHECK-NEXT: (type $A (sub (struct )))
+ (type $A (sub (struct)))
+
+ ;; CHECK: (type $B1 (sub $A (struct )))
+ (type $B1 (sub $A (struct)))
+
+ ;; CHECK: (type $B2 (sub $A (struct )))
+ (type $B2 (sub $A (struct)))
+ )
+
+ ;; CHECK: (type $3 (func (param (ref $A) funcref)))
+
+ ;; CHECK: (type $4 (func))
+
+ ;; CHECK: (type $5 (func (param (ref $A))))
+
+ ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $no.side.effects (type $3) (param (ref $A) funcref)))
+ (import "binaryen-intrinsics" "call.without.effects" (func $no.side.effects
+ (param (ref $A))
+ (param funcref)
+ ))
+
+ ;; CHECK: (elem declare func $target)
+
+ ;; CHECK: (func $calls (type $4)
+ ;; CHECK-NEXT: (call $no.side.effects
+ ;; CHECK-NEXT: (struct.new_default $B1)
+ ;; CHECK-NEXT: (ref.func $target)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $target
+ ;; CHECK-NEXT: (struct.new_default $B2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $calls
+ (call $no.side.effects
+ (struct.new $B1)
+ (ref.func $target)
+ )
+ (call $target
+ (struct.new $B2)
+ )
+ )
+
+ ;; CHECK: (func $target (type $5) (param $x (ref $A))
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $target (param $x (ref $A))
+ ;; Because of the two calls above, this cannot be refined.
+ )
+)