summaryrefslogtreecommitdiff
path: root/test/lit/validation
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-08-24 12:11:55 -0500
committerGitHub <noreply@github.com>2023-08-24 10:11:55 -0700
commit73bbbab144c4543edb70d35160cd620d3fe94539 (patch)
tree47c40a9722f73c1be24ef5a963281aca371074ca /test/lit/validation
parentda8937a71e908fecfc5722594dadd3c7ec6e80be (diff)
downloadbinaryen-73bbbab144c4543edb70d35160cd620d3fe94539.tar.gz
binaryen-73bbbab144c4543edb70d35160cd620d3fe94539.tar.bz2
binaryen-73bbbab144c4543edb70d35160cd620d3fe94539.zip
Simplify and consolidate type printing (#5816)
When printing Binaryen IR, we previously generated names for unnamed heap types based on their structure. This was useful for seeing the structure of simple types at a glance without having to separately go look up their definitions, but it also had two problems: 1. The same name could be generated for multiple types. The generated names did not take into account rec group structure or finality, so types that differed only in these properties would have the same name. Also, generated type names were limited in length, so very large types that shared only some structure could also end up with the same names. Using the same name for multiple types produces incorrect and unparsable output. 2. The generated names were not useful beyond the most trivial examples. Even with length limits, names for nontrivial types were extremely long and visually noisy, which made reading disassembled real-world code more challenging. Fix these problems by emitting simple indexed names for unnamed heap types instead. This regresses readability for very simple examples, but the trade off is worth it. This change also reduces the number of type printing systems we have by one. Previously we had the system in Print.cpp, but we had another, more general and extensible system in wasm-type-printing.h and wasm-type.cpp as well. Remove the old type printing system from Print.cpp and replace it with a much smaller use of the new system. This requires significant refactoring of Print.cpp so that PrintExpressionContents object now holds a reference to a parent PrintSExpression object that holds the type name state. This diff is very large because almost every test output changed slightly. To minimize the diff and ease review, change the type printer in wasm-type.cpp to behave the same as the old type printer in Print.cpp except for the differences in name generation. These changes will be reverted in much smaller PRs in the future to generally improve how types are printed.
Diffstat (limited to 'test/lit/validation')
-rw-r--r--test/lit/validation/closed-world-interface-intrinsics.wast12
-rw-r--r--test/lit/validation/closed-world-interface.wast2
-rw-r--r--test/lit/validation/eqref.wast4
-rw-r--r--test/lit/validation/nn-tuples.wast2
4 files changed, 10 insertions, 10 deletions
diff --git a/test/lit/validation/closed-world-interface-intrinsics.wast b/test/lit/validation/closed-world-interface-intrinsics.wast
index 91133d6dc..50151b8c0 100644
--- a/test/lit/validation/closed-world-interface-intrinsics.wast
+++ b/test/lit/validation/closed-world-interface-intrinsics.wast
@@ -10,18 +10,18 @@
;; CHECK: (type $struct (struct (field i32)))
(type $struct (struct i32))
- ;; CHECK: (type $ref|$struct|_funcref_=>_none (func (param (ref $struct) funcref)))
+ ;; CHECK: (type $1 (func (param (ref $struct) funcref)))
- ;; CHECK: (type $none_=>_none (func))
+ ;; CHECK: (type $2 (func))
- ;; CHECK: (type $ref|$struct|_=>_none (func (param (ref $struct))))
+ ;; CHECK: (type $3 (func (param (ref $struct))))
- ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $cwe (type $ref|$struct|_funcref_=>_none) (param (ref $struct) funcref)))
+ ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $cwe (type $1) (param (ref $struct) funcref)))
(import "binaryen-intrinsics" "call.without.effects" (func $cwe (param (ref $struct)) (param funcref)))
;; CHECK: (elem declare func $func)
- ;; CHECK: (func $test (type $none_=>_none)
+ ;; CHECK: (func $test (type $2)
;; CHECK-NEXT: (call $cwe
;; CHECK-NEXT: (struct.new $struct
;; CHECK-NEXT: (i32.const 100)
@@ -38,7 +38,7 @@
)
)
- ;; CHECK: (func $func (type $ref|$struct|_=>_none) (param $ref (ref $struct))
+ ;; CHECK: (func $func (type $3) (param $ref (ref $struct))
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
(func $func (param $ref (ref $struct))
diff --git a/test/lit/validation/closed-world-interface.wast b/test/lit/validation/closed-world-interface.wast
index f6f663550..f5dd7ad46 100644
--- a/test/lit/validation/closed-world-interface.wast
+++ b/test/lit/validation/closed-world-interface.wast
@@ -17,7 +17,7 @@
;; This is referred to by the type of a function export, but is still not allowed.
;; CHECK: publicly exposed type disallowed with a closed world: $struct, on
-;; CHECK-NEXT: (struct)
+;; CHECK-NEXT: (struct )
(module
(type $struct (struct))
diff --git a/test/lit/validation/eqref.wast b/test/lit/validation/eqref.wast
index 8de1e93fa..3c636592f 100644
--- a/test/lit/validation/eqref.wast
+++ b/test/lit/validation/eqref.wast
@@ -1,12 +1,12 @@
;; Test for eqref validating only with GC, and not just reference types, even
;; when only declared in a null.
-;; RUN: not wasm-opt --enable-reference-types %s 2>&1 | filecheck %s --check-prefix NO-GC
+;; RUN: not wasm-opt --enable-reference-types %s -o - -S 2>&1 | filecheck %s --check-prefix NO-GC
;; RUN: wasm-opt --enable-reference-types --enable-gc %s -o - -S | filecheck %s --check-prefix GC
;; NO-GC: all used types should be allowed
-;; GC: (func $foo (type $eqref_=>_none) (param $x eqref)
+;; GC: (func $foo (type $0) (param $x eqref)
(module
(func $foo (param $x eqref)
diff --git a/test/lit/validation/nn-tuples.wast b/test/lit/validation/nn-tuples.wast
index 2a621face..c84dd9aab 100644
--- a/test/lit/validation/nn-tuples.wast
+++ b/test/lit/validation/nn-tuples.wast
@@ -6,7 +6,7 @@
;; Test for non-nullable types in tuples
(module
- ;; CHECK: (func $foo (type $none_=>_none)
+ ;; CHECK: (func $foo (type $0)
;; CHECK-NEXT: (local $tuple ((ref any) (ref any)))
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )