wazevo: passes multiple return spectests (#1701)

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
Takeshi Yoneda
2023-09-13 08:50:58 +09:00
committed by GitHub
parent b78d821ba3
commit 1cf7d0d1cd
3 changed files with 23 additions and 7 deletions

View File

@@ -237,6 +237,7 @@ func (c *compiler) assignVirtualRegisters() {
// Assigns each value to a virtual register produced by instructions.
for cur := blk.Root(); cur != nil; cur = cur.Next() {
r, rs := cur.Returns()
var N int
if r.Valid() {
id := r.ID()
ssaTyp := r.Type()
@@ -248,18 +249,20 @@ func (c *compiler) assignVirtualRegisters() {
RefCount: refCounts[id],
}
c.ssaTypeOfVRegID[vReg.ID()] = ssaTyp
N++
}
for i, r := range rs {
for _, r := range rs {
id := r.ID()
ssaTyp := r.Type()
vReg := c.AllocateVReg(regalloc.RegTypeOf(ssaTyp))
c.ssaValueToVRegs[id] = vReg
c.ssaValueDefinitions[id] = SSAValueDefinition{
Instr: cur,
N: i,
N: N,
RefCount: refCounts[id],
}
c.ssaTypeOfVRegID[vReg.ID()] = ssaTyp
N++
}
}
}

View File

@@ -128,12 +128,25 @@ func TestSpectestV2(t *testing.T) {
for _, tc := range []struct {
name string
}{
{"conversions"}, // includes non-trapping conversions.
{"block"},
{"br"},
{"call"},
{"call_indirect"},
{"conversions"},
{"if"},
{"loop"},
{"simd_const"},
} {
t.Run(tc.name, func(t *testing.T) {
spectest.RunCase(t, v2.Testcases, tc.name, context.Background(), config,
-1, 0, math.MaxInt)
t.Run("normal", func(t *testing.T) {
spectest.RunCase(t, v2.Testcases, tc.name, context.Background(), config,
-1, 0, math.MaxInt)
})
t.Run("reg high pressure", func(t *testing.T) {
ctx := wazevoapi.EnableHighRegisterPressure(context.Background())
spectest.RunCase(t, v2.Testcases, tc.name, ctx, config,
-1, 0, math.MaxInt)
})
})
}
}

View File

@@ -1032,7 +1032,7 @@ func (c *Compiler) lowerCurrentOpcode() {
var args []ssa.Value
if len(bt.Params) > 0 {
args = cloneValuesList(state.values[len(state.values)-1-len(bt.Params):])
args = cloneValuesList(state.values[len(state.values)-len(bt.Params):])
}
// Insert the conditional jump to the Else block.
@@ -1117,7 +1117,7 @@ func (c *Compiler) lowerCurrentOpcode() {
// If this is the end of Then block, we have to emit the empty Else block.
elseBlk := ctrl.blk
builder.SetCurrentBlock(elseBlk)
c.insertJumpToBlock(nil, followingBlk)
c.insertJumpToBlock(ctrl.clonedArgs, followingBlk)
}
builder.Seal(ctrl.followingBlock)