Cranelift: Add .wat to assembly test support and generate Wasm load/store tests for all ISAs (#5439)

* cranelift-filetest: Add the ability to test `.wat` to assembly

* Make the load/store test case generator script use `.wat` tests

And generate tests that exercise both Wasm-to-CLIF lowering and Wasm all the way
to assembly.

* Remove old versions of generated load/store tests

* Add new generated load/store tests

* Fix filename reference in script
This commit is contained in:
Nick Fitzgerald
2022-12-14 13:13:43 -08:00
committed by GitHub
parent 9dc4f1a83c
commit be710df237
502 changed files with 34040 additions and 760 deletions

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=false
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i32, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i32
block0(v0: i64, v1: i32, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i32, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i32
fn0 = %do_store(i64, i32, i32)
block0(v0: i64, v1: i32, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=true
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i32, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i32
block0(v0: i64, v1: i32, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i32, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i32
fn0 = %do_store(i64, i32, i32)
block0(v0: i64, v1: i32, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=false
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i32, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0xffff_ffff, index_type i32
block0(v0: i64, v1: i32, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i32, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0xffff_ffff, index_type i32
fn0 = %do_store(i64, i32, i32)
block0(v0: i64, v1: i32, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=true
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i32, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0xffff_ffff, index_type i32
block0(v0: i64, v1: i32, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i32, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0xffff_ffff, index_type i32
fn0 = %do_store(i64, i32, i32)
block0(v0: i64, v1: i32, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=false
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i64, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i64
block0(v0: i64, v1: i64, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i64, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i64
fn0 = %do_store(i64, i64, i32)
block0(v0: i64, v1: i64, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=true
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i64, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i64
block0(v0: i64, v1: i64, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i64, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i64
fn0 = %do_store(i64, i64, i32)
block0(v0: i64, v1: i64, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=false
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i64, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0xffff_ffff, index_type i64
block0(v0: i64, v1: i64, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i64, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0xffff_ffff, index_type i64
fn0 = %do_store(i64, i64, i32)
block0(v0: i64, v1: i64, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=true
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i64, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0xffff_ffff, index_type i64
block0(v0: i64, v1: i64, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i64, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
gv2 = load.i64 notrap aligned gv0+8
heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0xffff_ffff, index_type i64
fn0 = %do_store(i64, i64, i32)
block0(v0: i64, v1: i64, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=false
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i32, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i32
block0(v0: i64, v1: i32, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i32, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i32
fn0 = %do_store(i64, i32, i32)
block0(v0: i64, v1: i32, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=true
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i32, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i32
block0(v0: i64, v1: i32, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i32, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i32
fn0 = %do_store(i64, i32, i32)
block0(v0: i64, v1: i32, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=false
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i32, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0xffff_ffff, index_type i32
block0(v0: i64, v1: i32, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i32, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0xffff_ffff, index_type i32
fn0 = %do_store(i64, i32, i32)
block0(v0: i64, v1: i32, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=true
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i32, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0xffff_ffff, index_type i32
block0(v0: i64, v1: i32, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i32, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0xffff_ffff, index_type i32
fn0 = %do_store(i64, i32, i32)
block0(v0: i64, v1: i32, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=false
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i64, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i64
block0(v0: i64, v1: i64, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i64, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i64
fn0 = %do_store(i64, i64, i32)
block0(v0: i64, v1: i64, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=true
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i64, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i64
block0(v0: i64, v1: i64, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i64, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i64
fn0 = %do_store(i64, i64, i32)
block0(v0: i64, v1: i64, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=false
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i64, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0xffff_ffff, index_type i64
block0(v0: i64, v1: i64, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i64, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0xffff_ffff, index_type i64
fn0 = %do_store(i64, i64, i32)
block0(v0: i64, v1: i64, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,41 +0,0 @@
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=true
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, i64, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0xffff_ffff, index_type i64
block0(v0: i64, v1: i64, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, i64, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0xffff_ffff, index_type i64
fn0 = %do_store(i64, i64, i32)
block0(v0: i64, v1: i64, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd

View File

@@ -1,91 +0,0 @@
#!/usr/bin/env bash
# This script generates the `heap_load_store_*.clif` test files.
#
# Usage:
#
# $ ./make-heap-load-store-tests.sh
set -e
cd $(dirname "$0")
function generate_one_test() {
local kind=$1
local index_type=$2
local guard=$3
local spectre=$4
local enable_spectre=true
if [[ $spectre == "no" ]]; then
enable_spectre=false
fi
local have_guards=yes
if [[ $guard == "0" ]]; then
have_guards=no
fi
local gv2=""
local bound=0x1000
if [[ $kind == "dynamic" ]]; then
gv2="gv2 = load.i64 notrap aligned gv0+8"
bound=gv2
fi
local filename="heap_load_store_${kind}_${index_type}_${have_guards}_guards_${spectre}_spectre.clif"
echo "Generating $filename"
cat <<EOF > "$filename"
;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!!
test interpret
test run
set enable_heap_access_spectre_mitigation=${enable_spectre}
target x86_64
target s390x
target aarch64
target riscv64
function %do_store(i64 vmctx, ${index_type}, i32) {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
$gv2
heap0 = ${kind} gv1, min 0x1000, bound ${bound}, offset_guard ${guard}, index_type ${index_type}
block0(v0: i64, v1: ${index_type}, v2: i32):
heap_store.i32 heap0 little v1+4, v2
return
}
function %test(i64 vmctx, ${index_type}, i32) -> i32 {
gv0 = vmctx
gv1 = load.i64 notrap aligned gv0+0
$gv2
heap0 = ${kind} gv1, min 0x1000, bound ${bound}, offset_guard ${guard}, index_type ${index_type}
fn0 = %do_store(i64, ${index_type}, i32)
block0(v0: i64, v1: ${index_type}, v2: i32):
call fn0(v0, v1, v2)
v3 = heap_load.i32 heap0 little v1+4
return v3
}
; heap: ${kind}, size=0x1000, ptr=vmctx+0, bound=vmctx+8
; run: %test(0, 0) == 0
; run: %test(0, -1) == -1
; run: %test(16, 1) == 1
; run: %test(16, -1) == -1
; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd
EOF
}
for spectre in "yes" "no"; do
for guard in "0" "0xffff_ffff"; do
for index_type in "i32" "i64"; do
for kind in "static" "dynamic"; do
generate_one_test $kind $index_type $guard $spectre
done
done
done
done