From 01ba8bfe868df2eea10ea8dd5bfbe5af0549909d Mon Sep 17 00:00:00 2001 From: Guoqi Chen Date: Tue, 25 Feb 2025 10:50:50 +0800 Subject: [PATCH] runtime/cgo: use standard ABI call setg_gcc in crosscall1 on loong64 Change-Id: Ie38583d667d579751d643b2da2aa56390b69904c Reviewed-on: https://go-review.googlesource.com/c/go/+/652255 Reviewed-by: Michael Knyszek LUCI-TryBot-Result: Go LUCI Reviewed-by: sophie zhao Reviewed-by: Michael Pratt Reviewed-by: Meidan Li --- src/runtime/asm_loong64.s | 4 ++-- src/runtime/cgo/gcc_loong64.S | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/runtime/asm_loong64.s b/src/runtime/asm_loong64.s index d5dc61ff68..604b1243f7 100644 --- a/src/runtime/asm_loong64.s +++ b/src/runtime/asm_loong64.s @@ -656,9 +656,9 @@ TEXT runtime·setg(SB), NOSPLIT, $0-8 JAL runtime·save_g(SB) RET -// void setg_gcc(G*); set g called from gcc with g in R19 +// void setg_gcc(G*); set g called from gcc with g in R4 TEXT setg_gcc<>(SB),NOSPLIT,$0-0 - MOVV R19, g + MOVV R4, g JAL runtime·save_g(SB) RET diff --git a/src/runtime/cgo/gcc_loong64.S b/src/runtime/cgo/gcc_loong64.S index 6b7668f288..c84a3715b2 100644 --- a/src/runtime/cgo/gcc_loong64.S +++ b/src/runtime/cgo/gcc_loong64.S @@ -34,10 +34,11 @@ crosscall1: fst.d $f30, $r3, 136 fst.d $f31, $r3, 144 - move $r18, $r4 // save R4 - move $r19, $r6 + // r4 = *fn, r5 = *setg_gcc, r6 = *g + move $r23, $r4 // save R4 + move $r4, $r6 jirl $r1, $r5, 0 // call setg_gcc (clobbers R4) - jirl $r1, $r18, 0 // call fn + jirl $r1, $r23, 0 // call fn ld.d $r23, $r3, 8 ld.d $r24, $r3, 16