Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
no-decl
  • Loading branch information
tlively committed Dec 20, 2023
commit 70286bd06bc856d10262fbbe34e91d3e1498f89c
6 changes: 5 additions & 1 deletion scripts/update_lit_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@

ALL_ITEMS = '|'.join(['type', 'import', 'global', 'memory', 'data', 'table',
'elem', 'tag', 'export', 'start', 'func'])
ITEM_NAME = r'\$[^\s()]*|"[^\s()]*"'

# Regular names as well as the "declare" in (elem declare ... to get declarative
# segments included in the output.
ITEM_NAME = r'\$[^\s()]*|"[^\s()]*"|declare'

# FIXME: This does not handle nested string contents. For example,
# (data (i32.const 10) "hello(")
# will look unterminated, due to the '(' inside the string. As a result, the
Expand Down
8 changes: 2 additions & 6 deletions src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <ir/iteration.h>
#include <ir/module-utils.h>
#include <ir/names.h>
#include <ir/table-utils.h>
#include <pass.h>
#include <pretty_printing.h>
Expand Down Expand Up @@ -3279,14 +3278,11 @@ void PrintSExpression::visitModule(Module* curr) {
}
auto elemDeclareNames = TableUtils::getFunctionsNeedingElemDeclare(*curr);
if (!elemDeclareNames.empty()) {
// Generate a name for the declarative segment to include it in generated
// lit test output.
auto segName = Names::getValidElementSegmentName(*curr, "decl");
doIndent(o, indent);
printMedium(o, "(elem ");
printName(segName, o);
printMedium(o, "(elem");
o << " declare func";
for (auto name : elemDeclareNames) {
o << ' ';
printName(name, o);
}
o << ')' << maybeNewLine;
Expand Down
15 changes: 8 additions & 7 deletions test/lit/basic/reference-types.wast
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

;; CHECK-TEXT: (elem $0 (i32.const 0) $take_eqref $take_funcref $take_anyref)

;; CHECK-TEXT: (elem $decl declare func$foo$ref-taken-but-not-in-table)
;; CHECK-TEXT: (elem declare func $foo $ref-taken-but-not-in-table)

;; CHECK-TEXT: (tag $e-i32 (param i32))

Expand Down Expand Up @@ -95,7 +95,7 @@

;; CHECK-BIN: (elem $0 (i32.const 0) $take_eqref $take_funcref $take_anyref)

;; CHECK-BIN: (elem $decl declare func$foo$ref-taken-but-not-in-table)
;; CHECK-BIN: (elem declare func $foo $ref-taken-but-not-in-table)

;; CHECK-BIN: (tag $e-i32 (param i32))

Expand Down Expand Up @@ -133,8 +133,6 @@
(func $foo)

(table funcref (elem $take_eqref $take_funcref $take_anyref))
(elem declare func $ref-taken-but-not-in-table)

;; CHECK-BIN-NODEBUG: (type $0 (func (result anyref)))

;; CHECK-BIN-NODEBUG: (type $1 (func (param anyref)))
Expand All @@ -154,9 +152,9 @@
;; CHECK-BIN-NODEBUG: (type $8 (func (param eqref) (result funcref)))

;; CHECK-BIN-NODEBUG: (import "env" "import_global" (global $gimport$0 eqref))
(import "env" "import_func" (func $import_func (param eqref) (result funcref)))

;; CHECK-BIN-NODEBUG: (import "env" "import_func" (func $fimport$0 (type $8) (param eqref) (result funcref)))
(import "env" "import_global" (global $import_global eqref))

;; CHECK-BIN-NODEBUG: (global $global$0 (mut eqref) (ref.null none))

;; CHECK-BIN-NODEBUG: (global $global$1 (mut funcref) (ref.null nofunc))
Expand All @@ -171,8 +169,11 @@

;; CHECK-BIN-NODEBUG: (elem $0 (i32.const 0) $0 $1 $2)

;; CHECK-BIN-NODEBUG: (elem $decl declare func$23$3)
;; CHECK-BIN-NODEBUG: (elem declare func $23 $3)
(elem declare func $ref-taken-but-not-in-table)

(import "env" "import_func" (func $import_func (param eqref) (result funcref)))
(import "env" "import_global" (global $import_global eqref))
;; CHECK-BIN-NODEBUG: (tag $tag$0 (param i32))

;; CHECK-BIN-NODEBUG: (export "export_func" (func $fimport$0))
Expand Down
6 changes: 3 additions & 3 deletions test/lit/basic/types-function-references.wast
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

;; CHECK-TEXT: (type $10 (func (param (ref null $mixed_results))))

;; CHECK-TEXT: (elem $decl declare func$call-ref$call-ref-more)
;; CHECK-TEXT: (elem declare func $call-ref $call-ref-more)

;; CHECK-TEXT: (func $call-ref (type $void)
;; CHECK-TEXT-NEXT: (call_ref $void
Expand All @@ -64,7 +64,7 @@
;; CHECK-TEXT-NEXT: )
;; CHECK-BIN: (type $10 (func (param (ref null $mixed_results))))

;; CHECK-BIN: (elem $decl declare func$call-ref$call-ref-more)
;; CHECK-BIN: (elem declare func $call-ref $call-ref-more)

;; CHECK-BIN: (func $call-ref (type $void)
;; CHECK-BIN-NEXT: (call_ref $void
Expand Down Expand Up @@ -375,7 +375,7 @@

;; CHECK-BIN-NODEBUG: (type $10 (func (param (ref null $0))))

;; CHECK-BIN-NODEBUG: (elem $decl declare func$0$2)
;; CHECK-BIN-NODEBUG: (elem declare func $0 $2)

;; CHECK-BIN-NODEBUG: (func $0 (type $1)
;; CHECK-BIN-NODEBUG-NEXT: (call_ref $1
Expand Down
2 changes: 1 addition & 1 deletion test/lit/ctor-eval/table.wat
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

;; CHECK: (elem $0 (i32.const 0) $nop)

;; CHECK: (elem $decl declare func$trap)
;; CHECK: (elem declare func $trap)

;; CHECK: (export "run" (func $run_3))
(export "run" (func $run))
Expand Down
2 changes: 1 addition & 1 deletion test/lit/non-nullable-locals.wast
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

;; CHECK: (type $2 (func (param funcref) (result i32)))

;; CHECK: (elem $decl declare func$helper)
;; CHECK: (elem declare func $helper)

;; CHECK: (func $no-uses (type $0)
;; CHECK-NEXT: (local $x (ref func))
Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/abstract-type-refining.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@
;; NO_TNH: (type $C (sub $B (func)))
(type $C (sub $B (func)))

;; YESTNH: (elem $decl declare func$A$C)
;; YESTNH: (elem declare func $A $C)

;; YESTNH: (export "A" (func $A))

Expand All @@ -1106,7 +1106,7 @@
;; YESTNH-NEXT: (ref.func $A)
;; YESTNH-NEXT: )
;; YESTNH-NEXT: )
;; NO_TNH: (elem $decl declare func$A$C)
;; NO_TNH: (elem declare func $A $C)

;; NO_TNH: (export "A" (func $A))

Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/cfp.wast
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@
(type $struct (struct funcref))
;; CHECK: (type $1 (func (param (ref null $struct))))

;; CHECK: (elem $decl declare func$test)
;; CHECK: (elem declare func $test)

;; CHECK: (func $test (type $1) (param $struct (ref null $struct))
;; CHECK-NEXT: (drop
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/dae_all-features.wast
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@

;; CHECK: (type $1 (func (param f32) (result funcref)))

;; CHECK: (elem $decl declare func$0)
;; CHECK: (elem declare func $0)

;; CHECK: (export "export" (func $export))

Expand Down
8 changes: 4 additions & 4 deletions test/lit/passes/directize_all-features.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1105,14 +1105,14 @@

;; CHECK: (elem $0 (i32.const 10) $foo-ref $foo-ref)

;; CHECK: (elem $decl declare func$select-non-nullable)
;; CHECK: (elem declare func $select-non-nullable)

;; CHECK: (func $foo-ref (type $F) (param $0 (ref func))
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; IMMUT: (elem $0 (i32.const 10) $foo-ref $foo-ref)

;; IMMUT: (elem $decl declare func$select-non-nullable)
;; IMMUT: (elem declare func $select-non-nullable)

;; IMMUT: (func $foo-ref (type $F) (param $0 (ref func))
;; IMMUT-NEXT: (unreachable)
Expand Down Expand Up @@ -1469,12 +1469,12 @@

;; CHECK: (elem $0 (i32.const 0) $func-A)

;; CHECK: (elem $decl declare func$func-B)
;; CHECK: (elem declare func $func-B)

;; CHECK: (export "a" (func $fill))
;; IMMUT: (elem $0 (i32.const 0) $func-A)

;; IMMUT: (elem $decl declare func$func-B)
;; IMMUT: (elem declare func $func-B)

;; IMMUT: (export "a" (func $fill))
(export "a" (func $fill))
Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/global-refining.wast
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
;; CLOSD: (global $func-func-init (mut (ref $0)) (ref.func $foo))
(global $func-func-init (mut funcref) (ref.func $foo))

;; CHECK: (elem $decl declare func$foo)
;; CHECK: (elem declare func $foo)

;; CHECK: (func $foo (type $0)
;; CHECK-NEXT: (global.set $func-null-init
Expand All @@ -88,7 +88,7 @@
;; CHECK-NEXT: (ref.func $foo)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CLOSD: (elem $decl declare func$foo)
;; CLOSD: (elem declare func $foo)

;; CLOSD: (func $foo (type $0)
;; CLOSD-NEXT: (global.set $func-null-init
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/gsi_vacuum_precompute.wast
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
)
))

;; CHECK: (elem $decl declare func$func1$func2)
;; CHECK: (elem declare func $func1 $func2)

;; CHECK: (export "test-A" (func $test-A))

Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/gto-mutability.wast
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

;; CHECK: (table $0 0 funcref)

;; CHECK: (elem $decl declare func$func-two-params)
;; CHECK: (elem declare func $func-two-params)

;; CHECK: (tag $tag (param (ref $struct)))
(tag $tag (param (ref $struct)))
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/gufa-cast-all.wast
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
;; CHECK: (import "a" "b" (func $import (type $3) (result i32)))
(import "a" "b" (func $import (result i32)))

;; CHECK: (elem $decl declare func$func$funcs)
;; CHECK: (elem declare func $func $funcs)

;; CHECK: (export "export1" (func $ref))

Expand Down
8 changes: 4 additions & 4 deletions test/lit/passes/gufa-refs.wast
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@
;; CHECK: (type $two-params (func (param (ref $struct) (ref $struct))))
(type $two-params (func (param (ref $struct)) (param (ref $struct))))

;; CHECK: (elem $decl declare func$func-2params-a)
;; CHECK: (elem declare func $func-2params-a)

;; CHECK: (func $func-2params-a (type $two-params) (param $x (ref $struct)) (param $y (ref $struct))
;; CHECK-NEXT: (drop
Expand Down Expand Up @@ -2330,7 +2330,7 @@
)
)

;; CHECK: (elem $decl declare func$foo$test)
;; CHECK: (elem declare func $foo $test)

;; CHECK: (func $test (type $1)
;; CHECK-NEXT: (drop
Expand Down Expand Up @@ -4464,7 +4464,7 @@
;; CHECK: (global $func (ref func) (ref.func $reffed-in-global-code))
(global $func (ref func) (ref.func $reffed-in-global-code))

;; CHECK: (elem $decl declare func$reffed1$reffed2)
;; CHECK: (elem declare func $reffed1 $reffed2)

;; CHECK: (func $reffed1 (type $i1) (param $x i32)
;; CHECK-NEXT: (drop
Expand Down Expand Up @@ -5500,7 +5500,7 @@

;; CHECK: (elem $0 func)

;; CHECK: (elem $decl declare func$test)
;; CHECK: (elem declare func $test)

;; CHECK: (func $test (type $1)
;; CHECK-NEXT: (local $ref (ref $vector))
Expand Down
14 changes: 7 additions & 7 deletions test/lit/passes/gufa-tnh-closed.wast
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

;; CHECK: (type $1 (func (param funcref)))

;; CHECK: (elem $decl declare func$possible)
;; CHECK: (elem declare func $possible)

;; CHECK: (export "out" (func $caller))

Expand Down Expand Up @@ -144,7 +144,7 @@

;; CHECK: (type $1 (func (param funcref)))

;; CHECK: (elem $decl declare func$possible)
;; CHECK: (elem declare func $possible)

;; CHECK: (export "out" (func $caller))

Expand Down Expand Up @@ -239,7 +239,7 @@

;; CHECK: (type $2 (func (param funcref)))

;; CHECK: (elem $decl declare func$possible-2)
;; CHECK: (elem declare func $possible-2)

;; CHECK: (export "out" (func $caller))

Expand Down Expand Up @@ -313,7 +313,7 @@

;; CHECK: (type $5 (func))

;; CHECK: (elem $decl declare func$possible-Y1$possible-Y2)
;; CHECK: (elem declare func $possible-Y1 $possible-Y2)

;; CHECK: (export "out" (func $caller))

Expand Down Expand Up @@ -440,7 +440,7 @@

;; CHECK: (type $6 (func))

;; CHECK: (elem $decl declare func$possible-Y1$possible-Y2)
;; CHECK: (elem declare func $possible-Y1 $possible-Y2)

;; CHECK: (export "out" (func $caller1))

Expand Down Expand Up @@ -676,7 +676,7 @@

;; CHECK: (type $5 (func))

;; CHECK: (elem $decl declare func$possible-1$possible-2)
;; CHECK: (elem declare func $possible-1 $possible-2)

;; CHECK: (export "out" (func $caller1))

Expand Down Expand Up @@ -902,7 +902,7 @@

;; CHECK: (type $5 (func))

;; CHECK: (elem $decl declare func$possible-1$possible-2)
;; CHECK: (elem declare func $possible-1 $possible-2)

;; CHECK: (export "out" (func $caller1))

Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/gufa-vs-cfp.wast
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@
(type $struct (struct funcref))
;; CHECK: (type $0 (func))

;; CHECK: (elem $decl declare func$test)
;; CHECK: (elem declare func $test)

;; CHECK: (func $test (type $0)
;; CHECK-NEXT: (drop
Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/gufa.wast
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@
(import "other" "import"
(func $other-import (param funcref)))

;; CHECK: (elem $decl declare func$target-drop$target-keep)
;; CHECK: (elem declare func $target-drop $target-keep)

;; CHECK: (export "foo" (func $foo))

Expand Down Expand Up @@ -1008,7 +1008,7 @@
(import "other" "import"
(func $other-import (param funcref)))

;; CHECK: (elem $decl declare func$target-keep$target-keep-2)
;; CHECK: (elem declare func $target-keep $target-keep-2)

;; CHECK: (export "foo" (func $foo))

Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/inlining_all-features.wast
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

;; CHECK: (type $1 (func (result funcref)))

;; CHECK: (elem $decl declare func$foo)
;; CHECK: (elem declare func $foo)

;; CHECK: (export "ref_func_test" (func $ref_func_test))
(export "ref_func_test" (func $ref_func_test))
Expand Down Expand Up @@ -117,7 +117,7 @@

;; CHECK: (type $0 (func (result (ref func))))

;; CHECK: (elem $decl declare func$1)
;; CHECK: (elem declare func $1)

;; CHECK: (func $1 (type $0) (result (ref func))
;; CHECK-NEXT: (local $0 (ref func))
Expand Down
Loading