aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2024-05-24 15:00:56 -0400
committerCherry Mui <cherryyz@google.com>2024-06-07 15:22:22 +0000
commit0b72631a8229bcb86913f4855e217ddedbfbbb46 (patch)
tree5d8e6d0913d276b550a0d7480567076d91ea5114 /test
parent98529a8e7cf1cc0b561f26a4bd3ddf8f6dbd2f8a (diff)
downloadgo-0b72631a8229bcb86913f4855e217ddedbfbbb46.tar.xz
cmd/compile: generate args_stackmap for ABI0 assembly func regardless of linkname
Currently, the compiler generates the argument stack map based on the function signature for bodyless function declarations, if it is not linknamed. The assumption is that linknamed function is provided by (Go code in) another package, so its args stack map will be generated when compiling that package. Now we have linknames added to declarations of assembly functions, to signal that this function is accessed externally. Examples include runtime.morestack_noctxt, math/big.addVV. In the current implementation the compiler does not generate its args stack map. That causes the assembly function's args stack map missing. Instead, change it to generate the stack map if it is a declaration of an ABI0 function, which can only be defined in assembly and passed to the compiler through the -symabis flag. The stack map generation currently only works with ABI0 layout anyway, so we don't need to handle ABIInternal assembly functions. Change-Id: Ic9da3b4854c604e64ed01584da3865994f5b95b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/587928 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/linknameasm.dir/a_amd64.s7
-rw-r--r--test/linknameasm.dir/x.go26
-rw-r--r--test/linknameasm.go9
3 files changed, 42 insertions, 0 deletions
diff --git a/test/linknameasm.dir/a_amd64.s b/test/linknameasm.dir/a_amd64.s
new file mode 100644
index 0000000000..2799609cd7
--- /dev/null
+++ b/test/linknameasm.dir/a_amd64.s
@@ -0,0 +1,7 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+TEXT ·asm(SB),0,$0-8
+ CALL ·callback(SB)
+ RET
diff --git a/test/linknameasm.dir/x.go b/test/linknameasm.dir/x.go
new file mode 100644
index 0000000000..38bca6f7d7
--- /dev/null
+++ b/test/linknameasm.dir/x.go
@@ -0,0 +1,26 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that a linkname applied on an assembly declaration
+// does not affect stack map generation.
+
+package main
+
+import (
+ "runtime"
+ _ "unsafe"
+)
+
+//go:linkname asm
+func asm(*int)
+
+func main() {
+ x := new(int)
+ asm(x)
+}
+
+// called from asm
+func callback() {
+ runtime.GC() // scan stack
+}
diff --git a/test/linknameasm.go b/test/linknameasm.go
new file mode 100644
index 0000000000..119f4bda42
--- /dev/null
+++ b/test/linknameasm.go
@@ -0,0 +1,9 @@
+// buildrundir
+
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build amd64
+
+package ignored