aboutsummaryrefslogtreecommitdiff
path: root/test/escape5.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2019-04-01 11:58:33 -0700
committerMatthew Dempsky <mdempsky@google.com>2019-04-02 16:34:03 +0000
commitabefcac10a635c5c6afdeada810f4663e6cb6f17 (patch)
tree1361a49965e3c1d19795abfc1734d3b262455ee8 /test/escape5.go
parent4ebc6514faa8530d1a68b4e04f57dc5c25bcb01c (diff)
downloadgo-abefcac10a635c5c6afdeada810f4663e6cb6f17.tar.gz
go-abefcac10a635c5c6afdeada810f4663e6cb6f17.zip
cmd/compile: skip escape analysis diagnostics for OADDR
For most nodes (e.g., OPTRLIT, OMAKESLICE, OCONVIFACE), escape analysis prints "escapes to heap" or "does not escape" to indicate whether that node's allocation can be heap or stack allocated. These messages are also emitted for OADDR, even though OADDR does not actually allocate anything itself. Moreover, it's redundant because escape analysis already prints "moved to heap" diagnostics when an OADDR node like "&x" causes x to require heap allocation. Because OADDR nodes don't allocate memory, my escape analysis rewrite doesn't naturally emit the "escapes to heap" / "does not escape" diagnostics for them. It's also non-trivial to replicate the exact semantics esc.go uses for OADDR. Since there are so many of these messages, I'm disabling them in this CL by themselves. I modified esc.go to suppress the Warnl calls without any other behavior changes, and then used a shell script to automatically remove any ERROR messages mentioned by run.go in "missing error" or "no match for" lines. Fixes #16300. Updates #23109. Change-Id: I3993e2743c3ff83ccd0893f4e73b366ff8871a57 Reviewed-on: https://go-review.googlesource.com/c/go/+/170319 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/escape5.go')
-rw-r--r--test/escape5.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/test/escape5.go b/test/escape5.go
index e26ecd5275..4dbe89f313 100644
--- a/test/escape5.go
+++ b/test/escape5.go
@@ -60,37 +60,37 @@ func leaktosink(p *int) *int { // ERROR "leaking param: p"
func f1() {
var x int
- p := noleak(&x) // ERROR "&x does not escape"
+ p := noleak(&x)
_ = p
}
func f2() {
var x int
- p := leaktoret(&x) // ERROR "&x does not escape"
+ p := leaktoret(&x)
_ = p
}
func f3() {
var x int // ERROR "moved to heap: x"
- p := leaktoret(&x) // ERROR "&x escapes to heap"
+ p := leaktoret(&x)
gp = p
}
func f4() {
var x int // ERROR "moved to heap: x"
- p, q := leaktoret2(&x) // ERROR "&x escapes to heap"
+ p, q := leaktoret2(&x)
gp = p
gp = q
}
func f5() {
var x int
- leaktoret22(leaktoret2(&x)) // ERROR "&x does not escape"
+ leaktoret22(leaktoret2(&x))
}
func f6() {
var x int // ERROR "moved to heap: x"
- px1, px2 := leaktoret22(leaktoret2(&x)) // ERROR "&x escapes to heap"
+ px1, px2 := leaktoret22(leaktoret2(&x))
gp = px1
_ = px2
}
@@ -142,7 +142,7 @@ func f8(p *T1) (k T2) { // ERROR "leaking param: p to result k" "leaking param:
func f9() {
var j T1 // ERROR "moved to heap: j"
- f8(&j) // ERROR "&j escapes to heap"
+ f8(&j)
}
func f10() {
@@ -159,8 +159,8 @@ func f12(_ **int) {
}
func f13() {
var x *int
- f11(&x) // ERROR "&x does not escape"
- f12(&x) // ERROR "&x does not escape"
+ f11(&x)
+ f12(&x)
runtime.KeepAlive(&x) // ERROR "&x does not escape"
}
@@ -172,8 +172,8 @@ func (_ *U) N() {}
func _() {
var u U
- u.M() // ERROR "u does not escape"
- u.N() // ERROR "u does not escape"
+ u.M()
+ u.N()
}
// Issue 24730: taking address in a loop causes unnecessary escape
@@ -182,15 +182,15 @@ type T24730 struct {
}
func (t *T24730) g() { // ERROR "t does not escape"
- y := t.x[:] // ERROR "t\.x does not escape"
- for i := range t.x[:] { // ERROR "t\.x does not escape"
- y = t.x[:] // ERROR "t\.x does not escape"
+ y := t.x[:]
+ for i := range t.x[:] {
+ y = t.x[:]
y[i] = 1
}
var z *byte
- for i := range t.x[:] { // ERROR "t\.x does not escape"
- z = &t.x[i] // ERROR "t\.x\[i\] does not escape"
+ for i := range t.x[:] {
+ z = &t.x[i]
*z = 2
}
}