aboutsummaryrefslogtreecommitdiff
path: root/test/escape_field.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/escape_field.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/escape_field.go')
-rw-r--r--test/escape_field.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/test/escape_field.go b/test/escape_field.go
index e8835ae6ff..ae2425871f 100644
--- a/test/escape_field.go
+++ b/test/escape_field.go
@@ -23,7 +23,7 @@ type Y struct {
func field0() {
i := 0 // ERROR "moved to heap: i$"
var x X
- x.p1 = &i // ERROR "&i escapes to heap$"
+ x.p1 = &i
sink = x.p1 // ERROR "x\.p1 escapes to heap"
}
@@ -31,21 +31,21 @@ func field1() {
i := 0 // ERROR "moved to heap: i$"
var x X
// BAD: &i should not escape
- x.p1 = &i // ERROR "&i escapes to heap$"
+ x.p1 = &i
sink = x.p2 // ERROR "x\.p2 escapes to heap"
}
func field3() {
i := 0 // ERROR "moved to heap: i$"
var x X
- x.p1 = &i // ERROR "&i escapes to heap$"
+ x.p1 = &i
sink = x // ERROR "x escapes to heap"
}
func field4() {
i := 0 // ERROR "moved to heap: i$"
var y Y
- y.x.p1 = &i // ERROR "&i escapes to heap$"
+ y.x.p1 = &i
x := y.x
sink = x // ERROR "x escapes to heap"
}
@@ -54,7 +54,7 @@ func field5() {
i := 0 // ERROR "moved to heap: i$"
var x X
// BAD: &i should not escape here
- x.a[0] = &i // ERROR "&i escapes to heap$"
+ x.a[0] = &i
sink = x.a[1] // ERROR "x\.a\[1\] escapes to heap"
}
@@ -67,14 +67,14 @@ func field6a() {
i := 0 // ERROR "moved to heap: i$"
var x X
// BAD: &i should not escape
- x.p1 = &i // ERROR "&i escapes to heap$"
- field6(&x) // ERROR "field6a &x does not escape"
+ x.p1 = &i
+ field6(&x)
}
func field7() {
i := 0
var y Y
- y.x.p1 = &i // ERROR "field7 &i does not escape$"
+ y.x.p1 = &i
x := y.x
var y1 Y
y1.x = x
@@ -84,7 +84,7 @@ func field7() {
func field8() {
i := 0 // ERROR "moved to heap: i$"
var y Y
- y.x.p1 = &i // ERROR "&i escapes to heap$"
+ y.x.p1 = &i
x := y.x
var y1 Y
y1.x = x
@@ -94,7 +94,7 @@ func field8() {
func field9() {
i := 0 // ERROR "moved to heap: i$"
var y Y
- y.x.p1 = &i // ERROR "&i escapes to heap$"
+ y.x.p1 = &i
x := y.x
var y1 Y
y1.x = x
@@ -105,7 +105,7 @@ func field10() {
i := 0 // ERROR "moved to heap: i$"
var y Y
// BAD: &i should not escape
- y.x.p1 = &i // ERROR "&i escapes to heap$"
+ y.x.p1 = &i
x := y.x
var y1 Y
y1.x = x
@@ -114,33 +114,33 @@ func field10() {
func field11() {
i := 0 // ERROR "moved to heap: i$"
- x := X{p1: &i} // ERROR "&i escapes to heap$"
+ x := X{p1: &i}
sink = x.p1 // ERROR "x\.p1 escapes to heap"
}
func field12() {
i := 0 // ERROR "moved to heap: i$"
// BAD: &i should not escape
- x := X{p1: &i} // ERROR "&i escapes to heap$"
+ x := X{p1: &i}
sink = x.p2 // ERROR "x\.p2 escapes to heap"
}
func field13() {
i := 0 // ERROR "moved to heap: i$"
- x := &X{p1: &i} // ERROR "&i escapes to heap$" "field13 &X literal does not escape$"
+ x := &X{p1: &i} // ERROR "field13 &X literal does not escape$"
sink = x.p1 // ERROR "x\.p1 escapes to heap"
}
func field14() {
i := 0 // ERROR "moved to heap: i$"
// BAD: &i should not escape
- x := &X{p1: &i} // ERROR "&i escapes to heap$" "field14 &X literal does not escape$"
+ x := &X{p1: &i} // ERROR "field14 &X literal does not escape$"
sink = x.p2 // ERROR "x\.p2 escapes to heap"
}
func field15() {
i := 0 // ERROR "moved to heap: i$"
- x := &X{p1: &i} // ERROR "&X literal escapes to heap$" "&i escapes to heap$"
+ x := &X{p1: &i} // ERROR "&X literal escapes to heap$"
sink = x // ERROR "x escapes to heap"
}
@@ -148,7 +148,7 @@ func field16() {
i := 0 // ERROR "moved to heap: i$"
var x X
// BAD: &i should not escape
- x.p1 = &i // ERROR "&i escapes to heap$"
+ x.p1 = &i
var iface interface{} = x // ERROR "x escapes to heap"
x1 := iface.(X)
sink = x1.p2 // ERROR "x1\.p2 escapes to heap"
@@ -157,7 +157,7 @@ func field16() {
func field17() {
i := 0 // ERROR "moved to heap: i$"
var x X
- x.p1 = &i // ERROR "&i escapes to heap$"
+ x.p1 = &i
var iface interface{} = x // ERROR "x escapes to heap"
x1 := iface.(X)
sink = x1.p1 // ERROR "x1\.p1 escapes to heap"
@@ -167,7 +167,7 @@ func field18() {
i := 0 // ERROR "moved to heap: i$"
var x X
// BAD: &i should not escape
- x.p1 = &i // ERROR "&i escapes to heap$"
+ x.p1 = &i
var iface interface{} = x // ERROR "x escapes to heap"
y, _ := iface.(Y) // Put X, but extracted Y. The cast will fail, so y is zero initialized.
sink = y // ERROR "y escapes to heap"