Repository: tetratelabs/wazero
Pull request #2268 (2024-06-25 17:05:03)

regalloc: removes unused Instr.AddedBeforeRegAlloc api


Patch:
diff --git a/internal/engine/wazevo/backend/isa/amd64/instr.go b/internal/engine/wazevo/backend/isa/amd64/instr.go
index 96350490..6a3e58f5 100644
--- a/internal/engine/wazevo/backend/isa/amd64/instr.go
+++ b/internal/engine/wazevo/backend/isa/amd64/instr.go
@@ -26,9 +26,6 @@ func (i *instruction) IsIndirectCall() bool { return i.kind == callIndirect }
 // IsReturn implements regalloc.Instr.
 func (i *instruction) IsReturn() bool { return i.kind == ret }
 
-// AddedBeforeRegAlloc implements regalloc.Instr.
-func (i *instruction) AddedBeforeRegAlloc() bool { return i.addedBeforeRegAlloc }
-
 // String implements regalloc.Instr.
 func (i *instruction) String() string {
 	switch i.kind {
diff --git a/internal/engine/wazevo/backend/isa/amd64/machine_regalloc.go b/internal/engine/wazevo/backend/isa/amd64/machine_regalloc.go
index 1750c892..de9dcc94 100644
--- a/internal/engine/wazevo/backend/isa/amd64/machine_regalloc.go
+++ b/internal/engine/wazevo/backend/isa/amd64/machine_regalloc.go
@@ -165,7 +165,7 @@ func (pos *labelPosition) InstrIteratorNext() *instruction {
 		pos.cur = instr
 		if instr == nil {
 			return nil
-		} else if instr.AddedBeforeRegAlloc() {
+		} else if instr.addedBeforeRegAlloc {
 			// Only concerned about the instruction added before regalloc.
 			return instr
 		}
@@ -188,7 +188,7 @@ func (pos *labelPosition) InstrRevIteratorNext() *instruction {
 		pos.cur = instr
 		if instr == nil {
 			return nil
-		} else if instr.AddedBeforeRegAlloc() {
+		} else if instr.addedBeforeRegAlloc {
 			// Only concerned about the instruction added before regalloc.
 			return instr
 		}
diff --git a/internal/engine/wazevo/backend/isa/arm64/instr.go b/internal/engine/wazevo/backend/isa/arm64/instr.go
index 08fb84d0..1f563428 100644
--- a/internal/engine/wazevo/backend/isa/arm64/instr.go
+++ b/internal/engine/wazevo/backend/isa/arm64/instr.go
@@ -51,11 +51,6 @@ func (i *instruction) IsReturn() bool {
 	return i.kind == ret
 }
 
-// AddedBeforeRegAlloc implements regalloc.Instr AddedBeforeRegAlloc.
-func (i *instruction) AddedBeforeRegAlloc() bool {
-	return i.addedBeforeRegAlloc
-}
-
 type defKind byte
 
 const (
diff --git a/internal/engine/wazevo/backend/isa/arm64/machine_regalloc.go b/internal/engine/wazevo/backend/isa/arm64/machine_regalloc.go
index c82abbdc..f2ed53ae 100644
--- a/internal/engine/wazevo/backend/isa/arm64/machine_regalloc.go
+++ b/internal/engine/wazevo/backend/isa/arm64/machine_regalloc.go
@@ -167,7 +167,7 @@ func (pos *labelPosition) InstrIteratorNext() *instruction {
 		pos.cur = instr
 		if instr == nil {
 			return nil
-		} else if instr.AddedBeforeRegAlloc() {
+		} else if instr.addedBeforeRegAlloc {
 			// Only concerned about the instruction added before regalloc.
 			return instr
 		}
@@ -190,7 +190,7 @@ func (pos *labelPosition) InstrRevIteratorNext() *instruction {
 		pos.cur = instr
 		if instr == nil {
 			return nil
-		} else if instr.AddedBeforeRegAlloc() {
+		} else if instr.addedBeforeRegAlloc {
 			// Only concerned about the instruction added before regalloc.
 			return instr
 		}
diff --git a/internal/engine/wazevo/backend/regalloc/api.go b/internal/engine/wazevo/backend/regalloc/api.go
index 5d961614..5d15bd9d 100644
--- a/internal/engine/wazevo/backend/regalloc/api.go
+++ b/internal/engine/wazevo/backend/regalloc/api.go
@@ -120,7 +120,5 @@ type (
 		IsIndirectCall() bool
 		// IsReturn returns true if this instruction is a return instruction.
 		IsReturn() bool
-		// AddedBeforeRegAlloc returns true if this instruction is added before register allocation.
-		AddedBeforeRegAlloc() bool
 	}
 )


Test patch:
diff --git a/internal/engine/wazevo/backend/regalloc/api_test.go b/internal/engine/wazevo/backend/regalloc/api_test.go
index d3d9b662..e40d5a96 100644
--- a/internal/engine/wazevo/backend/regalloc/api_test.go
+++ b/internal/engine/wazevo/backend/regalloc/api_test.go
@@ -266,9 +266,6 @@ func (m *mockInstr) Defs(ret *[]VReg) []VReg {
 	return *ret
 }
 
-// AddedBeforeRegAlloc implements Instr.
-func (m *mockInstr) AddedBeforeRegAlloc() bool { return true }
-
 // Uses implements Instr.
 func (m *mockInstr) Uses(ret *[]VReg) []VReg {
 	*ret = append((*ret)[:0], m.uses...)