cmd/compile: don't call memclrNoHeapPointersPreemptible from nosplit functions

That function will allow preemption, which could subsequently allow
for a stack copy (from shrinking). We can't let that happen inside
a nosplit function.

Update #78081

Change-Id: I12e77b50bbdcdd1e08e505a863b13cd9e1f814ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/756123
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
This commit is contained in:
Keith Randall
2026-03-17 13:28:51 -07:00
committed by Gopher Robot
parent cd2fa3b48d
commit adf9c27874
2 changed files with 4 additions and 0 deletions

View File

@@ -723,6 +723,8 @@ func extendSlice(n *ir.CallExpr, init *ir.Nodes) ir.Node {
if hasPointers {
clrname = "memclrHasPointers"
ir.CurFunc.SetWBPos(n.Pos())
} else if ir.CurFunc.Pragma&ir.Nosplit != 0 {
clrname = "memclrNoHeapPointers"
}
var clr ir.Nodes

View File

@@ -588,6 +588,8 @@ func arrayClear(wbPos src.XPos, a ir.Node, nrange *ir.RangeStmt) ir.Node {
// memclrHasPointers(hp, hn)
ir.CurFunc.SetWBPos(wbPos)
fn = mkcallstmt("memclrHasPointers", hp, hn)
} else if ir.CurFunc.Pragma&ir.Nosplit != 0 {
fn = mkcallstmt("memclrNoHeapPointers", hp, hn)
} else {
// memclrNoHeapPointersPreemptible(hp, hn)
fn = mkcallstmt("memclrNoHeapPointersPreemptible", hp, hn)