test: fix tests to work with sizespecializedmalloc turned off

Cq-Include-Trybots: luci.golang.try:gotip-linux-386-nosizespecializedmalloc,gotip-linux-amd64-nosizespecializedmalloc,gotip-linux-arm64-nosizespecializedmalloc
Change-Id: I6a6a696465004b939c989afc058c4c3e1fb7134f
Reviewed-on: https://go-review.googlesource.com/c/go/+/720401
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
This commit is contained in:
matloob@golang.org 2025-11-13 17:04:54 -05:00 committed by Gopher Robot
parent 704f841eab
commit d50a571ddf
5 changed files with 16 additions and 16 deletions

View file

@ -23,7 +23,7 @@ func CountBytes(s []byte) int {
func ToByteSlice() []byte { // Issue #24698
// amd64:`LEAQ type:\[3\]uint8`
// amd64:`CALL runtime\.mallocTiny3`
// amd64:`CALL runtime\.(newobject|mallocTiny3)`
// amd64:-`.*runtime.stringtoslicebyte`
return []byte("foo")
}

View file

@ -19,7 +19,7 @@ type T struct{ M string }
var b bool
func f1(q *Q, xx []byte) interface{} { // ERROR "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: xx$" "live at entry to f1: xx$"
func f1(q *Q, xx []byte) interface{} { // ERROR "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): xx$" "live at entry to f1: xx$"
// xx was copied from the stack to the heap on the previous line:
// xx was live for the first two prints but then it switched to &xx
// being live. We should not see plain xx again.
@ -36,7 +36,7 @@ func f1(q *Q, xx []byte) interface{} { // ERROR "live at call to mallocgcSmallSc
//go:noinline
func f2(d []byte, n int) (odata, res []byte, e interface{}) { // ERROR "live at entry to f2: d$"
if n > len(d) {
return d, nil, &T{M: "hello"} // ERROR "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: d"
return d, nil, &T{M: "hello"} // ERROR "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+)+: d"
}
res = d[:n]
odata = d[n:]

View file

@ -467,9 +467,9 @@ func f27defer(b bool) {
func f27go(b bool) {
x := 0
if b {
go call27(func() { x++ }) // ERROR "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: &x$" "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: &x .autotmp_[0-9]+$" "live at call to newproc: &x$" // allocate two closures, the func literal, and the wrapper for go
go call27(func() { x++ }) // ERROR "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): &x$" "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): &x .autotmp_[0-9]+$" "live at call to newproc: &x$" // allocate two closures, the func literal, and the wrapper for go
}
go call27(func() { x++ }) // ERROR "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: &x$" "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: .autotmp_[0-9]+$" // allocate two closures, the func literal, and the wrapper for go
go call27(func() { x++ }) // ERROR "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): &x$" "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): .autotmp_[0-9]+$" // allocate two closures, the func literal, and the wrapper for go
printnl()
}
@ -538,7 +538,7 @@ func f31(b1, b2, b3 bool) {
g31(g18()) // ERROR "stack object .autotmp_[0-9]+ \[2\]string$"
}
if b2 {
h31(g18()) // ERROR "live at call to convT: .autotmp_[0-9]+$" "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: .autotmp_[0-9]+$"
h31(g18()) // ERROR "live at call to convT: .autotmp_[0-9]+$" "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): .autotmp_[0-9]+$"
}
if b3 {
panic(g18())
@ -665,14 +665,14 @@ func f39a() (x []int) {
func f39b() (x [10]*int) {
x = [10]*int{}
x[0] = new(int) // ERROR "live at call to mallocTiny[48]: x$"
x[0] = new(int) // ERROR "live at call to (newobject|mallocTiny[48]): x$"
printnl() // ERROR "live at call to printnl: x$"
return x
}
func f39c() (x [10]*int) {
x = [10]*int{}
x[0] = new(int) // ERROR "live at call to mallocTiny[48]: x$"
x[0] = new(int) // ERROR "live at call to (newobject|mallocTiny[48]): x$"
printnl() // ERROR "live at call to printnl: x$"
return
}

View file

@ -465,9 +465,9 @@ func f27defer(b bool) {
func f27go(b bool) {
x := 0
if b {
go call27(func() { x++ }) // ERROR "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: &x$" "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: &x .autotmp_[0-9]+$" "live at call to newproc: &x$" // allocate two closures, the func literal, and the wrapper for go
go call27(func() { x++ }) // ERROR "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): &x$" "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): &x .autotmp_[0-9]+$" "live at call to newproc: &x$" // allocate two closures, the func literal, and the wrapper for go
}
go call27(func() { x++ }) // ERROR "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: &x$" "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: .autotmp_[0-9]+$" // allocate two closures, the func literal, and the wrapper for go
go call27(func() { x++ }) // ERROR "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): &x$" "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): .autotmp_[0-9]+$" // allocate two closures, the func literal, and the wrapper for go
printnl()
}
@ -536,7 +536,7 @@ func f31(b1, b2, b3 bool) {
g31(g18()) // ERROR "stack object .autotmp_[0-9]+ \[2\]string$"
}
if b2 {
h31(g18()) // ERROR "live at call to convT: .autotmp_[0-9]+$" "live at call to mallocgcSmallScanNoHeaderSC[0-9]+: .autotmp_[0-9]+$"
h31(g18()) // ERROR "live at call to convT: .autotmp_[0-9]+$" "live at call to (newobject|mallocgcSmallScanNoHeaderSC[0-9]+): .autotmp_[0-9]+$"
}
if b3 {
panic(g18())
@ -663,14 +663,14 @@ func f39a() (x []int) {
func f39b() (x [10]*int) {
x = [10]*int{}
x[0] = new(int) // ERROR "live at call to mallocTiny[48]: x$"
x[0] = new(int) // ERROR "live at call to (newobject|mallocTiny[48]): x$"
printnl() // ERROR "live at call to printnl: x$"
return x
}
func f39c() (x [10]*int) {
x = [10]*int{}
x[0] = new(int) // ERROR "live at call to mallocTiny[48]: x$"
x[0] = new(int) // ERROR "live at call to (newobject|mallocTiny[48]): x$"
printnl() // ERROR "live at call to printnl: x$"
return
}

View file

@ -50,16 +50,16 @@ func TestM1() {
func TestF2() {
var v int // ERROR "moved to heap"
F2(0, 1, uintptr(unsafe.Pointer(&v)), 2) // ERROR "live at call to mallocgcSmallNoScanSC[0-9]+: .?autotmp" "live at call to F2: .?autotmp" "escapes to heap" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
F2(0, 1, uintptr(unsafe.Pointer(&v)), 2) // ERROR "live at call to (newobject|mallocgcSmallNoScanSC[0-9]+): .?autotmp" "live at call to F2: .?autotmp" "escapes to heap" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
}
func TestF4() {
var v2 int // ERROR "moved to heap"
F4(0, 1, uintptr(unsafe.Pointer(&v2)), 2) // ERROR "live at call to mallocgcSmallNoScanSC[0-9]+: .?autotmp" "live at call to F4: .?autotmp" "escapes to heap" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
F4(0, 1, uintptr(unsafe.Pointer(&v2)), 2) // ERROR "live at call to (newobject|mallocgcSmallNoScanSC[0-9]+): .?autotmp" "live at call to F4: .?autotmp" "escapes to heap" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
}
func TestM2() {
var t T
var v int // ERROR "moved to heap"
t.M2(0, 1, uintptr(unsafe.Pointer(&v)), 2) // ERROR "live at call to mallocgcSmallNoScanSC[0-9]+: .?autotmp" "live at call to T.M2: .?autotmp" "escapes to heap" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
t.M2(0, 1, uintptr(unsafe.Pointer(&v)), 2) // ERROR "live at call to (newobject|mallocgcSmallNoScanSC[0-9]+): .?autotmp" "live at call to T.M2: .?autotmp" "escapes to heap" "stack object .autotmp_[0-9]+ unsafe.Pointer$"
}