wazevo(regalloc): fixes the PHI value liverange (#1812)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
@@ -503,13 +503,13 @@ L4 (SSA Block: blk3):
|
||||
L1 (SSA Block: blk0):
|
||||
stp x30, xzr, [sp, #-0x10]!
|
||||
str xzr, [sp, #-0x10]!
|
||||
cbnz w2, #0xc (L2)
|
||||
cbnz w2, #0x8 (L2)
|
||||
L3 (SSA Block: blk2):
|
||||
mov x0, x3
|
||||
b #0x8 (L4)
|
||||
L2 (SSA Block: blk1):
|
||||
mov x0, x2
|
||||
mov x3, x2
|
||||
L4 (SSA Block: blk3):
|
||||
mov x0, x3
|
||||
add sp, sp, #0x10
|
||||
ldr x30, [sp], #0x10
|
||||
ret
|
||||
|
||||
@@ -219,7 +219,7 @@ func (a *Allocator) livenessAnalysis(f Function) {
|
||||
if instr.IsCopy() {
|
||||
id := int(dstVR.ID())
|
||||
if id < len(a.phiBlocks) && a.phiBlocks[id] != nil {
|
||||
info.liveOuts[srcVR] = struct{}{}
|
||||
info.liveOuts[dstVR] = struct{}{}
|
||||
}
|
||||
a.recordCopyRelation(dstVR, srcVR)
|
||||
}
|
||||
|
||||
@@ -130,6 +130,9 @@ func requireNoDiff(wasmBin []byte, checkMemory bool, requireNoError func(err err
|
||||
|
||||
func ensureMutableGlobalsMatch(compilerMod, interpreterMod api.Module, requireNoError func(err error)) {
|
||||
ci, ii := compilerMod.(*wasm.ModuleInstance), interpreterMod.(*wasm.ModuleInstance)
|
||||
if len(ci.Globals) == 0 {
|
||||
return
|
||||
}
|
||||
for i := range ci.Globals[:len(ci.Globals)-1] { // The last global is the fuel, so we can ignore it.
|
||||
cg := ci.Globals[i]
|
||||
ig := ii.Globals[i]
|
||||
|
||||
@@ -585,7 +585,7 @@ func Test1797c(t *testing.T) {
|
||||
}
|
||||
run(t, func(t *testing.T, r wazero.Runtime) {
|
||||
mod, err := r.Instantiate(ctx, getWasmBinary(t, "1797c"))
|
||||
require.NoError(t, err, "wasm binary should build successfully")
|
||||
require.NoError(t, err)
|
||||
m := mod.(*wasm.ModuleInstance)
|
||||
params := make([]uint64, 20)
|
||||
_, err = m.ExportedFunction("~zz\x00E1E\x00EE\x00$").Call(ctx, params...)
|
||||
@@ -600,7 +600,7 @@ func Test1797d(t *testing.T) {
|
||||
}
|
||||
run(t, func(t *testing.T, r wazero.Runtime) {
|
||||
mod, err := r.Instantiate(ctx, getWasmBinary(t, "1797d"))
|
||||
require.NoError(t, err, "wasm binary should build successfully")
|
||||
require.NoError(t, err)
|
||||
m := mod.(*wasm.ModuleInstance)
|
||||
params := make([]uint64, 20)
|
||||
_, err = m.ExportedFunction("p").Call(ctx, params...)
|
||||
@@ -609,3 +609,24 @@ func Test1797d(t *testing.T) {
|
||||
require.Equal(t, uint64(9241386435284803069), m.Globals[2].ValHi)
|
||||
})
|
||||
}
|
||||
|
||||
// Test1812 tests that many constant block params work fine.
|
||||
func Test1812(t *testing.T) {
|
||||
if !platform.CompilerSupported() {
|
||||
return
|
||||
}
|
||||
run(t, func(t *testing.T, r wazero.Runtime) {
|
||||
mod, err := r.Instantiate(ctx, getWasmBinary(t, "1812"))
|
||||
require.NoError(t, err)
|
||||
m := mod.(*wasm.ModuleInstance)
|
||||
res, err := m.ExportedFunction("").Call(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
[]uint64{
|
||||
0x8301fd00, 0xfd838783, 0x87878383, 0x9b000087, 0x170001fd,
|
||||
0xfd8383fd, 0x87838301, 0x878787, 0x83fd9b00, 0x201fd83, 0x878783,
|
||||
0x83fd9b00, 0x9b00fd83, 0xfd8383fd, 0x87838301, 0x87878787,
|
||||
0xfd9b0000, 0x87878383, 0x1fd8383,
|
||||
}, res)
|
||||
})
|
||||
}
|
||||
|
||||
BIN
internal/integration_test/fuzzcases/testdata/1812.wasm
vendored
Normal file
BIN
internal/integration_test/fuzzcases/testdata/1812.wasm
vendored
Normal file
Binary file not shown.
70
internal/integration_test/fuzzcases/testdata/1812.wat
vendored
Normal file
70
internal/integration_test/fuzzcases/testdata/1812.wat
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
(module
|
||||
(func (result i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32)
|
||||
i32.const 1
|
||||
if (result i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) ;; label = @1
|
||||
i32.const 1
|
||||
if (result i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) ;; label = @2
|
||||
i32.const -2097021696
|
||||
i32.const -41711741
|
||||
i32.const -2021162109
|
||||
i32.const -1694498681
|
||||
i32.const 385876477
|
||||
i32.const -41712643
|
||||
i32.const -2021424383
|
||||
i32.const 8882055
|
||||
i32.const -2080531712
|
||||
i32.const 33684867
|
||||
i32.const 8882051
|
||||
i32.const -2080531712
|
||||
i32.const -1694433917
|
||||
i32.const -41712643
|
||||
i32.const -2021424383
|
||||
i32.const -2021161081
|
||||
i32.const -40173568
|
||||
i32.const -2021162109
|
||||
i32.const 33391491
|
||||
else
|
||||
i32.const -1694498681
|
||||
i32.const -41712643
|
||||
i32.const -2088533247
|
||||
i32.const -2088566275
|
||||
i32.const -2021161085
|
||||
i32.const 34695
|
||||
i32.const -2088501861
|
||||
i32.const -2097020419
|
||||
i32.const 34695
|
||||
i32.const -2088501861
|
||||
i32.const -40173315
|
||||
i32.const 33391491
|
||||
i32.const -2021162109
|
||||
i32.const 8882055
|
||||
i32.const -2080531712
|
||||
i32.const -2097021565
|
||||
i32.const -2021161085
|
||||
i32.const 34695
|
||||
i32.const -2088501861
|
||||
end
|
||||
else
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
end
|
||||
)
|
||||
(export "" (func 0))
|
||||
)
|
||||
Reference in New Issue
Block a user