1
0
mirror of https://github.com/golang/go synced 2024-11-12 00:30:22 -07:00
go/test/fixedbugs/issue15277.go
Keith Randall 075880a8e8 cmd/compile: fix build
Run live vars test only on ssa builds.
We can't just drop KeepAlive ops during regalloc.  We need
to replace them with copies.

Change-Id: Ib4b3b1381415db88fdc2165fc0a9541b73ad9759
Reviewed-on: https://go-review.googlesource.com/23225
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-05-18 20:44:00 +00:00

39 lines
805 B
Go

// run
// Copyright 2016 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.
// +build amd64
package main
import "runtime"
type big [10 << 20]byte
func f(x *big, start int64) {
if delta := inuse() - start; delta < 9<<20 {
println("after alloc: expected delta at least 9MB, got: ", delta)
}
x = nil
if delta := inuse() - start; delta > 1<<20 {
println("after drop: expected delta below 1MB, got: ", delta)
}
x = new(big)
if delta := inuse() - start; delta < 9<<20 {
println("second alloc: expected delta at least 9MB, got: ", delta)
}
}
func main() {
x := inuse()
f(new(big), x)
}
func inuse() int64 {
runtime.GC()
var st runtime.MemStats
runtime.ReadMemStats(&st)
return int64(st.Alloc)
}