Repository: tetratelabs/wazero
Pull request #1642 (2023-08-21 00:37:26)

wazevo(arm64): do not use x18 reserved by apple
The wazevo tests have started failing somehow only from Go 1.21 on GOOS=dawrin,
and it turns out we used the reserved "do not use" register, x18 by Apple:
https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers

Since AArch64 has lots of GP regs, we conservatively stop using x18 for all platforms (incl. linux),
but that can be relaxed later.

#1496 


Patch:
diff --git a/internal/engine/wazevo/backend/isa/arm64/abi.go b/internal/engine/wazevo/backend/isa/arm64/abi.go
index cd2a16f8..0929e3db 100644
--- a/internal/engine/wazevo/backend/isa/arm64/abi.go
+++ b/internal/engine/wazevo/backend/isa/arm64/abi.go
@@ -14,7 +14,9 @@ const xArgRetRegMax, vArgRetRegMax = x7, v7 // x0-x7 & v0-v7.
 
 var regInfo = &regalloc.RegisterInfo{
 	AllocatableRegisters: [regalloc.RegTypeNum][]regalloc.RealReg{
-		// We don't allocate x27(=tmpReg) because of the reason described on tmpReg.
+		// We don't allocate:
+		// - x27(=tmpReg) because of the reason described on tmpReg.
+		// - x18 which is reserved by the macOS: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers
 		regalloc.RegTypeInt: {
 			x8, x9, x10, x11, x12, x13, x14, x15,
 			x16, x17, x18, x19, x20, x21, x22, x23, x24, x25,
@@ -31,7 +33,7 @@ var regInfo = &regalloc.RegisterInfo{
 		},
 	},
 	CalleeSavedRegisters: map[regalloc.RealReg]struct{}{
-		x18: {}, x19: {}, x20: {}, x21: {}, x22: {}, x23: {}, x24: {}, x25: {}, x26: {}, x28: {},
+		x19: {}, x20: {}, x21: {}, x22: {}, x23: {}, x24: {}, x25: {}, x26: {}, x28: {},
 		v18: {}, v19: {}, v20: {}, v21: {}, v22: {}, v23: {}, v24: {}, v25: {}, v26: {}, v27: {}, v28: {}, v29: {}, v30: {}, v31: {},
 	},
 	CallerSavedRegisters: map[regalloc.RealReg]struct{}{
diff --git a/internal/engine/wazevo/backend/isa/arm64/abi_go_call.go b/internal/engine/wazevo/backend/isa/arm64/abi_go_call.go
index d48b3853..e4f636b3 100644
--- a/internal/engine/wazevo/backend/isa/arm64/abi_go_call.go
+++ b/internal/engine/wazevo/backend/isa/arm64/abi_go_call.go
@@ -8,7 +8,7 @@ import (
 )
 
 var calleeSavedRegistersPlusLinkRegSorted = []regalloc.VReg{
-	x18VReg, x19VReg, x20VReg, x21VReg, x22VReg, x23VReg, x24VReg, x25VReg, x26VReg, x28VReg, lrVReg,
+	x19VReg, x20VReg, x21VReg, x22VReg, x23VReg, x24VReg, x25VReg, x26VReg, x28VReg, lrVReg,
 	v18VReg, v19VReg, v20VReg, v21VReg, v22VReg, v23VReg, v24VReg, v25VReg, v26VReg, v27VReg, v28VReg, v29VReg, v30VReg, v31VReg,
 }
 
diff --git a/internal/engine/wazevo/backend/isa/arm64/abi_go_entry.go b/internal/engine/wazevo/backend/isa/arm64/abi_go_entry.go
index 3910ef61..5bef5e27 100644
--- a/internal/engine/wazevo/backend/isa/arm64/abi_go_entry.go
+++ b/internal/engine/wazevo/backend/isa/arm64/abi_go_entry.go
@@ -22,8 +22,8 @@ func (a *abiImpl) EmitGoEntryPreamble() {
 var (
 	executionContextPtrReg = x0VReg
 	// callee-saved regs so that they can be used in the prologue and epilogue.
-	savedExecutionContextPtr = x18VReg
 	paramResultSlicePtr      = x19VReg
+	savedExecutionContextPtr = x20VReg
 	// goAllocatedStackPtr is not used in the epilogue.
 	goAllocatedStackPtr = x26VReg
 )
@@ -35,7 +35,7 @@ func (a *abiImpl) constructGoEntryPreamble() (root *instruction) {
 	//// ----------------------------------- prologue ----------------------------------- ////
 
 	// First, we save executionContextPtrReg into a callee-saved register so that it can be used in epilogue as well.
-	// 		mov x18, x0
+	// 		mov savedExecutionContextPtr, x0
 	cur := a.move64(savedExecutionContextPtr, executionContextPtrReg, root)
 
 	// Next, save the current FP, SP and LR into the wazevo.executionContext:


Test patch:
diff --git a/internal/engine/wazevo/backend/backend_test.go b/internal/engine/wazevo/backend/backend_test.go
index f0b3f3a7..9f319866 100644
--- a/internal/engine/wazevo/backend/backend_test.go
+++ b/internal/engine/wazevo/backend/backend_test.go
@@ -825,7 +825,6 @@ L1 (SSA Block: blk0):
 			afterFinalizeARM64: `
 L1 (SSA Block: blk0):
 	str x30, [sp, #-0x10]!
-	str x18, [sp, #-0x10]!
 	str x19, [sp, #-0x10]!
 	str q18, [sp, #-0x10]!
 	str q19, [sp, #-0x10]!
@@ -857,34 +856,33 @@ L1 (SSA Block: blk0):
 	ldr s9, [sp, #0xb0]
 	ldr d8, [sp, #0xb8]
 	add sp, sp, #0xc0
-	str d8, [sp, #0x108]
-	str s9, [sp, #0x100]
-	str x8, [sp, #0xf8]
-	str w9, [sp, #0xf0]
-	str d10, [sp, #0xe8]
-	str s11, [sp, #0xe0]
-	str x10, [sp, #0xd8]
-	str w11, [sp, #0xd0]
-	str d12, [sp, #0xc8]
-	str s13, [sp, #0xc0]
-	str x12, [sp, #0xb8]
-	str w13, [sp, #0xb0]
-	str d14, [sp, #0xa8]
-	str s15, [sp, #0xa0]
-	str x14, [sp, #0x98]
-	str w15, [sp, #0x90]
-	str d16, [sp, #0x88]
-	str s17, [sp, #0x80]
-	str x16, [sp, #0x78]
-	str w17, [sp, #0x70]
-	str d18, [sp, #0x68]
-	str s19, [sp, #0x60]
-	str x18, [sp, #0x58]
-	str w19, [sp, #0x50]
+	str d8, [sp, #0xf8]
+	str s9, [sp, #0xf0]
+	str x8, [sp, #0xe8]
+	str w9, [sp, #0xe0]
+	str d10, [sp, #0xd8]
+	str s11, [sp, #0xd0]
+	str x10, [sp, #0xc8]
+	str w11, [sp, #0xc0]
+	str d12, [sp, #0xb8]
+	str s13, [sp, #0xb0]
+	str x12, [sp, #0xa8]
+	str w13, [sp, #0xa0]
+	str d14, [sp, #0x98]
+	str s15, [sp, #0x90]
+	str x14, [sp, #0x88]
+	str w15, [sp, #0x80]
+	str d16, [sp, #0x78]
+	str s17, [sp, #0x70]
+	str x16, [sp, #0x68]
+	str w17, [sp, #0x60]
+	str d18, [sp, #0x58]
+	str s19, [sp, #0x50]
+	str x18, [sp, #0x48]
+	str w19, [sp, #0x40]
 	ldr q19, [sp], #0x10
 	ldr q18, [sp], #0x10
 	ldr x19, [sp], #0x10
-	ldr x18, [sp], #0x10
 	ldr x30, [sp], #0x10
 	ret
 `,
@@ -1098,7 +1096,6 @@ L1 (SSA Block: blk0):
 			afterFinalizeARM64: `
 L1 (SSA Block: blk0):
 	str x30, [sp, #-0x10]!
-	str x18, [sp, #-0x10]!
 	str x19, [sp, #-0x10]!
 	str q18, [sp, #-0x10]!
 	str q19, [sp, #-0x10]!
@@ -1114,62 +1111,61 @@ L1 (SSA Block: blk0):
 	mov x19, x7
 	mov q12.8b, q4.8b
 	mov q13.8b, q5.8b
-	ldr w18, [sp, #0x50]
-	ldr x17, [sp, #0x58]
+	ldr w18, [sp, #0x40]
+	ldr x17, [sp, #0x48]
 	mov q14.8b, q6.8b
 	mov q19.8b, q7.8b
-	ldr w16, [sp, #0x60]
-	ldr x15, [sp, #0x68]
-	ldr s18, [sp, #0x70]
-	ldr d17, [sp, #0x78]
-	ldr w14, [sp, #0x80]
-	ldr x13, [sp, #0x88]
-	ldr s16, [sp, #0x90]
-	ldr d15, [sp, #0x98]
-	ldr w7, [sp, #0xa0]
-	ldr x6, [sp, #0xa8]
-	ldr s7, [sp, #0xb0]
-	ldr d6, [sp, #0xb8]
-	ldr w5, [sp, #0xc0]
-	ldr x4, [sp, #0xc8]
-	ldr s5, [sp, #0xd0]
-	ldr d4, [sp, #0xd8]
-	ldr w3, [sp, #0xe0]
-	ldr x2, [sp, #0xe8]
-	ldr s3, [sp, #0xf0]
-	ldr d2, [sp, #0xf8]
-	ldr w1, [sp, #0x100]
-	ldr x0, [sp, #0x108]
-	ldr s1, [sp, #0x110]
-	ldr d0, [sp, #0x118]
-	str w8, [sp, #0x1d8]
-	str x9, [sp, #0x1d0]
-	str s8, [sp, #0x1c8]
-	str d9, [sp, #0x1c0]
-	str w10, [sp, #0x1b8]
-	str x11, [sp, #0x1b0]
-	str s10, [sp, #0x1a8]
-	str d11, [sp, #0x1a0]
-	str w12, [sp, #0x198]
-	str x19, [sp, #0x190]
-	str s12, [sp, #0x188]
-	str d13, [sp, #0x180]
-	str w18, [sp, #0x178]
-	str x17, [sp, #0x170]
-	str s14, [sp, #0x168]
-	str d19, [sp, #0x160]
-	str w16, [sp, #0x158]
-	str x15, [sp, #0x150]
-	str s18, [sp, #0x148]
-	str d17, [sp, #0x140]
-	str w14, [sp, #0x138]
-	str x13, [sp, #0x130]
-	str s16, [sp, #0x128]
-	str d15, [sp, #0x120]
+	ldr w16, [sp, #0x50]
+	ldr x15, [sp, #0x58]
+	ldr s18, [sp, #0x60]
+	ldr d17, [sp, #0x68]
+	ldr w14, [sp, #0x70]
+	ldr x13, [sp, #0x78]
+	ldr s16, [sp, #0x80]
+	ldr d15, [sp, #0x88]
+	ldr w7, [sp, #0x90]
+	ldr x6, [sp, #0x98]
+	ldr s7, [sp, #0xa0]
+	ldr d6, [sp, #0xa8]
+	ldr w5, [sp, #0xb0]
+	ldr x4, [sp, #0xb8]
+	ldr s5, [sp, #0xc0]
+	ldr d4, [sp, #0xc8]
+	ldr w3, [sp, #0xd0]
+	ldr x2, [sp, #0xd8]
+	ldr s3, [sp, #0xe0]
+	ldr d2, [sp, #0xe8]
+	ldr w1, [sp, #0xf0]
+	ldr x0, [sp, #0xf8]
+	ldr s1, [sp, #0x100]
+	ldr d0, [sp, #0x108]
+	str w8, [sp, #0x1c8]
+	str x9, [sp, #0x1c0]
+	str s8, [sp, #0x1b8]
+	str d9, [sp, #0x1b0]
+	str w10, [sp, #0x1a8]
+	str x11, [sp, #0x1a0]
+	str s10, [sp, #0x198]
+	str d11, [sp, #0x190]
+	str w12, [sp, #0x188]
+	str x19, [sp, #0x180]
+	str s12, [sp, #0x178]
+	str d13, [sp, #0x170]
+	str w18, [sp, #0x168]
+	str x17, [sp, #0x160]
+	str s14, [sp, #0x158]
+	str d19, [sp, #0x150]
+	str w16, [sp, #0x148]
+	str x15, [sp, #0x140]
+	str s18, [sp, #0x138]
+	str d17, [sp, #0x130]
+	str w14, [sp, #0x128]
+	str x13, [sp, #0x120]
+	str s16, [sp, #0x118]
+	str d15, [sp, #0x110]
 	ldr q19, [sp], #0x10
 	ldr q18, [sp], #0x10
 	ldr x19, [sp], #0x10
-	ldr x18, [sp], #0x10
 	ldr x30, [sp], #0x10
 	ret
 `,
@@ -1248,7 +1244,6 @@ L1 (SSA Block: blk0):
 			afterFinalizeARM64: `
 L1 (SSA Block: blk0):
 	str x30, [sp, #-0x10]!
-	str x18, [sp, #-0x10]!
 	str x19, [sp, #-0x10]!
 	str x20, [sp, #-0x10]!
 	str x21, [sp, #-0x10]!
@@ -1296,22 +1291,21 @@ L1 (SSA Block: blk0):
 	cset x8, hs
 	subs xzr, x19, x21
 	cset x19, hs
-	str w19, [sp, #0xa8]
-	str w8, [sp, #0xa0]
-	str w9, [sp, #0x98]
-	str w10, [sp, #0x90]
-	str w11, [sp, #0x88]
-	str w12, [sp, #0x80]
-	str w13, [sp, #0x78]
-	str w14, [sp, #0x70]
-	str w15, [sp, #0x68]
-	str w16, [sp, #0x60]
-	str w17, [sp, #0x58]
-	str w18, [sp, #0x50]
+	str w19, [sp, #0x98]
+	str w8, [sp, #0x90]
+	str w9, [sp, #0x88]
+	str w10, [sp, #0x80]
+	str w11, [sp, #0x78]
+	str w12, [sp, #0x70]
+	str w13, [sp, #0x68]
+	str w14, [sp, #0x60]
+	str w15, [sp, #0x58]
+	str w16, [sp, #0x50]
+	str w17, [sp, #0x48]
+	str w18, [sp, #0x40]
 	ldr x21, [sp], #0x10
 	ldr x20, [sp], #0x10
 	ldr x19, [sp], #0x10
-	ldr x18, [sp], #0x10
 	ldr x30, [sp], #0x10
 	ret
 `,
@@ -1662,7 +1656,6 @@ L1 (SSA Block: blk0):
 			afterFinalizeARM64: `
 L1 (SSA Block: blk0):
 	str x30, [sp, #-0x10]!
-	str x18, [sp, #-0x10]!
 	str x19, [sp, #-0x10]!
 	str x20, [sp, #-0x10]!
 	str x21, [sp, #-0x10]!
@@ -1819,7 +1812,6 @@ L1 (SSA Block: blk0):
 	ldr x21, [sp], #0x10
 	ldr x20, [sp], #0x10
 	ldr x19, [sp], #0x10
-	ldr x18, [sp], #0x10
 	ldr x30, [sp], #0x10
 	ret
 `,
@@ -2364,7 +2356,6 @@ L1 (SSA Block: blk0):
 			afterFinalizeARM64: `
 L1 (SSA Block: blk0):
 	str x30, [sp, #-0x10]!
-	str x18, [sp, #-0x10]!
 	str x19, [sp, #-0x10]!
 	str x20, [sp, #-0x10]!
 	str x21, [sp, #-0x10]!
@@ -2629,22 +2620,22 @@ L1 (SSA Block: blk0):
 	exit_sequence x8
 	add x8, x10, x29
 	ldr w8, [x8, #0xf]
-	str x8, [sp, #0x128]
-	str x26, [sp, #0x120]
-	str x25, [sp, #0x118]
-	str x24, [sp, #0x110]
-	str x23, [sp, #0x108]
-	str x22, [sp, #0x100]
-	str x21, [sp, #0xf8]
-	str x20, [sp, #0xf0]
-	str x19, [sp, #0xe8]
-	str x18, [sp, #0xe0]
-	str x17, [sp, #0xd8]
-	str x16, [sp, #0xd0]
-	str w15, [sp, #0xc8]
-	str w14, [sp, #0xc0]
-	str w13, [sp, #0xb8]
-	str w12, [sp, #0xb0]
+	str x8, [sp, #0x118]
+	str x26, [sp, #0x110]
+	str x25, [sp, #0x108]
+	str x24, [sp, #0x100]
+	str x23, [sp, #0xf8]
+	str x22, [sp, #0xf0]
+	str x21, [sp, #0xe8]
+	str x20, [sp, #0xe0]
+	str x19, [sp, #0xd8]
+	str x18, [sp, #0xd0]
+	str x17, [sp, #0xc8]
+	str x16, [sp, #0xc0]
+	str w15, [sp, #0xb8]
+	str w14, [sp, #0xb0]
+	str w13, [sp, #0xa8]
+	str w12, [sp, #0xa0]
 	mov x2, x11
 	ldr x28, [sp], #0x10
 	ldr x26, [sp], #0x10
@@ -2655,7 +2646,6 @@ L1 (SSA Block: blk0):
 	ldr x21, [sp], #0x10
 	ldr x20, [sp], #0x10
 	ldr x19, [sp], #0x10
-	ldr x18, [sp], #0x10
 	ldr x30, [sp], #0x10
 	ret
 `,
diff --git a/internal/engine/wazevo/backend/isa/arm64/abi_go_call_test.go b/internal/engine/wazevo/backend/isa/arm64/abi_go_call_test.go
index e23b38e8..9a797003 100644
--- a/internal/engine/wazevo/backend/isa/arm64/abi_go_call_test.go
+++ b/internal/engine/wazevo/backend/isa/arm64/abi_go_call_test.go
@@ -42,31 +42,30 @@ func TestMachine_CompileGoFunctionTrampoline(t *testing.T) {
 			},
 			needModuleContextPtr: true,
 			exp: `
-	str x18, [x0, #0x50]
-	str x19, [x0, #0x60]
-	str x20, [x0, #0x70]
-	str x21, [x0, #0x80]
-	str x22, [x0, #0x90]
-	str x23, [x0, #0xa0]
-	str x24, [x0, #0xb0]
-	str x25, [x0, #0xc0]
-	str x26, [x0, #0xd0]
-	str x28, [x0, #0xe0]
-	str x30, [x0, #0xf0]
-	str q18, [x0, #0x100]
-	str q19, [x0, #0x110]
-	str q20, [x0, #0x120]
-	str q21, [x0, #0x130]
-	str q22, [x0, #0x140]
-	str q23, [x0, #0x150]
-	str q24, [x0, #0x160]
-	str q25, [x0, #0x170]
-	str q26, [x0, #0x180]
-	str q27, [x0, #0x190]
-	str q28, [x0, #0x1a0]
-	str q29, [x0, #0x1b0]
-	str q30, [x0, #0x1c0]
-	str q31, [x0, #0x1d0]
+	str x19, [x0, #0x50]
+	str x20, [x0, #0x60]
+	str x21, [x0, #0x70]
+	str x22, [x0, #0x80]
+	str x23, [x0, #0x90]
+	str x24, [x0, #0xa0]
+	str x25, [x0, #0xb0]
+	str x26, [x0, #0xc0]
+	str x28, [x0, #0xd0]
+	str x30, [x0, #0xe0]
+	str q18, [x0, #0xf0]
+	str q19, [x0, #0x100]
+	str q20, [x0, #0x110]
+	str q21, [x0, #0x120]
+	str q22, [x0, #0x130]
+	str q23, [x0, #0x140]
+	str q24, [x0, #0x150]
+	str q25, [x0, #0x160]
+	str q26, [x0, #0x170]
+	str q27, [x0, #0x180]
+	str q28, [x0, #0x190]
+	str q29, [x0, #0x1a0]
+	str q30, [x0, #0x1b0]
+	str q31, [x0, #0x1c0]
 	str x1, [x0, #0x450]
 	add x15, x0, #0x458
 	str d0, [x15], #0x8
@@ -77,31 +76,30 @@ func TestMachine_CompileGoFunctionTrampoline(t *testing.T) {
 	adr x27, #0x1c
 	str x27, [x0, #0x30]
 	exit_sequence x0
-	ldr x18, [x0, #0x50]
-	ldr x19, [x0, #0x60]
-	ldr x20, [x0, #0x70]
-	ldr x21, [x0, #0x80]
-	ldr x22, [x0, #0x90]
-	ldr x23, [x0, #0xa0]
-	ldr x24, [x0, #0xb0]
-	ldr x25, [x0, #0xc0]
-	ldr x26, [x0, #0xd0]
-	ldr x28, [x0, #0xe0]
-	ldr x30, [x0, #0xf0]
-	ldr q18, [x0, #0x100]
-	ldr q19, [x0, #0x110]
-	ldr q20, [x0, #0x120]
-	ldr q21, [x0, #0x130]
-	ldr q22, [x0, #0x140]
-	ldr q23, [x0, #0x150]
-	ldr q24, [x0, #0x160]
-	ldr q25, [x0, #0x170]
-	ldr q26, [x0, #0x180]
-	ldr q27, [x0, #0x190]
-	ldr q28, [x0, #0x1a0]
-	ldr q29, [x0, #0x1b0]
-	ldr q30, [x0, #0x1c0]
-	ldr q31, [x0, #0x1d0]
+	ldr x19, [x0, #0x50]
+	ldr x20, [x0, #0x60]
+	ldr x21, [x0, #0x70]
+	ldr x22, [x0, #0x80]
+	ldr x23, [x0, #0x90]
+	ldr x24, [x0, #0xa0]
+	ldr x25, [x0, #0xb0]
+	ldr x26, [x0, #0xc0]
+	ldr x28, [x0, #0xd0]
+	ldr x30, [x0, #0xe0]
+	ldr q18, [x0, #0xf0]
+	ldr q19, [x0, #0x100]
+	ldr q20, [x0, #0x110]
+	ldr q21, [x0, #0x120]
+	ldr q22, [x0, #0x130]
+	ldr q23, [x0, #0x140]
+	ldr q24, [x0, #0x150]
+	ldr q25, [x0, #0x160]
+	ldr q26, [x0, #0x170]
+	ldr q27, [x0, #0x180]
+	ldr q28, [x0, #0x190]
+	ldr q29, [x0, #0x1a0]
+	ldr q30, [x0, #0x1b0]
+	ldr q31, [x0, #0x1c0]
 	add x15, x0, #0x458
 	ldr w27, [x15], #0x8
 	mov w0, w27
@@ -123,31 +121,30 @@ func TestMachine_CompileGoFunctionTrampoline(t *testing.T) {
 			},
 			needModuleContextPtr: true,
 			exp: `
-	str x18, [x0, #0x50]
-	str x19, [x0, #0x60]
-	str x20, [x0, #0x70]
-	str x21, [x0, #0x80]
-	str x22, [x0, #0x90]
-	str x23, [x0, #0xa0]
-	str x24, [x0, #0xb0]
-	str x25, [x0, #0xc0]
-	str x26, [x0, #0xd0]
-	str x28, [x0, #0xe0]
-	str x30, [x0, #0xf0]
-	str q18, [x0, #0x100]
-	str q19, [x0, #0x110]
-	str q20, [x0, #0x120]
-	str q21, [x0, #0x130]
-	str q22, [x0, #0x140]
-	str q23, [x0, #0x150]
-	str q24, [x0, #0x160]
-	str q25, [x0, #0x170]
-	str q26, [x0, #0x180]
-	str q27, [x0, #0x190]
-	str q28, [x0, #0x1a0]
-	str q29, [x0, #0x1b0]
-	str q30, [x0, #0x1c0]
-	str q31, [x0, #0x1d0]
+	str x19, [x0, #0x50]
+	str x20, [x0, #0x60]
+	str x21, [x0, #0x70]
+	str x22, [x0, #0x80]
+	str x23, [x0, #0x90]
+	str x24, [x0, #0xa0]
+	str x25, [x0, #0xb0]
+	str x26, [x0, #0xc0]
+	str x28, [x0, #0xd0]
+	str x30, [x0, #0xe0]
+	str q18, [x0, #0xf0]
+	str q19, [x0, #0x100]
+	str q20, [x0, #0x110]
+	str q21, [x0, #0x120]
+	str q22, [x0, #0x130]
+	str q23, [x0, #0x140]
+	str q24, [x0, #0x150]
+	str q25, [x0, #0x160]
+	str q26, [x0, #0x170]
+	str q27, [x0, #0x180]
+	str q28, [x0, #0x190]
+	str q29, [x0, #0x1a0]
+	str q30, [x0, #0x1b0]
+	str q31, [x0, #0x1c0]
 	str x1, [x0, #0x450]
 	add x15, x0, #0x458
 	str d0, [x15], #0x8
@@ -161,31 +158,30 @@ func TestMachine_CompileGoFunctionTrampoline(t *testing.T) {
 	adr x27, #0x1c
 	str x27, [x0, #0x30]
 	exit_sequence x0
-	ldr x18, [x0, #0x50]
-	ldr x19, [x0, #0x60]
-	ldr x20, [x0, #0x70]
-	ldr x21, [x0, #0x80]
-	ldr x22, [x0, #0x90]
-	ldr x23, [x0, #0xa0]
-	ldr x24, [x0, #0xb0]
-	ldr x25, [x0, #0xc0]
-	ldr x26, [x0, #0xd0]
-	ldr x28, [x0, #0xe0]
-	ldr x30, [x0, #0xf0]
-	ldr q18, [x0, #0x100]
-	ldr q19, [x0, #0x110]
-	ldr q20, [x0, #0x120]
-	ldr q21, [x0, #0x130]
-	ldr q22, [x0, #0x140]
-	ldr q23, [x0, #0x150]
-	ldr q24, [x0, #0x160]
-	ldr q25, [x0, #0x170]
-	ldr q26, [x0, #0x180]
-	ldr q27, [x0, #0x190]
-	ldr q28, [x0, #0x1a0]
-	ldr q29, [x0, #0x1b0]
-	ldr q30, [x0, #0x1c0]
-	ldr q31, [x0, #0x1d0]
+	ldr x19, [x0, #0x50]
+	ldr x20, [x0, #0x60]
+	ldr x21, [x0, #0x70]
+	ldr x22, [x0, #0x80]
+	ldr x23, [x0, #0x90]
+	ldr x24, [x0, #0xa0]
+	ldr x25, [x0, #0xb0]
+	ldr x26, [x0, #0xc0]
+	ldr x28, [x0, #0xd0]
+	ldr x30, [x0, #0xe0]
+	ldr q18, [x0, #0xf0]
+	ldr q19, [x0, #0x100]
+	ldr q20, [x0, #0x110]
+	ldr q21, [x0, #0x120]
+	ldr q22, [x0, #0x130]
+	ldr q23, [x0, #0x140]
+	ldr q24, [x0, #0x150]
+	ldr q25, [x0, #0x160]
+	ldr q26, [x0, #0x170]
+	ldr q27, [x0, #0x180]
+	ldr q28, [x0, #0x190]
+	ldr q29, [x0, #0x1a0]
+	ldr q30, [x0, #0x1b0]
+	ldr q31, [x0, #0x1c0]
 	add x15, x0, #0x458
 	ret
 `,
@@ -198,31 +194,30 @@ func TestMachine_CompileGoFunctionTrampoline(t *testing.T) {
 				Results: []ssa.Type{ssa.TypeI32},
 			},
 			exp: `
-	str x18, [x0, #0x50]
-	str x19, [x0, #0x60]
-	str x20, [x0, #0x70]
-	str x21, [x0, #0x80]
-	str x22, [x0, #0x90]
-	str x23, [x0, #0xa0]
-	str x24, [x0, #0xb0]
-	str x25, [x0, #0xc0]
-	str x26, [x0, #0xd0]
-	str x28, [x0, #0xe0]
-	str x30, [x0, #0xf0]
-	str q18, [x0, #0x100]
-	str q19, [x0, #0x110]
-	str q20, [x0, #0x120]
-	str q21, [x0, #0x130]
-	str q22, [x0, #0x140]
-	str q23, [x0, #0x150]
-	str q24, [x0, #0x160]
-	str q25, [x0, #0x170]
-	str q26, [x0, #0x180]
-	str q27, [x0, #0x190]
-	str q28, [x0, #0x1a0]
-	str q29, [x0, #0x1b0]
-	str q30, [x0, #0x1c0]
-	str q31, [x0, #0x1d0]
+	str x19, [x0, #0x50]
+	str x20, [x0, #0x60]
+	str x21, [x0, #0x70]
+	str x22, [x0, #0x80]
+	str x23, [x0, #0x90]
+	str x24, [x0, #0xa0]
+	str x25, [x0, #0xb0]
+	str x26, [x0, #0xc0]
+	str x28, [x0, #0xd0]
+	str x30, [x0, #0xe0]
+	str q18, [x0, #0xf0]
+	str q19, [x0, #0x100]
+	str q20, [x0, #0x110]
+	str q21, [x0, #0x120]
+	str q22, [x0, #0x130]
+	str q23, [x0, #0x140]
+	str q24, [x0, #0x150]
+	str q25, [x0, #0x160]
+	str q26, [x0, #0x170]
+	str q27, [x0, #0x180]
+	str q28, [x0, #0x190]
+	str q29, [x0, #0x1a0]
+	str q30, [x0, #0x1b0]
+	str q31, [x0, #0x1c0]
 	add x15, x0, #0x458
 	str x1, [x15], #0x8
 	orr w17, wzr, #0x2
@@ -232,31 +227,30 @@ func TestMachine_CompileGoFunctionTrampoline(t *testing.T) {
 	adr x27, #0x1c
 	str x27, [x0, #0x30]
 	exit_sequence x0
-	ldr x18, [x0, #0x50]
-	ldr x19, [x0, #0x60]
-	ldr x20, [x0, #0x70]
-	ldr x21, [x0, #0x80]
-	ldr x22, [x0, #0x90]
-	ldr x23, [x0, #0xa0]
-	ldr x24, [x0, #0xb0]
-	ldr x25, [x0, #0xc0]
-	ldr x26, [x0, #0xd0]
-	ldr x28, [x0, #0xe0]
-	ldr x30, [x0, #0xf0]
-	ldr q18, [x0, #0x100]
-	ldr q19, [x0, #0x110]
-	ldr q20, [x0, #0x120]
-	ldr q21, [x0, #0x130]
-	ldr q22, [x0, #0x140]
-	ldr q23, [x0, #0x150]
-	ldr q24, [x0, #0x160]
-	ldr q25, [x0, #0x170]
-	ldr q26, [x0, #0x180]
-	ldr q27, [x0, #0x190]
-	ldr q28, [x0, #0x1a0]
-	ldr q29, [x0, #0x1b0]
-	ldr q30, [x0, #0x1c0]
-	ldr q31, [x0, #0x1d0]
+	ldr x19, [x0, #0x50]
+	ldr x20, [x0, #0x60]
+	ldr x21, [x0, #0x70]
+	ldr x22, [x0, #0x80]
+	ldr x23, [x0, #0x90]
+	ldr x24, [x0, #0xa0]
+	ldr x25, [x0, #0xb0]
+	ldr x26, [x0, #0xc0]
+	ldr x28, [x0, #0xd0]
+	ldr x30, [x0, #0xe0]
+	ldr q18, [x0, #0xf0]
+	ldr q19, [x0, #0x100]
+	ldr q20, [x0, #0x110]
+	ldr q21, [x0, #0x120]
+	ldr q22, [x0, #0x130]
+	ldr q23, [x0, #0x140]
+	ldr q24, [x0, #0x150]
+	ldr q25, [x0, #0x160]
+	ldr q26, [x0, #0x170]
+	ldr q27, [x0, #0x180]
+	ldr q28, [x0, #0x190]
+	ldr q29, [x0, #0x1a0]
+	ldr q30, [x0, #0x1b0]
+	ldr q31, [x0, #0x1c0]
 	add x15, x0, #0x458
 	ldr w27, [x15], #0x8
 	mov w0, w27
diff --git a/internal/engine/wazevo/backend/isa/arm64/abi_go_entry_test.go b/internal/engine/wazevo/backend/isa/arm64/abi_go_entry_test.go
index db8dbbf4..5b41d9ed 100644
--- a/internal/engine/wazevo/backend/isa/arm64/abi_go_entry_test.go
+++ b/internal/engine/wazevo/backend/isa/arm64/abi_go_entry_test.go
@@ -20,17 +20,17 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 			name: "empty",
 			sig:  &ssa.Signature{},
 			exp: `
-	mov x18, x0
-	str x29, [x18, #0x10]
+	mov x20, x0
+	str x29, [x20, #0x10]
 	mov x27, sp
-	str x27, [x18, #0x18]
-	str x30, [x18, #0x20]
+	str x27, [x20, #0x18]
+	str x30, [x20, #0x20]
 	mov sp, x26
 	bl #0x18
-	ldr x29, [x18, #0x10]
-	ldr x27, [x18, #0x18]
+	ldr x29, [x20, #0x10]
+	ldr x27, [x20, #0x18]
 	mov sp, x27
-	ldr x30, [x18, #0x20]
+	ldr x30, [x20, #0x20]
 	ret
 `,
 		},
@@ -43,11 +43,11 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 				},
 			},
 			exp: `
-	mov x18, x0
-	str x29, [x18, #0x10]
+	mov x20, x0
+	str x29, [x20, #0x10]
 	mov x27, sp
-	str x27, [x18, #0x18]
-	str x30, [x18, #0x20]
+	str x27, [x20, #0x18]
+	str x30, [x20, #0x20]
 	mov sp, x26
 	ldr s0, [x19]
 	ldr s1, [x19, #0x8]
@@ -55,10 +55,10 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 	ldr s3, [x19, #0x18]
 	ldr d4, [x19, #0x20]
 	bl #0x18
-	ldr x29, [x18, #0x10]
-	ldr x27, [x18, #0x18]
+	ldr x29, [x20, #0x10]
+	ldr x27, [x20, #0x18]
 	mov sp, x27
-	ldr x30, [x18, #0x20]
+	ldr x30, [x20, #0x20]
 	ret
 `,
 		},
@@ -71,11 +71,11 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 				},
 			},
 			exp: `
-	mov x18, x0
-	str x29, [x18, #0x10]
+	mov x20, x0
+	str x29, [x20, #0x10]
 	mov x27, sp
-	str x27, [x18, #0x18]
-	str x30, [x18, #0x20]
+	str x27, [x20, #0x18]
+	str x30, [x20, #0x20]
 	mov sp, x26
 	ldr w2, [x19]
 	ldr w3, [x19, #0x8]
@@ -83,10 +83,10 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 	ldr x5, [x19, #0x18]
 	ldr w6, [x19, #0x20]
 	bl #0x18
-	ldr x29, [x18, #0x10]
-	ldr x27, [x18, #0x18]
+	ldr x29, [x20, #0x10]
+	ldr x27, [x20, #0x18]
 	mov sp, x27
-	ldr x30, [x18, #0x20]
+	ldr x30, [x20, #0x20]
 	ret
 `,
 		},
@@ -99,11 +99,11 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 				},
 			},
 			exp: `
-	mov x18, x0
-	str x29, [x18, #0x10]
+	mov x20, x0
+	str x29, [x20, #0x10]
 	mov x27, sp
-	str x27, [x18, #0x18]
-	str x30, [x18, #0x20]
+	str x27, [x20, #0x18]
+	str x30, [x20, #0x20]
 	mov sp, x26
 	ldr w2, [x19]
 	ldr d0, [x19, #0x8]
@@ -116,10 +116,10 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 	ldr w7, [x19, #0x40]
 	ldr s3, [x19, #0x48]
 	bl #0x18
-	ldr x29, [x18, #0x10]
-	ldr x27, [x18, #0x18]
+	ldr x29, [x20, #0x10]
+	ldr x27, [x20, #0x18]
 	mov sp, x27
-	ldr x30, [x18, #0x20]
+	ldr x30, [x20, #0x20]
 	ret
 `,
 		},
@@ -133,11 +133,11 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 				Results: []ssa.Type{f32, f64, i32, f32, i64, i32, f64},
 			},
 			exp: `
-	mov x18, x0
-	str x29, [x18, #0x10]
+	mov x20, x0
+	str x29, [x20, #0x10]
 	mov x27, sp
-	str x27, [x18, #0x18]
-	str x30, [x18, #0x20]
+	str x27, [x20, #0x18]
+	str x30, [x20, #0x20]
 	mov sp, x26
 	ldr w2, [x19]
 	ldr d0, [x19, #0x8]
@@ -152,10 +152,10 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 	str x1, [x19], #0x8
 	str w2, [x19], #0x8
 	str d3, [x19], #0x8
-	ldr x29, [x18, #0x10]
-	ldr x27, [x18, #0x18]
+	ldr x29, [x20, #0x10]
+	ldr x27, [x20, #0x18]
 	mov sp, x27
-	ldr x30, [x18, #0x20]
+	ldr x30, [x20, #0x20]
 	ret
 `,
 		},
@@ -168,11 +168,11 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 				},
 			},
 			exp: `
-	mov x18, x0
-	str x29, [x18, #0x10]
+	mov x20, x0
+	str x29, [x20, #0x10]
 	mov x27, sp
-	str x27, [x18, #0x18]
-	str x30, [x18, #0x20]
+	str x27, [x20, #0x18]
+	str x30, [x20, #0x20]
 	sub x26, x26, #0x30
 	mov sp, x26
 	bl #0x80
@@ -202,10 +202,10 @@ func TestAbiImpl_constructGoEntryPreamble(t *testing.T) {
 	str w27, [x19], #0x8
 	ldr x27, [sp, #0x28]
 	str x27, [x19], #0x8
-	ldr x29, [x18, #0x10]
-	ldr x27, [x18, #0x18]
+	ldr x29, [x20, #0x10]
+	ldr x27, [x20, #0x18]
 	mov sp, x27
-	ldr x30, [x18, #0x20]
+	ldr x30, [x20, #0x20]
 	ret
 `,
 		},