1
0
mirror of https://github.com/golang/go synced 2024-11-23 00:30:07 -07:00
go/test/linknameasm.dir/x.go
Cherry Mui 0b72631a82 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>
2024-06-07 15:22:22 +00:00

27 lines
451 B
Go

// 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
}