types.CalcSize(fn.Type())
a := ssagen.AbiForBodylessFuncStackMap(fn)
abiInfo := a.ABIAnalyzeFuncType(fn.Type()) // abiInfo has spill/home locations for wrapper
- liveness.WriteFuncMap(fn, abiInfo)
if fn.ABI == obj.ABI0 {
+ // The current args_stackmap generation assumes the function
+ // is ABI0, and only ABI0 assembly function can have a FUNCDATA
+ // reference to args_stackmap (see cmd/internal/obj/plist.go:Flushplist).
+ // So avoid introducing an args_stackmap if the func is not ABI0.
+ liveness.WriteFuncMap(fn, abiInfo)
+
x := ssagen.EmitArgInfo(fn, abiInfo)
objw.Global(x, int32(len(x.P)), obj.RODATA|obj.LOCAL)
}
// inputs and outputs as the value of symbol <fn>.args_stackmap.
// If fn has outputs, two bitmaps are written, otherwise just one.
func WriteFuncMap(fn *ir.Func, abiInfo *abi.ABIParamResultInfo) {
- if ir.FuncName(fn) == "_" || fn.Sym().Linkname != "" {
+ if ir.FuncName(fn) == "_" {
return
}
nptr := int(abiInfo.ArgWidth() / int64(types.PtrSize))
--- /dev/null
+// 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
--- /dev/null
+// 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
+}
--- /dev/null
+// 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