Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 9 additions & 8 deletions scripts/port_passes_tests_to_lit.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ def port_test(args, test):
warn('Skipping because only .wast files are supported')
return

if 'translate-to-fuzz' in test or 'dwarf' in test:
warn('Skipping due to Windows issues')
return

if 'noprint' in test:
warn('Skipping due to nonstandard output')
return

dest = os.path.join(test_dir, 'lit', 'passes', name)
if not args.force and os.path.exists(dest):
warn('Skipping because destination file already exist')
Expand All @@ -59,6 +51,15 @@ def port_test(args, test):
with open(passes_file) as f:
joined_passes = f.read().strip()

if 'translate-to-fuzz' in joined_passes or 'dwarf' in joined_passes:
warn('Skipping due to Windows issues')
return

for bad in ['noprint', 'metrics', 'fuzz', 'print', 'emit']:
if bad in joined_passes:
warn('Skipping due to nonstandard output')
return

passes = joined_passes.split('_')
opts = [('--' + p if not p.startswith('O') and p != 'g' else '-' + p)
for p in passes]
Expand Down
2 changes: 1 addition & 1 deletion test/lit/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
for tool in ('not', 'foreach'):
tool_file = config.binaryen_src_root + '/scripts/' + tool + '.py'
python = sys.executable.replace('\\', '/')
config.substitutions.append((tool, python + ' ' + tool_file))
config.substitutions.append((f' {tool} ', f' {python} {tool_file} '))
134 changes: 134 additions & 0 deletions test/lit/passes/O.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; NOTE: This test was ported using port_test.py and could be cleaned up.

;; RUN: foreach %s %t wasm-opt -O -S -o - | filecheck %s

(module
;; CHECK: (type $i32_=>_i32 (func (param i32) (result i32)))

;; CHECK: (type $none_=>_i32 (func (result i32)))

;; CHECK: (type $i64_=>_none (func (param i64)))

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

;; CHECK: (export "waka" (func $if-0-unreachable-to-none))

;; CHECK: (export "many-selects" (func $many-selects))

;; CHECK: (export "end-if-else" (func $end-if-else))

;; CHECK: (export "end-if-else-call" (func $end-if-else-call))

;; CHECK: (func $ret (; has Stack IR ;) (result i32)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (call $ret)
;; CHECK-NEXT: )
;; CHECK-NEXT: (if
;; CHECK-NEXT: (call $ret)
;; CHECK-NEXT: (return
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.const 999)
;; CHECK-NEXT: )
(func $ret (export "ret") (result i32)
(block $out (result i32)
(drop (call $ret))
(if (call $ret)
(return
(return
(i32.const 1)
)
)
)
(drop (br_if $out (i32.const 999) (i32.const 1)))
(unreachable)
)
)
;; CHECK: (func $if-0-unreachable-to-none (; has Stack IR ;) (param $0 i64)
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
(func $if-0-unreachable-to-none (export "waka") (param $var$0 i64)
(local $var$1 i64)
(local $var$2 i64)
(block $label$1
(if
(i32.const 0)
(br $label$1)
(unreachable)
)
)
)
;; CHECK: (func $many-selects (; has Stack IR ;) (param $0 i32) (result i32)
;; CHECK-NEXT: (select
;; CHECK-NEXT: (i32.const -1073741824)
;; CHECK-NEXT: (select
;; CHECK-NEXT: (i32.const 1073741823)
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (i32.gt_s
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (i32.const 1073741823)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.lt_s
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (i32.const -1073741824)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $many-selects (export "many-selects") (param $0 i32) (result i32)
(if
(i32.lt_s
(local.get $0)
(i32.const -1073741824)
)
(local.set $0
(i32.const -1073741824)
)
(if
(i32.gt_s
(local.get $0)
(i32.const 1073741823)
)
(local.set $0
(i32.const 1073741823)
)
)
)
(local.get $0)
)
;; CHECK: (func $end-if-else (; has Stack IR ;) (param $0 i32) (result i32)
;; CHECK-NEXT: (select
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $end-if-else (export "end-if-else") (param $x i32) (result i32)
(if
(local.get $x)
(local.set $x
(i32.const 1)
)
)
(local.get $x)
)
;; CHECK: (func $end-if-else-call (; has Stack IR ;) (param $0 i32) (result i32)
;; CHECK-NEXT: (if (result i32)
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: (call $ret)
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $end-if-else-call (export "end-if-else-call") (param $x i32) (result i32)
(if
(local.get $x)
(local.set $x
(call $ret)
)
)
(local.get $x)
)
)

43 changes: 43 additions & 0 deletions test/lit/passes/O1.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; NOTE: This test was ported using port_test.py and could be cleaned up.

;; RUN: foreach %s %t wasm-opt -O1 -S -o - | filecheck %s

(module
;; CHECK: (type $none_=>_i32 (func (result i32)))

;; CHECK: (memory $0 1 1)
(memory $0 1 1)
(global $global$0 (mut i32) (i32.const 10))
(func "foo" (result i32)
(i32.load offset=4 align=1
(i32.and
(block $label$1 (result i32)
(global.set $global$0
(i32.const 0)
)
(i32.const -64)
)
(i32.const 15)
)
)
)
(func $signed-overflow (param $0 f32) (result i32)
(i32.sub
(i32.const 268435456)
(i32.const -2147483648)
)
)
)


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

;; CHECK: (func $0 (result i32)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.load align=1
;; CHECK-NEXT: (i32.const 4)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Loading